ss-components.js 394 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360
  1. import { ssIcon, commonIcon } from "./icon-config.js";
  2. import * as IndexComponents from "./ss-index-components.js";
  3. import * as EchartComponents from "./ss-echarts-compnents.js";
  4. import {
  5. isNum,
  6. toStyleStr,
  7. buildThumbUrl,
  8. openServiceDialog,
  9. pickSearchParams,
  10. } from "./tools.js"; // 功能说明:组件内统一构建缩略图URL、打开服务弹窗,减少 JSP 层字段转换 by xu 20260122
  11. import { EVEN_VAR } from "./EventBus.js";
  12. // import * as elements from "../lib/element-plus.js";
  13. (function () {
  14. const {
  15. createApp,
  16. ref,
  17. reactive,
  18. watch,
  19. onMounted,
  20. onBeforeUnmount,
  21. h,
  22. computed,
  23. resolveComponent,
  24. watchEffect,
  25. nextTick,
  26. onVnodeMounted,
  27. Teleport,
  28. inject,
  29. provide,
  30. } = Vue;
  31. // 弹窗默认遮罩z-index
  32. let currentZIndex = 100;
  33. // 目前已存在的弹窗
  34. const topWindow = window.top;
  35. topWindow.dialogInstances = topWindow.dialogInstances || [];
  36. // 新建弹窗
  37. function createSsDialogInstance(setting, callbackEvent) {
  38. currentZIndex += 10; // 动态提升 z-index
  39. const container = document.createElement("div");
  40. document.body.appendChild(container);
  41. const app = Vue.createApp({
  42. render() {
  43. return h(SsDialog, {
  44. ...setting,
  45. zIndex: currentZIndex,
  46. onClose() {
  47. document.body.removeChild(container); // 仅移除弹窗容器
  48. const index = topWindow.dialogInstances.indexOf(app);
  49. if (index > -1) {
  50. topWindow.dialogInstances.splice(index, 1); // 移除实例
  51. }
  52. // 关闭后的回调
  53. if (callbackEvent && typeof callbackEvent === "function") {
  54. callbackEvent();
  55. }
  56. app.unmount(); // 仅卸载弹窗实例
  57. if (container.parentNode) {
  58. container.parentNode.removeChild(container); // 确保移除容器
  59. }
  60. },
  61. });
  62. },
  63. });
  64. topWindow.dialogInstances.push({ app, callbackEvent, container });
  65. app.component("ss-mark", SsMark); // 注册 ss-mark 组件
  66. app.component("ss-icon", SsIcon);
  67. app.component("ss-full-style-header", SsFullStyleHeader); // 注册 ss-full-style-header 组件
  68. app.mount(container);
  69. }
  70. // ss-breadcrumb 一级菜单页面面包屑
  71. const SsBreadcrumb = {
  72. name: "SsBreadcrumb",
  73. props: {
  74. level: {
  75. type: Object,
  76. default: null,
  77. },
  78. },
  79. setup(props) {
  80. const currentMenu = ref(null);
  81. const folderPath = ref([]);
  82. const eventBus = window.parent.sharedEventBus;
  83. // 监听页面变化
  84. onMounted(() => {
  85. // 获取初始页面
  86. currentMenu.value = eventBus.getState(EVEN_VAR.currentPage);
  87. folderPath.value = eventBus.getState("folderPath") || [];
  88. // 订阅页面变化
  89. eventBus.subscribe(EVEN_VAR.currentPage, (page) => {
  90. currentMenu.value = page;
  91. });
  92. eventBus.subscribe("folderPath", (path) => {
  93. folderPath.value = path || [];
  94. });
  95. });
  96. // 修改点击处理函数
  97. const handlePathClick = (index) => {
  98. if (props.level?.onBack) {
  99. // 截取到点击的位置,后面的路径会被销毁
  100. const newPath = folderPath.value.slice(0, index + 1);
  101. eventBus.publish("folderPath", newPath);
  102. // 返回到对应层级
  103. const targetFolder = newPath[newPath.length - 1]?.folder || null;
  104. props.level.onBack(targetFolder);
  105. }
  106. };
  107. const SsCommonIcon = resolveComponent("SsCommonIcon");
  108. return () =>
  109. h("div", { class: "bread-crumb" }, [
  110. currentMenu.value &&
  111. h(
  112. "div",
  113. {
  114. onClick: () => {
  115. if (props.level?.onBack) {
  116. eventBus.publish("folderPath", []);
  117. props.level.onBack(null); // 返回到根目录
  118. } else {
  119. eventBus.publish(EVEN_VAR.currentPage, currentMenu.value);
  120. }
  121. },
  122. },
  123. currentMenu.value.label || currentMenu.value.name
  124. ),
  125. ...(folderPath.value || [])
  126. .map((folder, index) => [
  127. h(SsCommonIcon, { class: "common-icon-arrow-right" }),
  128. h(
  129. "div",
  130. {
  131. class: "bread-crumb-item",
  132. onClick: () => handlePathClick(index),
  133. style: { cursor: "pointer" },
  134. },
  135. folder.title
  136. ),
  137. ])
  138. .flat(),
  139. ]);
  140. },
  141. };
  142. // ss-input form表单的输入
  143. const SsInput = {
  144. name: "SsInp", //把SsInput改为SsInp Ben(20251225)
  145. inheritAttrs: false, // 不直接继承属性到组件根元素
  146. props: {
  147. name: {
  148. type: String,
  149. required: true,
  150. default: "",
  151. },
  152. // 接收 v-model 绑定的值
  153. errTip: {
  154. type: String,
  155. },
  156. required: {
  157. type: Boolean,
  158. default: false,
  159. },
  160. placeholder: {
  161. type: String,
  162. default: "请输入",
  163. },
  164. defaultValue: [String, Number],
  165. modelValue: [String, Number],
  166. // 新增:附件配置
  167. fj: {
  168. type: Object,
  169. default: null,
  170. },
  171. // 新增:param 配置(用于附件功能)
  172. param: {
  173. type: Object,
  174. default: null,
  175. },
  176. // 新增:高度配置
  177. height: {
  178. type: String,
  179. default: "",
  180. },
  181. // 功能说明:传 height 时允许回车换行(多行输入);未传 height 默认单行 by xu 20260204
  182. // 功能说明:onChange 全局回调 prop,桥接 API 赋值时自动触发 by xu 20260416
  183. onchange: {
  184. type: String,
  185. required: false,
  186. },
  187. },
  188. emits: ["update:modelValue", "input", "blur", "change"], // 允许更新 v-model 绑定的值
  189. setup(props, { emit }) {
  190. const errMsg = ref("");
  191. const inputRef = ref(null);
  192. const textareaRef = ref(null);
  193. const inputValue = ref(props.modelValue || props.defaultValue || "");
  194. const contentFloatingDiv = ref(false); // 控制浮动 DIV 的显示
  195. const floatingDivPosition = ref("bottom"); // 'bottom' 或 'top'
  196. const isFocused = ref(false); // 跟踪焦点状态
  197. // 附件相关变量(仅在传入 param 时初始化)
  198. const buttonConfigRaw = props.param && props.param.button ? props.param.button : null;
  199. const buttonArray = Array.isArray(buttonConfigRaw)
  200. ? buttonConfigRaw
  201. : buttonConfigRaw
  202. ? [buttonConfigRaw]
  203. : [];
  204. const attachmentButton =
  205. buttonArray.find((btn) => btn && btn.cmsAddUrl && btn.cmsUpdUrl) || null;
  206. const hasAttachmentButton = !!attachmentButton;
  207. const attachmentFieldName =
  208. attachmentButton?.name || (props.fj && props.fj.name) || "fjid";
  209. const attachmentButtonText =
  210. attachmentButton?.desc ||
  211. attachmentButton?.text ||
  212. props.fj?.desc ||
  213. props.fj?.text ||
  214. "附件";
  215. const resolvePageSearchParam = (key) => {
  216. try {
  217. return new URL(window.location.href).searchParams.get(key) || "";
  218. } catch (error) {
  219. return "";
  220. }
  221. };
  222. const resolveAttachmentObjName = () =>
  223. props.param?.obj ||
  224. props.param?.ssObjName ||
  225. document.querySelector("[name='ssObjName']")?.value ||
  226. window?.ss?.dom?.ssObjName ||
  227. resolvePageSearchParam("ssObjName") ||
  228. "";
  229. const resolveAttachmentObjId = () =>
  230. props.param?.ssObjId ||
  231. props.param?.objId ||
  232. document.querySelector("[name='ssObjId']")?.value ||
  233. resolvePageSearchParam("ssObjId") ||
  234. "";
  235. const buildAttachmentCreatePayload = () => ({
  236. name: attachmentFieldName,
  237. ssNrObjName: resolveAttachmentObjName(),
  238. ssNrObjId: resolveAttachmentObjId(),
  239. });
  240. const buildAttachmentDialogQuery = () =>
  241. "&nrid=T-" +
  242. fjid.value +
  243. "&objectId=" +
  244. fjid.value +
  245. "&objectName=" +
  246. attachmentFieldName +
  247. "&callback=" +
  248. (window[attachmentFieldName + "CallbackName"] || "");
  249. let fjid = ref(attachmentButton?.val || null);
  250. let mode = props.param ? props.param.mode : null;
  251. // 功能说明:只有存在非空校验(notNull)且值为空时,才显示红线 by xu 20260402
  252. const hasNotNullRule = () => {
  253. const validations = window.ssVm?.validations?.get(props.name);
  254. if (!validations || validations.length === 0) return false;
  255. return validations.some(v => v.ruleName && v.ruleName.includes('notNull'));
  256. };
  257. const showRequired = computed(() => {
  258. const validations = window.ssVm?.validations?.get(props.name);
  259. if (!validations || validations.length === 0) return false;
  260. // 检查是否存在 notNull 规则
  261. const hasNotNull = validations.some(v => v.ruleName && v.ruleName.includes('notNull'));
  262. // 有非空规则且值为空时显示红线
  263. if (hasNotNull && !inputValue.value) {
  264. return true;
  265. }
  266. return false;
  267. });
  268. // 计算floatdiv应该向上还是向下展开
  269. const calculateFloatingDivPosition = () => {
  270. nextTick(() => {
  271. const textarea = inputRef.value;
  272. if (!textarea) return;
  273. const rect = textarea.getBoundingClientRect();
  274. const viewportHeight = window.innerHeight;
  275. // 预估floatdiv的高度(最多5行 * 20px + 上下padding + border)
  276. const estimatedFloatDivHeight = 20 * 5 + 10 + 2; // 5行 + padding + border = 112px
  277. // 检查下方空间
  278. const spaceBelow = viewportHeight - rect.bottom;
  279. // 如果下方空间不足,且上方空间足够,则向上展开
  280. if (
  281. spaceBelow < estimatedFloatDivHeight &&
  282. rect.top > estimatedFloatDivHeight
  283. ) {
  284. floatingDivPosition.value = "top";
  285. } else {
  286. floatingDivPosition.value = "bottom";
  287. }
  288. });
  289. };
  290. // 计算floatdiv的top偏移量
  291. const getFloatingDivTop = computed(() => {
  292. if (props.height) {
  293. // 有height时,padding是5px
  294. return "5px";
  295. } else {
  296. // 没有height时是单行居中,需要计算居中位置
  297. // 假设input-container高度是32px(或者从CSS读取),单行20px
  298. // 居中偏移 = (容器高度 - 行高) / 2 = (32 - 20) / 2 = 6px
  299. return "6px";
  300. }
  301. });
  302. const validate = () => {
  303. if (window.ssVm) {
  304. const result = window.ssVm.validateField(props.name);
  305. errMsg.value = result.valid ? "" : result.message;
  306. }
  307. };
  308. // 功能说明:调用全局 onChange 回调 by xu 20260416
  309. const callGlobalOnchg = (value) => {
  310. if (props.onchange && typeof props.onchange === "string") {
  311. if (
  312. typeof window !== "undefined" &&
  313. window[props.onchange] &&
  314. typeof window[props.onchange] === "function"
  315. ) {
  316. try {
  317. window[props.onchange](value);
  318. } catch (error) {
  319. console.error(`调用全局函数 ${props.onchange} 时出错:`, error);
  320. }
  321. }
  322. }
  323. };
  324. // 使用 watch 监听 props.errTip 和 props.modelValue 的变化
  325. watch(
  326. () => props.errTip,
  327. (newVal) => {
  328. errMsg.value = newVal;
  329. },
  330. { immediate: true }
  331. );
  332. watch(
  333. () => props.modelValue,
  334. (newVal) => {
  335. inputValue.value = newVal;
  336. // 桥接 API 赋值时触发全局 onChange by xu 20260416
  337. callGlobalOnchg(newVal);
  338. }
  339. );
  340. // 挂载时的逻辑
  341. onMounted(() => {
  342. errMsg.value = props.errTip;
  343. inputValue.value = props.modelValue || props.defaultValue || "";
  344. });
  345. // 计算并调整textarea的高度
  346. const adjustHeight = () => {
  347. nextTick(() => {
  348. const textarea = textareaRef.value;
  349. if (!textarea) return;
  350. // floatDiv的textarea始终自动计算高度,不受props.height影响
  351. // 重置高度以获得正确的scrollHeight
  352. textarea.style.height = "auto";
  353. // 计算新高度 - 统一限制为5行
  354. const lineHeight = parseInt(
  355. getComputedStyle(textarea).lineHeight,
  356. 10
  357. );
  358. const maxHeight = lineHeight * 5; // 统一为5行
  359. const newHeight = Math.min(textarea.scrollHeight, maxHeight);
  360. textarea.style.height = `${newHeight}px`;
  361. });
  362. };
  363. // 检查是否应该显示浮动窗口(需要同时满足:有焦点 + 内容超出)
  364. // 修复新增页面点击就出现floatdiv的问题 by xu 20251212
  365. const checkShouldShowFloatingDiv = () => {
  366. const textarea = inputRef.value;
  367. if (!textarea) return false;
  368. // 首先检查是否有内容,没有内容时不显示floatdiv by xu 20251212
  369. if (!inputValue.value || inputValue.value.toString().trim() === "") {
  370. console.log("[floatdiv] 内容为空,不显示floatdiv");
  371. return false;
  372. }
  373. // 判断内容是否超出 by xu 20251212
  374. // 同时检查横向和纵向溢出,任一方向溢出都应显示floatdiv
  375. // 纵向溢出需要加容差值,避免padding/border导致的误判 by xu 20251212
  376. const verticalTolerance = 5; // 容差值5px
  377. const isHorizontalOverflow =
  378. textarea.scrollWidth > textarea.clientWidth;
  379. const isVerticalOverflow =
  380. textarea.scrollHeight > textarea.clientHeight + verticalTolerance;
  381. const isOverflow = isHorizontalOverflow || isVerticalOverflow;
  382. console.log(
  383. "[floatdiv] 溢出检测 - scrollWidth:",
  384. textarea.scrollWidth,
  385. "clientWidth:",
  386. textarea.clientWidth,
  387. "horizontalOverflow:",
  388. isHorizontalOverflow
  389. );
  390. console.log(
  391. "[floatdiv] 溢出检测 - scrollHeight:",
  392. textarea.scrollHeight,
  393. "clientHeight:",
  394. textarea.clientHeight,
  395. "tolerance:",
  396. verticalTolerance,
  397. "verticalOverflow:",
  398. isVerticalOverflow
  399. );
  400. const shouldShow = isFocused.value && isOverflow;
  401. console.log(
  402. "[floatdiv] 最终判断 - isFocused:",
  403. isFocused.value,
  404. "isOverflow:",
  405. isOverflow,
  406. "shouldShow:",
  407. shouldShow
  408. );
  409. // 需要同时满足:有焦点 + 内容超出
  410. return shouldShow;
  411. };
  412. // 定义事件处理函数
  413. const onInput = (event) => {
  414. const newValue = event.target.value;
  415. inputValue.value = newValue;
  416. emit("update:modelValue", newValue);
  417. validate(); // 输入时验证
  418. nextTick(() => {
  419. // 检查是否需要显示浮动div
  420. contentFloatingDiv.value = checkShouldShowFloatingDiv();
  421. // 如果需要显示floatdiv,计算其位置
  422. if (contentFloatingDiv.value) {
  423. calculateFloatingDivPosition();
  424. }
  425. });
  426. adjustHeight();
  427. };
  428. const onFocus = (event) => {
  429. // 设置焦点状态为true
  430. isFocused.value = true;
  431. adjustHeight();
  432. // 检查是否应该显示浮动窗口
  433. nextTick(() => {
  434. contentFloatingDiv.value = checkShouldShowFloatingDiv();
  435. if (contentFloatingDiv.value) {
  436. calculateFloatingDivPosition();
  437. }
  438. });
  439. };
  440. // 失去焦点时进行验证
  441. const onBlur = (event) => {
  442. emit("blur", event.target);
  443. validate(); // 失焦时验证
  444. nextTick(() => {
  445. // 如果焦点不在 textarea 上,则隐藏浮动 div
  446. if (!document.activeElement.classList.contains("input-control")) {
  447. isFocused.value = false;
  448. contentFloatingDiv.value = false;
  449. }
  450. });
  451. };
  452. const onChange = (event) => {
  453. inputValue.value = event.target.value || "";
  454. emit("change", inputValue.value);
  455. };
  456. const onMouseover = (event) => {
  457. nextTick(() => {
  458. // setTimeout(contentFloatingDiv.value = true, 500)
  459. });
  460. };
  461. const onMouseleave = (event) => {
  462. // contentFloatingDiv.value = false
  463. };
  464. // 功能说明:传了 height 视为多行允许回车;未传 height 拦截回车(单行表现) by xu 20260204
  465. const onKeydown = (event) => {
  466. const allowMultiline =
  467. typeof props.height === "string" && props.height.trim() !== "";
  468. if (!allowMultiline && event.key === "Enter") {
  469. event.preventDefault();
  470. }
  471. };
  472. // 附件按钮点击处理(从 SsEditor 搬运)
  473. const onAttachmentClick = (e) => {
  474. e.preventDefault();
  475. if (!hasAttachmentButton || !attachmentButton) {
  476. console.warn("未配置 param 参数");
  477. return;
  478. }
  479. console.log("附件点击了");
  480. console.log("param", props.param);
  481. console.log("cmsAddUrl", attachmentButton.cmsAddUrl);
  482. // 如果 fjid 为空,先调用 cmsAddUrl 创建
  483. if (fjid.value == null || fjid.value == "") {
  484. $.ajax({
  485. type: "post",
  486. url: attachmentButton.cmsAddUrl,
  487. async: false,
  488. data: buildAttachmentCreatePayload(),
  489. success: function (_fjid) {
  490. console.log("cmsAddUrl success", _fjid);
  491. fjid.value = _fjid;
  492. },
  493. });
  494. }
  495. // 构建参数字符串
  496. const str = buildAttachmentDialogQuery();
  497. console.log("str", str);
  498. // 打开附件编辑对话框
  499. SS.openDialog({
  500. src: attachmentButton.cmsUpdUrl + str,
  501. headerTitle: "编辑",
  502. width: 900,
  503. high: 664,
  504. zIndex: 51,
  505. });
  506. };
  507. return {
  508. errMsg,
  509. inputValue,
  510. showRequired,
  511. onInput,
  512. onBlur,
  513. onChange,
  514. onMouseover,
  515. onMouseleave,
  516. onKeydown, // 新增:键盘事件处理 by xu 20251212
  517. contentFloatingDiv,
  518. floatingDivPosition,
  519. getFloatingDivTop,
  520. inputRef,
  521. textareaRef,
  522. onFocus,
  523. onAttachmentClick,
  524. attachmentFieldName,
  525. attachmentButtonText,
  526. hasAttachmentButton,
  527. fjid, // 附件 ID,用于隐藏字段
  528. };
  529. },
  530. render() {
  531. const { resolveComponent, h } = Vue;
  532. const SsIcon = resolveComponent("ss-icon");
  533. const SsEditorIcon = resolveComponent("SsEditorIcon");
  534. // 构建主textarea的样式
  535. const mainTextareaStyle = {};
  536. if (this.height) {
  537. mainTextareaStyle.height = "auto";
  538. // mainTextareaStyle.paddingTop = '5px'; // 有高度时加上padding-top
  539. // mainTextareaStyle.paddingBottom = '5px'; // 有高度时加上padding-bottom
  540. } else {
  541. // 没有指定height时,固定为单行高度
  542. mainTextareaStyle.height = "20px"; // 行高20px
  543. mainTextareaStyle.lineHeight = "20px"; // 确保单行垂直居中
  544. mainTextareaStyle.display = "flex";
  545. mainTextareaStyle.marginBottom = "5px";
  546. }
  547. // 如果有附件按钮,为按钮留出空间
  548. if (this.fj || this.hasAttachmentButton) {
  549. //加上&&this.param.button条件 Ben(20251221)
  550. mainTextareaStyle.paddingRight = "75px";
  551. }
  552. const mainTextareaRows = this.height
  553. ? Math.floor(parseFloat("80px") / 20)
  554. : 1;
  555. return h("div", { class: "input" }, [
  556. h("div", { class: "input-container" }, [
  557. h("div", { class: "input", style: "padding:5px 0" }, [
  558. h("textarea", {
  559. ref: "inputRef",
  560. class: "input-control",
  561. name: this.name,
  562. value: this.inputValue,
  563. onInput: this.onInput,
  564. onFocus: this.onFocus,
  565. onBlur: this.onBlur,
  566. onChange: this.onChange,
  567. onKeydown: this.onKeydown, // 新增:禁止回车换行 by xu 20251212
  568. placeholder: this.placeholder,
  569. onMouseover: this.onMouseover, // 监听鼠标悬停
  570. onMouseleave: this.onMouseleave, // 监听鼠标离开
  571. rows: mainTextareaRows,
  572. ...this.$attrs,
  573. style: mainTextareaStyle,
  574. autocomplete: "off",
  575. }),
  576. // 附件按钮(优先使用 param,兼容旧的 fj)
  577. this.fj || this.hasAttachmentButton //加上&&this.param.button条件 Ben(20251221)
  578. ? h(
  579. "button",
  580. {
  581. type: "button",
  582. class: "fj-button",
  583. onClick: this.hasAttachmentButton
  584. ? this.onAttachmentClick
  585. : (e) => {
  586. e.preventDefault();
  587. console.log("附件配置:", this.fj);
  588. },
  589. },
  590. [
  591. h(SsEditorIcon, {
  592. class: "editor-icon-link",
  593. }),
  594. h("span", { class: "fj-button-text" }, this.attachmentButtonText || "附件"),
  595. ]
  596. )
  597. : null,
  598. ]),
  599. this.contentFloatingDiv || ""
  600. ? h(
  601. "div",
  602. {
  603. class: "floating-div",
  604. style:
  605. this.floatingDivPosition === "bottom"
  606. ? {
  607. // 向下展开: 覆盖原输入框,top对齐首行
  608. top: this.getFloatingDivTop,
  609. bottom: "auto",
  610. }
  611. : {
  612. // 向上展开: 同样覆盖原输入框,但从底部开始计算
  613. top: "auto",
  614. bottom: this.height ? "5px" : "6px", // 对齐到原textarea的底部padding位置
  615. },
  616. },
  617. [
  618. h("textarea", {
  619. ref: "textareaRef",
  620. class: "input-control",
  621. value: this.inputValue,
  622. onInput: this.onInput,
  623. onBlur: this.onBlur,
  624. onFocus: this.onFocus,
  625. onKeydown: this.onKeydown, // 新增:禁止回车换行 by xu 20251212
  626. onMouseover: this.onMouseover, // 监听鼠标悬停
  627. onMouseleave: this.onMouseleave, // 监听鼠标离开
  628. autocomplete: "off",
  629. onVnodeMounted: (vnode) => {
  630. vnode.el.focus();
  631. },
  632. }),
  633. ]
  634. )
  635. : null,
  636. // this.errMsg ? h(SsValidate, { errMsg: this.errMsg }) : null,
  637. ]),
  638. // 附件相关的隐藏字段(仅在有 param 时才渲染)
  639. this.param && [
  640. // fjid 隐藏字段(只有当 fjid 有值时才渲染)
  641. this.fjid &&
  642. h("input", {
  643. type: "hidden",
  644. name: this.attachmentFieldName || "fjid",
  645. value: this.fjid,
  646. }),
  647. // 其他隐藏字段根据 name 生成
  648. /* 去掉。文本框不需要(这是富文本才有的) Ben 20251205
  649. h("input", {
  650. type: "hidden",
  651. name: this.name.replace(/wj$/, "") + "Edit",
  652. value: this.inputValue
  653. }),
  654. */
  655. // h("input", {
  656. // type: "hidden",
  657. // name: this.name.replace(/wj$/, "") + "wj",
  658. // value: this.inputValue
  659. // }),
  660. /* 去掉。文本框不需要(这是富文本才有的) Ben 20251205
  661. h("input", {
  662. type: "hidden",
  663. name: "ueditorpath",
  664. value: this.name
  665. }),
  666. */
  667. ],
  668. ]);
  669. },
  670. };
  671. // ss-normal-input 登录输入
  672. const SsLoginInput = {
  673. name: "SsLoginInput",
  674. inheritAttrs: false,
  675. props: {
  676. errTip: {
  677. type: String,
  678. },
  679. type: {
  680. type: String,
  681. default: "text",
  682. },
  683. required: {
  684. type: Boolean,
  685. default: false,
  686. },
  687. placeholder: {
  688. type: String,
  689. default: "请输入",
  690. },
  691. name: {
  692. type: String,
  693. default: "",
  694. },
  695. defaultValue: [String, Number],
  696. modelValue: [String, Number],
  697. },
  698. emits: ["update:modelValue", "input", "blur", "change"], // 允许更新 v-model 绑定的值
  699. setup(props, { emit }) {
  700. const errMsg = ref("");
  701. const inputRef = ref(null);
  702. const textareaRef = ref(null);
  703. const inputValue = ref(props.modelValue || props.defaultValue || "");
  704. // 使用 watch 监听 props.errTip 和 props.modelValue 的变化
  705. watch(
  706. () => props.errTip,
  707. (newVal) => {
  708. errMsg.value = newVal;
  709. },
  710. { immediate: true }
  711. );
  712. watch(
  713. () => props.modelValue,
  714. (newVal) => {
  715. inputValue.value = newVal;
  716. }
  717. );
  718. // 挂载时的逻辑
  719. onMounted(() => {
  720. errMsg.value = props.errTip;
  721. inputValue.value = props.modelValue || props.defaultValue || "";
  722. });
  723. // 定义事件处理函数
  724. const onInput = (event) => {
  725. const newValue = event.target.value;
  726. inputValue.value = newValue;
  727. emit("update:modelValue", newValue);
  728. };
  729. return { inputValue, onInput, inputRef, textareaRef };
  730. },
  731. render() {
  732. return h("div", { class: "input" }, [
  733. h("div", { class: "input-container" }, [
  734. h("div", { class: "input" }, [
  735. h("input", {
  736. ref: "inputRef",
  737. class: "input-control",
  738. name: this.name,
  739. value: this.inputValue,
  740. onInput: this.onInput,
  741. type: this.type,
  742. placeholder: this.placeholder,
  743. required: this.required,
  744. ...this.$attrs,
  745. autocomplete: "off",
  746. }),
  747. ]),
  748. ]),
  749. ]);
  750. },
  751. };
  752. // ss-login-button
  753. const SsLoginButton = {
  754. name: "SsLoginButton",
  755. inheritAttrs: false,
  756. props: {
  757. class: {
  758. type: String,
  759. default: "",
  760. },
  761. text: {
  762. type: String,
  763. default: "",
  764. },
  765. type: {
  766. type: String,
  767. default: "button",
  768. },
  769. },
  770. emits: ["click"],
  771. setup(props, { emit }) {
  772. // 定义事件处理函数
  773. const onClick = (event) => {
  774. // 发射一个 'click' 事件,你可以传递所需的参数
  775. emit("click", event);
  776. };
  777. return { props, onClick };
  778. },
  779. render() {
  780. const SsIcon = resolveComponent("ss-icon");
  781. const SsLoginIcon = resolveComponent("ss-login-icon");
  782. return h(
  783. "button",
  784. { class: "login-button", type: this.type, onClick: this.onClick },
  785. [
  786. h("span", [h(SsLoginIcon, { class: this.class })]),
  787. h("span", {}, this.text),
  788. ]
  789. );
  790. },
  791. };
  792. // ss-objp 下拉选择
  793. const SsObjp = {
  794. name: "SsObjp",
  795. inheritAttrs: false,
  796. props: {
  797. onchange: {
  798. //在此属性传入onChange的window全局回调函数,函数唯一参数是当前选中值 Ben(20251217)
  799. type: String,
  800. required: false,
  801. },
  802. filter: {
  803. type: String,
  804. required: false,
  805. },
  806. filterfield: {
  807. type: String,
  808. required: false,
  809. },
  810. // filterField: {
  811. // //此属性为页面表单元素的name用逗号分隔,作用为在向后台查询下拉菜单选项时,会带上这些name的表单元素的value值 Ben(20260313)
  812. // type: String,
  813. // required: false,
  814. // },
  815. cb: {
  816. type: String,
  817. required: true,
  818. },
  819. url: {
  820. type: String,
  821. required: true,
  822. },
  823. name: {
  824. type: String,
  825. required: true,
  826. },
  827. width: {
  828. type: String,
  829. default: "100%",
  830. },
  831. placeholder: {
  832. type: String,
  833. default: "请选择",
  834. },
  835. inp: {
  836. type: Boolean,
  837. default: false,
  838. },
  839. opt: {
  840. type: Array,
  841. default: () => [],
  842. },
  843. errTip: String,
  844. defaultValue: [String, Number],
  845. modelValue: [String, Number],
  846. direction: {
  847. type: String,
  848. default: "bottom",
  849. },
  850. },
  851. emits: ["update:modelValue", "input", "blur", "change"],
  852. setup(props, { emit }) {
  853. const canInput = props.inp;
  854. const errMsg = Vue.ref(props.errTip);
  855. const selectItem = Vue.ref({});
  856. let inputText = Vue.ref(""); // 用于存储输入框的文本
  857. const popupWinVisible = Vue.ref(false);
  858. const filteredOptions = Vue.ref(props.opt);
  859. const popupDirection = Vue.ref("bottom");
  860. const popupMaxHeight = Vue.ref("none"); // popup最大高度,用于空间不足时限制高度并出滚动条 by xu 20251212
  861. const popupContentAreaMaxHeight = Vue.computed(() => {
  862. if (!popupMaxHeight.value || popupMaxHeight.value === "none")
  863. return null;
  864. const maxHeightNum = Number.parseFloat(popupMaxHeight.value);
  865. if (!Number.isFinite(maxHeightNum)) return null;
  866. // 功能说明:滚动条统一落在 .content-area(CSS 默认如此),因此需要扣掉 popup-win padding-top(10) 与 popup-content padding(15*2) by xu 20260126
  867. const contentAreaMaxHeight = Math.max(60, maxHeightNum - 40);
  868. return `${contentAreaMaxHeight}px`;
  869. });
  870. // 修复表格内下拉弹层被 overflow 截断:popup 使用 Teleport 到 body + fixed 定位 by xu 20260126
  871. const selectContainerRef = Vue.ref(null);
  872. const popupRef = Vue.ref(null);
  873. const teleportRootStyle = Vue.ref({
  874. position: "fixed",
  875. left: "0",
  876. top: "0",
  877. width: "0",
  878. height: "0",
  879. zIndex: 9999,
  880. pointerEvents: "none",
  881. });
  882. const popupLayerStyle = Vue.ref({
  883. position: "fixed",
  884. left: "0",
  885. top: "0",
  886. bottom: "auto", // 功能说明:覆盖 .popup-win.top 的 bottom 定位,避免 fixed 场景被撑高/错位 by xu 20260126
  887. minWidth: "0",
  888. zIndex: 9999,
  889. pointerEvents: "auto",
  890. });
  891. // const showRequired = Vue.computed(() => {
  892. // const hasValidationRule = window.ssVm?.validations?.has(props.name);
  893. // if (!hasValidationRule) return false;
  894. // if (errMsg.value) return true;
  895. // if (!selectItem.value?.value) return true;
  896. // return false;
  897. // });
  898. const validate = () => {
  899. if (window.ssVm) {
  900. const result = window.ssVm.validateField(props.name);
  901. // console.log("validate", window.ssVm.validateField(props.name));
  902. errMsg.value = result.valid ? "" : result.message;
  903. }
  904. };
  905. //在objPicker界面,选中value对应的项
  906. const updateSelectItem = () => {
  907. // console.log(props.opt);
  908. const item = props.opt.find((it) => it.value === props.modelValue);
  909. if (item) {
  910. selectItem.value = item;
  911. inputText.value = item.label;
  912. } else {
  913. selectItem.value = { label: "", value: "" };
  914. inputText.value = "";
  915. }
  916. // validate();
  917. };
  918. Vue.watch(
  919. () => props.errTip,
  920. (newVal) => {
  921. errMsg.value = newVal;
  922. }
  923. );
  924. // 功能说明:调用全局 onChange 回调,必须在 handleModelValueChange 之前定义 by xu 20260416
  925. const callGlobalOnchg = (value, desc) => {
  926. if (props.onchange && typeof props.onchange === "string") {
  927. if (
  928. typeof window !== "undefined" &&
  929. window[props.onchange] &&
  930. typeof window[props.onchange] === "function"
  931. ) {
  932. try {
  933. window[props.onchange](value, desc);
  934. } catch (error) {
  935. console.error(`调用全局函数 ${props.onchange} 时出错:`, error);
  936. }
  937. }
  938. }
  939. };
  940. // 功能说明:封装 modelValue 变化后的联动逻辑,兼容用户点击和桥接 API 赋值 by xu 20260416
  941. const handleModelValueChange = (newValue) => {
  942. updateSelectItem();
  943. if (newValue) {
  944. // 如果当前 options 里没有对应项,去服务端请求回显
  945. const exists = props.opt.some((it) => it.value === newValue);
  946. if (!exists && props.url && props.cb) {
  947. let url = props.url;
  948. if (props.filter) {
  949. const filterObj = props.filter;
  950. for (let k in filterObj) {
  951. url += "&" + k + "=" + filterObj[k];
  952. }
  953. }
  954. const params = new URLSearchParams();
  955. params.append("objectpickerparam", JSON.stringify({ input: props.inp, codebook: props.cb }));
  956. params.append("objectpickertype", "2");
  957. params.append("objectpickervalue", newValue);
  958. axios.post(url, params, {
  959. headers: { "Content-Type": "application/x-www-form-urlencoded" }
  960. }).then((response) => {
  961. if ("timeout" == response.data.statusText) {
  962. alert("网络超时!");
  963. return;
  964. }
  965. if (response.data.result) {
  966. const keys = Object.keys(response.data.result);
  967. if (keys.length === 1) {
  968. let code = keys[0];
  969. let desc = response.data.result[keys[0]];
  970. props.opt.length = 0;
  971. props.opt.push({ label: desc, value: code });
  972. updateSelectItem();
  973. callGlobalOnchg(code, desc);
  974. }
  975. }
  976. });
  977. } else if (selectItem.value && selectItem.value.value) {
  978. // options 里有对应项,触发 onChange
  979. callGlobalOnchg(selectItem.value.value, selectItem.value.label);
  980. }
  981. } else {
  982. // 值为空时清空选中
  983. callGlobalOnchg("", "");
  984. }
  985. };
  986. Vue.watch(() => props.modelValue, handleModelValueChange, { immediate: true });
  987. Vue.watch(
  988. () => props.opt,
  989. (newVal) => {
  990. updateSelectItem();
  991. filteredOptions.value = [...newVal];
  992. // console.log("filteredOptions", filteredOptions.value);
  993. }
  994. );
  995. //初始化objPicker在页面刚打开时的默认值
  996. async function initDefaultValue() {
  997. try {
  998. if (props.url && props.cb && props.modelValue) {
  999. let objectPickerParam;
  1000. let url = props.url;
  1001. //如果有定义过滤器
  1002. if (props.filter) {
  1003. //包含HTML实体的JSON字符串转为JSON对象,如原字符串是{&quot;dwid&quot;:&quot;88&quot;},注意key也必需用单引号包着
  1004. // const decodedString = props.filter.replace(/&quot;/g, '"'); // 转换为: {"dwid":"88"}
  1005. // objectPickerParam = JSON.parse(decodedString); // 转为json对象
  1006. const filterObj = props.filter; // 转为json对象
  1007. for (let k in filterObj) {
  1008. let v = filterObj[k];
  1009. url += "&" + k + "=" + v;
  1010. }
  1011. objectPickerParam = props.filter; // 转为json对象
  1012. objectPickerParam["input"] = props.inp;
  1013. objectPickerParam["codebook"] = props.cb;
  1014. // alert(url);
  1015. } else {
  1016. objectPickerParam = { input: props.inp, codebook: props.cb };
  1017. }
  1018. const objectPickerParamStr = JSON.stringify(objectPickerParam);
  1019. const params = new URLSearchParams();
  1020. params.append("objectpickerparam", objectPickerParamStr);
  1021. params.append("objectpickertype", "2");
  1022. params.append("objectpickervalue", props.modelValue); //需回显的值
  1023. // alert("1params:"+JSON.stringify(params));
  1024. axios
  1025. .post(props.url, params, {
  1026. headers: {
  1027. "Content-Type": "application/x-www-form-urlencoded", // 必须手动设置!
  1028. },
  1029. })
  1030. .then((response) => {
  1031. // alert(JSON.stringify(response.data));
  1032. if ("timeout" == response.data.statusText) {
  1033. alert("网络超时!");
  1034. return;
  1035. }
  1036. if (response.data.result) {
  1037. const keys = Object.keys(response.data.result);
  1038. if (keys.length === 1) {
  1039. let code = keys[0];
  1040. let desc = response.data.result[keys[0]];
  1041. if (props.opt)
  1042. props.opt.length = 0; //通过修改数组的length属性,直接清空数组元素,内存会被自动释放。这是性能最优的方式
  1043. else {
  1044. props.opt = [];
  1045. }
  1046. props.opt.push({ label: desc, value: code });
  1047. updateSelectItem();
  1048. // alert('props.opt:'+JSON.stringify(props.opt));
  1049. }
  1050. }
  1051. });
  1052. }
  1053. } catch (error) {
  1054. // callback(null, error.message); // 失败回调,传递错误
  1055. }
  1056. }
  1057. // Vue.onMounted(updateSelectItem);
  1058. const doSelectItem = (item) => {
  1059. emit("update:modelValue", item.value);
  1060. selectItem.value = item;
  1061. inputText.value = item.label;
  1062. hidePopup();
  1063. nextTick(() => {
  1064. console.log(item.value + "@@@props.modelValue:" + props.modelValue);
  1065. validate();
  1066. if (window.ssVm) {
  1067. // 遍历所有验证规则,找到依赖当前字段的规则
  1068. for (const [field, rules] of window.ssVm.validations.entries()) {
  1069. for (const rule of rules) {
  1070. if (rule.opt?.relField === props.name) {
  1071. // console.log("Found dependent field:", field); // 调试日志
  1072. window.ssVm.validateField(field);
  1073. }
  1074. }
  1075. }
  1076. }
  1077. });
  1078. // callGlobalOnchg 已移到 handleModelValueChange 统一处理,避免用户点击和桥接 API 赋值行为不一致 by xu 20260416
  1079. };
  1080. //可录入的objPicker,更新下拉菜单选项
  1081. async function updateOptionBYInputText(inpTxt) {
  1082. try {
  1083. let objectPickerParam;
  1084. let url = props.url;
  1085. if (props.url && props.cb) {
  1086. //如果有定义过滤器
  1087. if (props.filter || props.filterfield) {
  1088. let filterObj = props.filter;
  1089. if (!props.filter) filterObj = {};
  1090. if (props.filter) {
  1091. const filterObj = props.filter; // 转为json对象
  1092. for (let k in filterObj) {
  1093. let v = filterObj[k];
  1094. url += "&" + k + "=" + v;
  1095. }
  1096. }
  1097. if (props.filterfield) {
  1098. //加上filterfield的值过滤
  1099. let filterfieldArr = props.filterfield.split(",");
  1100. for (var i = 0; i < filterfieldArr.length; i++) {
  1101. let fieldName = filterfieldArr[i];
  1102. let fields = document.getElementsByName(fieldName);
  1103. if (!fields || fields.length < 1) {
  1104. alert("下拉菜单配置的过滤条件" + fieldName + "不存在!");
  1105. continue;
  1106. }
  1107. let v = null;
  1108. for (let j = 0; j < fields.length; j++) {
  1109. if (fields[j].value) {
  1110. v = fields[j].value;
  1111. break;
  1112. }
  1113. }
  1114. // let field = document.getElementsByName(fieldName)[0];
  1115. // let v = field.value;
  1116. if (v) {
  1117. url += "&" + fieldName + "=" + v;
  1118. filterObj[fieldName] = v;
  1119. }
  1120. }
  1121. console.log("filterfield url:" + url);
  1122. }
  1123. //包含HTML实体的JSON字符串转为JSON对象,如原字符串是{&quot;dwid&quot;:&quot;88&quot;},注意key也必需用单引号包着
  1124. // const decodedString = props.filter.replace(/&quot;/g, '"'); // 转换为: {"dwid":"88"}
  1125. // objectPickerParam = JSON.parse(decodedString); // 转为json对象
  1126. objectPickerParam = filterObj;
  1127. objectPickerParam["input"] = props.inp;
  1128. objectPickerParam["codebook"] = props.cb;
  1129. // alert(url);
  1130. } else {
  1131. objectPickerParam = { input: props.inp, codebook: props.cb };
  1132. }
  1133. const objectPickerParamStr = JSON.stringify(objectPickerParam);
  1134. const params = new URLSearchParams();
  1135. params.append("objectpickerparam", objectPickerParamStr);
  1136. params.append("objectpickertype", "1");
  1137. if (props.inp && props.inp === true) {
  1138. //把"true"改为true Ben(20251209)
  1139. params.append("objectpickersearchAll", 0); //只查录入的值
  1140. params.append("objectpickerinput", inpTxt); //录入的值
  1141. // 功能说明:将输入值也加到 URL 参数,避免后端只读 URL 不读 body by xu 20250408
  1142. if (inpTxt) {
  1143. url += "&objectpickerinput=" + encodeURIComponent(inpTxt);
  1144. }
  1145. } else {
  1146. params.append("objectpickersearchAll", 1);
  1147. }
  1148. axios
  1149. .post(url, params, {
  1150. headers: {
  1151. "Content-Type": "application/x-www-form-urlencoded", // 必须手动设置!
  1152. },
  1153. })
  1154. .then((response) => {
  1155. if ("timeout" == response.data.statusText) {
  1156. alert("网络超时!");
  1157. return;
  1158. }
  1159. // 先清空选项 by xu 20251212
  1160. if (props.opt) {
  1161. props.opt.length = 0;
  1162. } else {
  1163. props.opt = [];
  1164. }
  1165. if (response.data.result) {
  1166. const keys = Object.keys(response.data.result);
  1167. // console.log("params:"+params+"@@response.data:"+JSON.stringify(response.data));
  1168. if (keys.length > 0) {
  1169. for (let k in response.data.result) {
  1170. props.opt.push({
  1171. label: response.data.result[k],
  1172. value: k,
  1173. });
  1174. }
  1175. // console.log('###inpTxt:'+inpTxt+';');
  1176. if (
  1177. props.inp &&
  1178. props.inp === true && //把"true"改为true Ben(20251209)
  1179. inpTxt.length > 0
  1180. ) {
  1181. //对于可录入的,用已录入的值作过滤
  1182. filteredOptions.value = props.opt.filter((option) =>
  1183. option.label
  1184. .toLowerCase()
  1185. .includes(inputText.value.toLowerCase())
  1186. );
  1187. // 可录入的objPicker,当搜索结果只有一项时,自动选中这一项 by xu 20251212
  1188. if (filteredOptions.value.length === 1) {
  1189. const autoSelectItem = filteredOptions.value[0];
  1190. console.log(
  1191. "[objp] 搜索结果只有一项,自动选中:",
  1192. autoSelectItem
  1193. );
  1194. doSelectItem(autoSelectItem);
  1195. return; // 自动选中后直接返回,不需要显示popup
  1196. }
  1197. filteredOptions.value.unshift({ label: "", value: "" });
  1198. // console.log('###做了过滤:'+inputText.value.toLowerCase()+';');
  1199. } else {
  1200. filteredOptions.value = props.opt;
  1201. filteredOptions.value.unshift({ label: "", value: "" });
  1202. }
  1203. console.log("props.opt11:" + JSON.stringify(props.opt));
  1204. } else {
  1205. // 没有数据时,清空过滤选项 by xu 20251212
  1206. filteredOptions.value = [];
  1207. console.log("[objp] 接口返回空数据");
  1208. }
  1209. } else {
  1210. // result不存在时,清空过滤选项 by xu 20251212
  1211. filteredOptions.value = [];
  1212. console.log("[objp] 接口返回无result");
  1213. }
  1214. // 无论是否有数据,都显示popup by xu 20251212
  1215. openPopup(); // Teleport 场景下统一打开并重定位 by xu 20260126
  1216. });
  1217. }
  1218. } catch (error) {
  1219. // callback(null, error.message); // 失败回调,传递错误
  1220. }
  1221. }
  1222. // 计算弹出方向和最大高度的方法 by xu 20251212
  1223. // 当空间不足时限制popup高度并显示滚动条
  1224. const calculatePopupDirection = () => {
  1225. const triggerEl =
  1226. selectContainerRef.value?.querySelector(".input") ||
  1227. selectContainerRef.value;
  1228. if (!triggerEl) return;
  1229. const selectRect = triggerEl.getBoundingClientRect();
  1230. const viewportHeight = window.innerHeight;
  1231. // 3. 计算上下可用空间
  1232. const spaceBelow = viewportHeight - selectRect.bottom - 10; // 减10px留边距
  1233. const spaceAbove = selectRect.top - 10; // 减10px留边距
  1234. // 4. popup预估高度(假设每项36px,最多显示8项 + padding)
  1235. const estimatedPopupHeight = 300;
  1236. const minPopupHeight = 100; // 最小高度
  1237. console.log(
  1238. "[popup] 空间计算 - spaceAbove:",
  1239. spaceAbove,
  1240. "spaceBelow:",
  1241. spaceBelow,
  1242. "estimatedHeight:",
  1243. estimatedPopupHeight
  1244. );
  1245. // 5. 判断方向和最大高度 by xu 20251212
  1246. if (spaceBelow >= estimatedPopupHeight) {
  1247. // 下方空间足够,向下展开,不限制高度
  1248. popupDirection.value = "bottom";
  1249. popupMaxHeight.value = "none";
  1250. console.log("[popup] 向下展开,空间充足");
  1251. } else if (spaceAbove >= estimatedPopupHeight) {
  1252. // 上方空间足够,向上展开,不限制高度
  1253. popupDirection.value = "top";
  1254. popupMaxHeight.value = "none";
  1255. console.log("[popup] 向上展开,空间充足");
  1256. } else {
  1257. // 上下空间都不足,选择空间大的方向,并限制高度出滚动条
  1258. if (spaceBelow >= spaceAbove) {
  1259. popupDirection.value = "bottom";
  1260. popupMaxHeight.value = Math.max(spaceBelow, minPopupHeight) + "px";
  1261. console.log(
  1262. "[popup] 向下展开,空间不足,限制高度:",
  1263. popupMaxHeight.value
  1264. );
  1265. } else {
  1266. popupDirection.value = "top";
  1267. popupMaxHeight.value = Math.max(spaceAbove, minPopupHeight) + "px";
  1268. console.log(
  1269. "[popup] 向上展开,空间不足,限制高度:",
  1270. popupMaxHeight.value
  1271. );
  1272. }
  1273. }
  1274. };
  1275. // Teleport popup 的定位(fixed) by xu 20260126
  1276. const updatePopupPosition = () => {
  1277. const triggerEl =
  1278. selectContainerRef.value?.querySelector(".input") ||
  1279. selectContainerRef.value;
  1280. if (!triggerEl) return;
  1281. const triggerRect = triggerEl.getBoundingClientRect();
  1282. const margin = 10;
  1283. const viewportWidth = window.innerWidth;
  1284. const viewportHeight = window.innerHeight;
  1285. const popupGap = 0; // 功能说明:定位不再做 -10 重叠,让 padding-top 自然形成间距 by xu 20260126
  1286. // 先给一个初始位置,确保下一帧可以测量弹层尺寸 by xu 20260126
  1287. popupLayerStyle.value = {
  1288. position: "fixed",
  1289. left: `${Math.max(margin, triggerRect.left)}px`,
  1290. top: `${Math.max(margin, triggerRect.bottom + popupGap)}px`, // 功能说明:与输入框底部对齐 by xu 20260126
  1291. bottom: "auto", // 功能说明:fixed 场景显式取消 bottom,避免与 top 同时生效 by xu 20260126
  1292. minWidth: `${Math.max(0, triggerRect.width)}px`,
  1293. zIndex: 9999,
  1294. pointerEvents: "auto",
  1295. };
  1296. Vue.nextTick(() => {
  1297. const popupEl = popupRef.value;
  1298. if (!popupEl) return;
  1299. const popupRect = popupEl.getBoundingClientRect();
  1300. const maxLeft = viewportWidth - popupRect.width - margin;
  1301. const left = Math.min(
  1302. Math.max(margin, triggerRect.left),
  1303. Math.max(margin, maxLeft)
  1304. );
  1305. let top;
  1306. if (popupDirection.value === "top") {
  1307. top = triggerRect.top - popupRect.height - popupGap; // 功能说明:向上展开时与输入框顶部对齐 by xu 20260126
  1308. top = Math.max(margin, top);
  1309. } else {
  1310. top = triggerRect.bottom + popupGap; // 功能说明:向下展开时与输入框底部对齐 by xu 20260126
  1311. if (top + popupRect.height > viewportHeight - margin) {
  1312. top = Math.max(
  1313. margin,
  1314. viewportHeight - popupRect.height - margin
  1315. );
  1316. }
  1317. }
  1318. popupLayerStyle.value = {
  1319. ...popupLayerStyle.value,
  1320. left: `${left}px`,
  1321. top: `${top}px`,
  1322. bottom: "auto", // 功能说明:无论 top/bottom 展开都用 top 定位,禁用 bottom by xu 20260126
  1323. };
  1324. });
  1325. };
  1326. const openPopup = () => {
  1327. if (!popupWinVisible.value) popupWinVisible.value = true;
  1328. Vue.nextTick(() => {
  1329. calculatePopupDirection();
  1330. updatePopupPosition();
  1331. });
  1332. };
  1333. // Teleport 场景下:滚动/缩放重定位 by xu 20260126
  1334. const handleViewportChange = () => {
  1335. if (!popupWinVisible.value) return;
  1336. calculatePopupDirection();
  1337. updatePopupPosition();
  1338. };
  1339. // Teleport 场景下:点击外部关闭 by xu 20260126
  1340. const onDocPointerDown = (event) => {
  1341. if (!popupWinVisible.value) return;
  1342. const target = event.target;
  1343. if (selectContainerRef.value?.contains(target)) return;
  1344. if (popupRef.value?.contains(target)) return;
  1345. hidePopup();
  1346. };
  1347. //点击下拉菜单的文本区域时,会触发的方法
  1348. function togglePopup() {
  1349. // 可录入的 objPicker,更新下拉菜单选项
  1350. updateOptionBYInputText(inputText.value);
  1351. // popupWinVisible.value = !popupWinVisible.value;
  1352. Vue.nextTick(() => {
  1353. calculatePopupDirection();
  1354. updatePopupPosition(); // Teleport 场景下同步定位 by xu 20260126
  1355. });
  1356. }
  1357. const hidePopup = () => {
  1358. popupWinVisible.value = false;
  1359. };
  1360. //点击下拉菜单的三角形时,会触发的方法
  1361. // 添加toggle逻辑,点击时切换显示/隐藏 by xu 20251212
  1362. const suffixClick = () => {
  1363. // 如果popup已显示,则关闭 by xu 20251212
  1364. if (popupWinVisible.value) {
  1365. hidePopup();
  1366. console.log("[objp] 点三角关闭popup");
  1367. return;
  1368. }
  1369. //可录入的objPicker,更新下拉菜单选项
  1370. updateOptionBYInputText("");
  1371. Vue.nextTick(() => {
  1372. calculatePopupDirection();
  1373. updatePopupPosition(); // Teleport 场景下同步定位 by xu 20260126
  1374. });
  1375. console.log("[objp] 点三角打开popup");
  1376. };
  1377. //可录入的objPicker,录入项变化时,会触发
  1378. async function handleInputChange(event) {
  1379. inputText.value = event.target.value;
  1380. if (!inputText.value) {
  1381. inputText.value = "";
  1382. }
  1383. //可录入的objPicker,更新下拉菜单选项
  1384. updateOptionBYInputText(inputText.value);
  1385. // filteredOptions.value = props.opt.filter((option) =>
  1386. // option.label.toLowerCase().includes(inputText.value.toLowerCase())
  1387. // );
  1388. // if (!popupWinVisible.value) {
  1389. // popupWinVisible.value = true; // 确保下拉框在输入时打开
  1390. // }
  1391. }
  1392. Vue.onMounted(() => {
  1393. initDefaultValue();
  1394. // Teleport 场景下:滚动/缩放需要重定位(scroll 用 capture 捕获容器滚动) by xu 20260126
  1395. window.addEventListener("resize", handleViewportChange);
  1396. window.addEventListener("scroll", handleViewportChange, true);
  1397. // 点击外部关闭(原本依赖 mouseleave,Teleport 后会误关) by xu 20260126
  1398. document.addEventListener("pointerdown", onDocPointerDown, true);
  1399. });
  1400. Vue.onUnmounted(() => {
  1401. window.removeEventListener("resize", handleViewportChange);
  1402. window.removeEventListener("scroll", handleViewportChange, true);
  1403. document.removeEventListener("pointerdown", onDocPointerDown, true);
  1404. });
  1405. return {
  1406. errMsg,
  1407. selectItem,
  1408. inputText,
  1409. canInput,
  1410. filteredOptions,
  1411. popupWinVisible,
  1412. popupDirection,
  1413. popupMaxHeight, // 添加popup最大高度 by xu 20251212
  1414. popupContentAreaMaxHeight,
  1415. selectContainerRef,
  1416. popupRef,
  1417. teleportRootStyle,
  1418. popupLayerStyle,
  1419. suffixClick,
  1420. togglePopup,
  1421. hidePopup,
  1422. doSelectItem,
  1423. handleInputChange,
  1424. };
  1425. },
  1426. template: `
  1427. <div class="input" style="position: relative" :style="{width: width}">
  1428. <div class="select-container" ref="selectContainerRef">
  1429. <div class="input" @click="togglePopup">
  1430. <input
  1431. type="hidden"
  1432. :name="name"
  1433. :value="selectItem.value"
  1434. .value="selectItem.value"
  1435. />
  1436. <input
  1437. v-model="inputText"
  1438. @input="handleInputChange"
  1439. v-if="canInput"
  1440. :placeholder="placeholder"
  1441. />
  1442. <input
  1443. v-else
  1444. :placeholder="placeholder"
  1445. :value="selectItem.label"
  1446. disabled
  1447. style="pointer-events: none;"
  1448. />
  1449. <div class="suffix" @click.stop="suffixClick">
  1450. <ss-form-icon :class="popupWinVisible ? 'form-icon-transform-select select' : 'form-icon-select'" />
  1451. </div>
  1452. </div>
  1453. <!-- 修复表格内弹层被截断:popup Teleport 到 body by xu 20260126 -->
  1454. <teleport to="body">
  1455. <div v-show="popupWinVisible" class="select-container ss-objp-teleport-root" :style="teleportRootStyle">
  1456. <!-- popup弹出层,添加maxHeight和overflowY支持空间不足时滚动 by xu 20251212 -->
  1457. <div ref="popupRef" class="popup-win" :class="popupDirection" :style="[popupLayerStyle, { maxHeight: popupMaxHeight !== 'none' ? popupMaxHeight : 'none', overflowY: 'visible' }]">
  1458. <div v-if="opt && opt.length && filteredOptions.length > 0" class="popup-content">
  1459. <div class="content-area" :style="popupContentAreaMaxHeight ? { maxHeight: popupContentAreaMaxHeight, overflowY: 'auto' } : null">
  1460. <div v-for="(item, index) in filteredOptions" :key="index" @click="doSelectItem(item)" :class="{ active: item.value === selectItem.value }">
  1461. <span class="check-icon">
  1462. <ss-form-icon class="form-icon-select-checked" />
  1463. </span>
  1464. <span>{{ item.label }}</span>
  1465. </div>
  1466. </div>
  1467. </div>
  1468. <div v-else class="popup-content"><div class="content-area"><div class="content-area"> <span>无选项</span></div></div></div>
  1469. </div>
  1470. </div>
  1471. </teleport>
  1472. </div>
  1473. </div>
  1474. `,
  1475. };
  1476. // ss-hidden 隐藏字段组件
  1477. const SsHidden = {
  1478. name: "SsHidden",
  1479. props: {
  1480. modelValue: String,
  1481. name: {
  1482. type: String,
  1483. required: true,
  1484. },
  1485. rule: {
  1486. type: String,
  1487. required: false,//因为要单独发布非级联用的隐藏字段,改为非必需
  1488. },
  1489. param: {
  1490. type: String,
  1491. required: false,//因为要单独发布非级联用的隐藏字段,改为非必需
  1492. },
  1493. url: {
  1494. type: String,
  1495. required: false,//因为要单独发布非级联用的隐藏字段,改为非必需
  1496. },
  1497. },
  1498. emits: ["update:modelValue"],
  1499. setup(props, { emit }) {
  1500. const errMsg = Vue.ref("");
  1501. const validate = () => {
  1502. if (window.ssVm) {
  1503. const result = window.ssVm.validateField(props.name);
  1504. console.log("validate", window.ssVm.validateField(props.name));
  1505. errMsg.value = result.valid ? "" : result.message;
  1506. }
  1507. };
  1508. Vue.onMounted(() => {
  1509. /**
  1510. * 初始化级联菜单值初始值思路:
  1511. * 1. 带隐藏字段(即带编码规则)的级联菜单
  1512. * 在隐藏字段这,可以取到要回显的值和编码规则,从而计算出各级下拉菜单要回显的值。
  1513. * 然后通过ajax取各级级联菜单的值回显。
  1514. * 2. 不带隐藏字段的级联,只能在各个下拉菜单的setup事件中通过ajax取回显值回显
  1515. */
  1516. // 当同组级联下拉菜单选中值变化时,会调用本隐藏字段下面这方法设置隐藏字段值
  1517. window.addEventListener(
  1518. "cascader-setHiddenVal-" + props.name,
  1519. (event) => {
  1520. const { value } = event.detail;
  1521. emit("update:modelValue", value);
  1522. console.log(value);
  1523. setTimeout(() => {
  1524. validate();
  1525. }, 50);
  1526. }
  1527. );
  1528. // 如果有初始值,触发回显过程
  1529. if (props.modelValue&&props.param) {//增加props.param非空判断,非级联的hidden没props.param Ben(20260414)
  1530. console.log("级联隐藏字段,开始回显,初始值:", props.modelValue);
  1531. triggerCascaderEcho(props.modelValue);
  1532. validate();
  1533. }
  1534. });
  1535. // 触发级联回显
  1536. const triggerCascaderEcho = (code) => {
  1537. /**
  1538. * 开始回显,初始值: 440304
  1539. * 解析后的所有值: Array(3)0: "440000"1: "440300"2: "440304"length: 3[[Prototype]]: Array(0)
  1540. */
  1541. const values = parseHiddenCodeForAll(code, props.rule);
  1542. console.log("解析后的所有值:", values);
  1543. // 转换为 JSON 对象
  1544. // const paramObj = JSON.parse(props.param);
  1545. const paramObj = props.param;
  1546. let selectArr = paramObj.fieldOrd; //保存本组级联菜单项的数组,如:['hksheng','hkshi','hkxian']
  1547. if (selectArr.length != values.length) {
  1548. // alert('属性'+props.name+'的值'+code+'与级联菜单中下拉菜单的数目不匹配!');
  1549. return;
  1550. }
  1551. // 按顺序触发回显,并增加延迟确保数据加载
  1552. /**
  1553. * 通过隐藏字段的setup事件,
  1554. * 循环遍历各级下拉菜单,并触发定义在下拉菜单中的'cascader-echo'事件,
  1555. * 在此事件中完成每个下拉菜单回显值操作(只取当前要回显的键值对显示,
  1556. * 下拉菜单所有的值,在点击下拉菜单时,才通过ajax取)。
  1557. */
  1558. values.forEach((value, index) => {
  1559. if (value) {
  1560. setTimeout(() => {
  1561. let upperVal = undefined;
  1562. if (index != 0) {
  1563. upperVal = values[index - 1];
  1564. }
  1565. const echoEvent = new CustomEvent(
  1566. "cascader-echo-" + selectArr[index],
  1567. {
  1568. detail: {
  1569. name: props.name,
  1570. value: value,
  1571. // level: index + 1,
  1572. isAuto: true, // 标记为自动回显
  1573. upperVal: upperVal,
  1574. },
  1575. }
  1576. );
  1577. console.log(props.name + "--upperValue:" + upperVal);
  1578. window.dispatchEvent(echoEvent);
  1579. }, index * 500); // 每级增加500ms延迟
  1580. }
  1581. });
  1582. };
  1583. // 解析所有级别的代码
  1584. const parseHiddenCodeForAll = (code, rule) => {
  1585. if (!code || !rule) return [];
  1586. // 获取规则中每段的长度
  1587. const segments = [];
  1588. let currentChar = rule[0];
  1589. let currentLength = 1;
  1590. for (let i = 1; i < rule.length; i++) {
  1591. if (rule[i] === currentChar) {
  1592. currentLength++;
  1593. } else {
  1594. segments.push(currentLength);
  1595. currentChar = rule[i];
  1596. currentLength = 1;
  1597. }
  1598. }
  1599. segments.push(currentLength);
  1600. // 解析每一级的值
  1601. const values = [];
  1602. let position = 0;
  1603. segments.forEach((length, index) => {
  1604. const value = code
  1605. .substring(0, position + length)
  1606. .padEnd(rule.length, "0");
  1607. values.push(value);
  1608. position += length;
  1609. });
  1610. return values;
  1611. };
  1612. watchEffect(() => {});
  1613. return {};
  1614. },
  1615. template: `<input type="hidden" :name="name" :value="modelValue">`,
  1616. };
  1617. // ss-cascader 级联选择器
  1618. const SsCcp = {
  1619. name: "SsCcp",
  1620. inheritAttrs: false,
  1621. props: {
  1622. modelValue: String,
  1623. name: {
  1624. type: String,
  1625. required: true,
  1626. },
  1627. level: {
  1628. type: Number,
  1629. required: true,
  1630. },
  1631. opt: {
  1632. type: Array,
  1633. default: () => [],
  1634. },
  1635. placeholder: {
  1636. type: String,
  1637. default: "请选择",
  1638. },
  1639. width: {
  1640. type: String,
  1641. default: "150px",
  1642. },
  1643. direction: {
  1644. type: String,
  1645. default: "bottom",
  1646. },
  1647. mode: {
  1648. type: String,
  1649. default: "1",
  1650. },
  1651. //级联菜单配置参数,如果是数组,则代表本下拉菜单是多套级联菜单共用的第一级菜单。如果是对象,则只有一套级联菜单用此下拉菜单。
  1652. param: {
  1653. type: String,
  1654. required: true,
  1655. },
  1656. //向后台拿数据的url
  1657. url: {
  1658. type: String,
  1659. required: true,
  1660. },
  1661. },
  1662. emits: ["update:modelValue", "change"],
  1663. setup(props, { emit }) {
  1664. // alert('级联菜单初始化:'+props.name+':--:'+props.modelValue);
  1665. const selectItem = Vue.ref({ label: props.placeholder, value: "" });
  1666. const popupWinVisible = Vue.ref(false);
  1667. const isAutoEcho = Vue.ref(false); // 用于标记是否是自动回显
  1668. const upperValue = Vue.ref(""); //上级下拉菜单当前值,在初始化下拉菜单默认值时,和上级下拉菜单的值变化时,修改此upperValue变量
  1669. const popupDirection = Vue.ref("bottom");
  1670. const popupMaxHeight = Vue.ref("none"); // popup最大高度,用于空间不足时限制高度并出滚动条 by xu 20251212
  1671. //有隐藏字段的下拉菜单,加载菜单项并展开事件
  1672. // 被上级下拉菜单选中值后,触发本下拉菜单刷新菜单项并弹出显示
  1673. window.addEventListener("cascader-open-" + props.name, async (event) => {
  1674. const { upperVal } = event.detail;
  1675. upperValue.value = upperVal;
  1676. console.log(
  1677. "22props.name:" +
  1678. props.name +
  1679. ",22props.upperValue:" +
  1680. upperValue.value
  1681. );
  1682. selectItem.value = ""; //清除本下拉菜单当前选中的值
  1683. emit("update:modelValue", ""); //通知父级
  1684. //清空下拉菜单,并设置第一项的值为placeholder
  1685. clearAndInit1stOpt();
  1686. //下个下拉菜单名
  1687. let nextSelName = getNextSel(props.name, props.param.fieldOrd);
  1688. if (nextSelName) {
  1689. //清下个下拉菜单选中值和选项
  1690. event = new CustomEvent("cascader-cleanOpt-" + nextSelName, {
  1691. detail: {},
  1692. });
  1693. window.dispatchEvent(event);
  1694. }
  1695. showPopup();
  1696. });
  1697. //设置mode2的下级下拉菜单的上级菜单当前值
  1698. function setNextSelectUpperValue() {
  1699. //设置下级菜单的上级菜单当前值upperValue
  1700. let paramArr = undefined;
  1701. if (Array.isArray(props.param)) {
  1702. paramArr = props.param;
  1703. } else {
  1704. paramArr = [];
  1705. paramArr.push(props.param);
  1706. }
  1707. for (const oneParam of paramArr) {
  1708. //下个下拉菜单名
  1709. const nextSelName = getNextSel(props.name, oneParam.fieldOrd);
  1710. if (nextSelName) {
  1711. setTimeout(() => {
  1712. const openNextEvent = new CustomEvent(
  1713. "cascade-setUpperVal-" + nextSelName,
  1714. {
  1715. detail: {
  1716. upperVal: props.modelValue,
  1717. },
  1718. }
  1719. );
  1720. window.dispatchEvent(openNextEvent);
  1721. }, 100);
  1722. }
  1723. } // end for
  1724. }
  1725. // 把上级 级联下拉菜单的值,设置进本组件的事件
  1726. window.addEventListener("cascade-setUpperVal-" + props.name, (event) => {
  1727. // alert('props.name:'+props.name+',props.upperValue:'+event.detail.upperVal);
  1728. const { upperVal } = event.detail;
  1729. upperValue.value = upperVal;
  1730. // console.log('props.name:'+props.name+',props.upperValue:'+upperValue.value);
  1731. });
  1732. //清空下拉菜单,并设置第一项的值为空
  1733. function clearAndInit1stOpt() {
  1734. if (props.opt)
  1735. props.opt.length = 0; //通过修改数组的length属性,直接清空数组元素,内存会被自动释放。这是性能最优的方式
  1736. else {
  1737. props.opt = [];
  1738. }
  1739. props.opt.push({ label: "", value: "" });
  1740. }
  1741. // 兼容旧版 Map 结果和新版 List<Map> 结果,避免下拉项显示为 [object Object]
  1742. function normalizeCcpResult(result) {
  1743. const normalized = [];
  1744. if (!result) {
  1745. return normalized;
  1746. }
  1747. if (Array.isArray(result)) {
  1748. result.forEach((item) => {
  1749. if (!item || typeof item !== "object") {
  1750. return;
  1751. }
  1752. const entry = Object.entries(item)[0];
  1753. if (!entry) {
  1754. return;
  1755. }
  1756. normalized.push({
  1757. label: entry[1],
  1758. value: entry[0],
  1759. });
  1760. });
  1761. return normalized;
  1762. }
  1763. Object.keys(result).forEach((key) => {
  1764. normalized.push({
  1765. label: result[key],
  1766. value: key,
  1767. });
  1768. });
  1769. return normalized;
  1770. }
  1771. //获取下一级下拉菜单,如果下一级下拉菜单不存在,则返回undefined
  1772. function getNextSel(selName, selNameArr) {
  1773. // 检查参数有效性
  1774. if (!Array.isArray(selNameArr) || selNameArr.length === 0) {
  1775. return undefined;
  1776. }
  1777. // 查找当前元素的索引
  1778. const currentIndex = selNameArr.indexOf(selName);
  1779. // 如果元素不存在或已经是最后一个元素,返回undefined
  1780. if (currentIndex === -1 || currentIndex === selNameArr.length - 1) {
  1781. return undefined;
  1782. }
  1783. // 返回下一个元素
  1784. return selNameArr[currentIndex + 1];
  1785. }
  1786. const validate = () => {
  1787. if (window.ssVm) {
  1788. return window.ssVm.validateField(props.name);
  1789. }
  1790. return { valid: true };
  1791. };
  1792. // 处理选择事件
  1793. const doSelectItem = (item) => {
  1794. selectItem.value = item;
  1795. emit("update:modelValue", item.value); //修改本下拉菜单在vue中保存的值
  1796. // alert('item.value:'+item.value);
  1797. if (props.mode === "1") {
  1798. // mode 1 模式:修改隐藏字段值
  1799. let event = new CustomEvent(
  1800. "cascader-setHiddenVal-" + props.param.combField,
  1801. {
  1802. detail: {
  1803. value: item.value,
  1804. },
  1805. }
  1806. );
  1807. window.dispatchEvent(event);
  1808. }
  1809. emit("change", item.value); //触发配置的change方法
  1810. nextTick(() => {
  1811. validate();
  1812. if (window.ssVm) {
  1813. for (const [field, rules] of window.ssVm.validations.entries()) {
  1814. for (const rule of rules) {
  1815. if (rule.options?.relField) {
  1816. const relFields = String(rule.options.relField)
  1817. .split(",")
  1818. .map((name) => name.trim())
  1819. .filter(Boolean);
  1820. if (relFields.includes(props.name)) {
  1821. window.ssVm.validateField(field);
  1822. }
  1823. }
  1824. }
  1825. }
  1826. }
  1827. });
  1828. //设置下级菜单的上级菜单当前值upperValue
  1829. let paramArr = undefined;
  1830. if (Array.isArray(props.param)) {
  1831. paramArr = props.param;
  1832. } else {
  1833. paramArr = [];
  1834. paramArr.push(props.param);
  1835. }
  1836. for (const oneParam of paramArr) {
  1837. //下个下拉菜单名
  1838. const nextSelName = getNextSel(props.name, oneParam.fieldOrd);
  1839. if (nextSelName) {
  1840. setTimeout(() => {
  1841. const openNextEvent = new CustomEvent(
  1842. "cascader-open-" + nextSelName,
  1843. {
  1844. detail: {
  1845. upperVal: item.value,
  1846. },
  1847. }
  1848. );
  1849. window.dispatchEvent(openNextEvent);
  1850. }, 100);
  1851. }
  1852. } // end for
  1853. hidePopup();
  1854. //下个下拉菜单名
  1855. // let nextSelName = getNextSel(props.name, props.param.fieldOrd);
  1856. // if(nextSelName){
  1857. // // //设置下一级下拉菜单中保存的本下拉菜单值(upperValue)
  1858. // // event = new CustomEvent('cascade-setUpperVal-'+nextSelName, {
  1859. // // detail: {
  1860. // // value: item.value
  1861. // // }
  1862. // // });
  1863. // // window.dispatchEvent(event);
  1864. //
  1865. // //触发下一级下拉菜单,重新初始化下拉菜单项并弹出显示
  1866. // event = new CustomEvent('cascader-open-' +nextSelName, {
  1867. // detail: {
  1868. // upperVal: item.value
  1869. // }
  1870. // });
  1871. // window.dispatchEvent(event);
  1872. // }
  1873. // 只在手动选择时自动展开下一级
  1874. // if (!isAutoEcho.value) {
  1875. // const nextLevel = props.level + 1;
  1876. // setTimeout(() => {
  1877. // const openNextEvent = new CustomEvent('open-next-cascader', {
  1878. // detail: {
  1879. // name: props.name,
  1880. // level: nextLevel
  1881. // }
  1882. // });
  1883. // window.dispatchEvent(openNextEvent);
  1884. // }, 100);
  1885. // }
  1886. };
  1887. // 监听下一级展开事件 (仅 mode 2)
  1888. window.addEventListener("cascade-open", (event) => {
  1889. if (props.mode === "2") {
  1890. const { level } = event.detail;
  1891. if (level === props.level) {
  1892. popupWinVisible.value = true;
  1893. }
  1894. }
  1895. });
  1896. if (props.mode === "1") {
  1897. //如果是有隐藏字段的下拉菜单
  1898. // 监听回显事件
  1899. window.addEventListener(
  1900. "cascader-echo-" + props.name,
  1901. async (event) => {
  1902. const { name, value, isAuto, upperVal } = event.detail;
  1903. // level,
  1904. if (upperVal) {
  1905. upperValue.value = upperVal;
  1906. console.log(
  1907. "value:" +
  1908. value +
  1909. ",upperValue:" +
  1910. upperValue +
  1911. ",初始化级联组件时props.name:" +
  1912. props.name
  1913. );
  1914. }
  1915. // if (name === props.name && level === props.level) {
  1916. // 设置自动回显标记
  1917. isAutoEcho.value = true;
  1918. // if (props.opt.length === 0) {
  1919. // const loadDataEvent = new CustomEvent('cascader-load-data', {
  1920. // detail: {
  1921. // name: props.name,
  1922. // level: props.level,
  1923. // value: value
  1924. // }
  1925. // });
  1926. // window.dispatchEvent(loadDataEvent);
  1927. //下面的代码只用于页面刚打开时,初始化级联菜单的回显值。
  1928. //Vue.watch用于监听数据的变化,并在数据变化时执行特定的回调函数。
  1929. //这段代码使用了 Vue.js 的 watch API 来监听 props.opt 的变化,如果props.opt有变化,则自动
  1930. // const unwatch = Vue.watch(
  1931. // () => props.opt, // 监听的数据源(props.opt)
  1932. // (newOptions) => { // 回调函数
  1933. // if (newOptions.length > 0) { // 条件判断
  1934. // matchAndSelect(value); // 执行逻辑
  1935. // unwatch(); // 停止监听
  1936. // }
  1937. // },
  1938. // { immediate: true } // 配置:立即触发一次
  1939. // );
  1940. // } else {
  1941. // matchAndSelect(value);
  1942. // }
  1943. // 初始化级联菜单在页面刚打开时的默认值
  1944. async function initDefaultValue(value) {
  1945. try {
  1946. // alert(1);
  1947. if (
  1948. props.url &&
  1949. props.param
  1950. // && props.modelValue 对于有rule编码规则的级联菜单(即mode=1),modelValue一定是空的,所以注释掉,修复mode=1的级联菜单无法回显问题。Ben(20251124)
  1951. ) {
  1952. // alert(2);
  1953. /**
  1954. * let objectPickerParam=
  1955. * {"objectpickerparam":"{\"input\":\"false\",\"cascadingLevel\":\"hksheng,hkshi,hkxian\"," +
  1956. * "\"name\":\"hksheng\"," +
  1957. * "\"cascadingName\":\"dq\",\"cascadingInputsName\":\"hkdqm\"," +
  1958. * "\"codebook\":\"sheng\"}",
  1959. * "objectpickertype":2,
  1960. * "objectpickervalue":"440000"
  1961. * };
  1962. */
  1963. const objectPickerParam = {
  1964. input: "false",
  1965. cascadingLevel: props.param.fieldOrd.join(","), //如:"hksheng,hkshi,hkxian"
  1966. name: props.name, //本下拉菜单名
  1967. cascadingName: props.param.name, //级联菜单名
  1968. cascadingInputsName: props.param.combField, //对象属性,即隐藏字段名,如:hkdqm
  1969. codebook: props.param.codebook,
  1970. };
  1971. const objectPickerParamStr =
  1972. JSON.stringify(objectPickerParam);
  1973. const params = new URLSearchParams();
  1974. params.append("objectpickerparam", objectPickerParamStr);
  1975. params.append("objectpickertype", "2");
  1976. params.append("objectpickervalue", value); //需回显的值
  1977. axios
  1978. .post(props.url, params, {
  1979. headers: {
  1980. "Content-Type": "application/x-www-form-urlencoded", // 必须手动设置!
  1981. },
  1982. })
  1983. .then((response) => {
  1984. // alert(JSON.stringify(response.data));
  1985. if ("timeout" == response.data.statusText) {
  1986. alert("网络超时!");
  1987. return;
  1988. }
  1989. if (response.data.result) {
  1990. const normalizedResult = normalizeCcpResult(
  1991. response.data.result
  1992. );
  1993. if (normalizedResult.length === 1) {
  1994. const option = normalizedResult[0];
  1995. clearAndInit1stOpt();
  1996. props.opt.push(option);
  1997. if (value) matchAndSelect(value);
  1998. // updateSelectItem();
  1999. // alert('props.opt:'+JSON.stringify(props.opt));
  2000. }
  2001. }
  2002. });
  2003. }
  2004. } catch (error) {
  2005. alert(error);
  2006. // callback(null, error.message); // 失败回调,传递错误
  2007. }
  2008. }
  2009. //下面的代码只用于页面刚打开时,初始化级联菜单的回显值。
  2010. initDefaultValue(value);
  2011. // 延迟重置自动回显标记
  2012. setTimeout(() => {
  2013. isAutoEcho.value = false;
  2014. }, 500);
  2015. }
  2016. );
  2017. // 被上级下拉菜单触发的,清除选中值和下拉菜单选项
  2018. window.addEventListener(
  2019. "cascader-cleanOpt-" + props.name,
  2020. async (event) => {
  2021. upperValue.value = "";
  2022. selectItem.value = ""; //清除本下拉菜单当前选中的值
  2023. emit("update:modelValue", ""); //通知父级
  2024. //清空所有下拉菜单项
  2025. if (props.opt) {
  2026. props.opt.length = 0;
  2027. } else {
  2028. props.opt = [];
  2029. }
  2030. //下个下拉菜单名
  2031. let nextSelName = getNextSel(props.name, props.param.fieldOrd);
  2032. // alert('nextSelName:'+nextSelName+'--,props.name:'+props.name);
  2033. if (nextSelName) {
  2034. //清下个下拉菜单选中值和选项
  2035. event = new CustomEvent("cascader-cleanOpt-" + nextSelName, {
  2036. detail: {},
  2037. });
  2038. window.dispatchEvent(event);
  2039. }
  2040. }
  2041. );
  2042. } else if (props.mode === "2") {
  2043. //没隐藏字段的下拉菜单,在这初始化默认值
  2044. let needInitParam = undefined;
  2045. if (Array.isArray(props.param)) {
  2046. needInitParam = props.param[props.param.length - 1]; //只初始化数组最后一项
  2047. console.log("needInitParam最后一项:" + JSON.stringify(needInitParam));
  2048. } else {
  2049. needInitParam = props.param;
  2050. }
  2051. // 初始化级联菜单在页面刚打开时的默认值
  2052. async function initDefaultValue(value, param) {
  2053. try {
  2054. // alert(1);
  2055. if (props.url && param && props.modelValue) {
  2056. // alert(2);
  2057. /**
  2058. * let param=
  2059. * {"objectpickerparam":"{\"input\":\"false\",\"cascadingLevel\":\"rylbm,gwid\"," +
  2060. * "\"name\":\"gwid\",\"cascadingName\":\"rylb_gw\"," +
  2061. * "\"codebook\":\"gwByRylb\"}",
  2062. * "objectpickertype":2,
  2063. * "objectpickervalue":"102121"};
  2064. */
  2065. // alert('props.name:'+props.name+',props.param.fieldOrd:'+props.param.fieldOrd);
  2066. const objectPickerParam = {
  2067. input: "false",
  2068. cascadingLevel: param.fieldOrd.join(","), //如:"hksheng,hkshi,hkxian"
  2069. name: props.name, //本下拉菜单名
  2070. cascadingName: param.name, //级联菜单名
  2071. codebook: param.codebook,
  2072. };
  2073. const objectPickerParamStr = JSON.stringify(objectPickerParam);
  2074. const sendParams = new URLSearchParams();
  2075. sendParams.append("objectpickerparam", objectPickerParamStr);
  2076. sendParams.append("objectpickertype", "2");
  2077. sendParams.append("objectpickervalue", value); //需回显的值
  2078. axios
  2079. .post(props.url, sendParams, {
  2080. headers: {
  2081. "Content-Type": "application/x-www-form-urlencoded", // 必须手动设置!
  2082. },
  2083. })
  2084. .then((response) => {
  2085. // alert(JSON.stringify(response.data));
  2086. if ("timeout" == response.data.statusText) {
  2087. alert("网络超时!");
  2088. return;
  2089. }
  2090. if (response.data.result) {
  2091. const normalizedResult = normalizeCcpResult(
  2092. response.data.result
  2093. );
  2094. console.log(
  2095. "name:" +
  2096. props.name +
  2097. ",@@级联初始化默认值value:" +
  2098. value +
  2099. "--param:" +
  2100. JSON.stringify(param) +
  2101. "--objectPickerParamStr:" +
  2102. objectPickerParamStr +
  2103. "--response.data:" +
  2104. JSON.stringify(response.data)
  2105. );
  2106. if (normalizedResult.length === 1) {
  2107. const option = normalizedResult[0];
  2108. if (props.opt)
  2109. props.opt.length = 0; //通过修改数组的length属性,直接清空数组元素,内存会被自动释放。这是性能最优的方式
  2110. else {
  2111. props.opt = [];
  2112. }
  2113. props.opt.push(option);
  2114. if (value) matchAndSelect(value);
  2115. console.log(
  2116. "GOOD mode2回显的默认值:" +
  2117. JSON.stringify(option) +
  2118. "--props.param:" +
  2119. JSON.stringify(param)
  2120. );
  2121. // updateSelectItem();
  2122. // alert('props.opt:'+JSON.stringify(props.opt));
  2123. }
  2124. }
  2125. });
  2126. }
  2127. } catch (error) {
  2128. alert(error);
  2129. // callback(null, error.message); // 失败回调,传递错误
  2130. }
  2131. // 重置自动回显标记
  2132. isAutoEcho.value = false;
  2133. }
  2134. // 初始化级联菜单在页面刚打开时的默认值
  2135. initDefaultValue(props.modelValue, needInitParam);
  2136. //设置mode2的下级下拉菜单的上级菜单当前值
  2137. setNextSelectUpperValue();
  2138. }
  2139. //选中要回显的默认值
  2140. const matchAndSelect = (value) => {
  2141. const matchedOption = props.opt.find((opt) => opt.value === value);
  2142. if (matchedOption) {
  2143. selectItem.value = matchedOption;
  2144. emit("update:modelValue", value);
  2145. emit("change", value);
  2146. }
  2147. };
  2148. // 计算弹出方向和最大高度的方法 by xu 20251212
  2149. // 当空间不足时限制popup高度并显示滚动条
  2150. const calculatePopupDirection = () => {
  2151. // 1. 获取select容器元素
  2152. const selectEl = document.querySelector(
  2153. `[name="${props.name}"]`
  2154. )?.nextElementSibling;
  2155. console.log("selectEl:" + selectEl, props.name);
  2156. if (!selectEl) return;
  2157. // 2. 获取位置信息
  2158. const selectRect = selectEl.getBoundingClientRect();
  2159. const viewportHeight = window.innerHeight;
  2160. // 3. 计算上下可用空间 by xu 20251212
  2161. const spaceBelow = viewportHeight - selectRect.bottom - 10; // 减10px留边距
  2162. const spaceAbove = selectRect.top - 10; // 减10px留边距
  2163. // 4. popup预估高度(假设每项36px,最多显示8项 + padding)
  2164. const estimatedPopupHeight = 300;
  2165. const minPopupHeight = 100; // 最小高度
  2166. console.log(
  2167. "[popup] 空间计算 - spaceAbove:",
  2168. spaceAbove,
  2169. "spaceBelow:",
  2170. spaceBelow,
  2171. "estimatedHeight:",
  2172. estimatedPopupHeight
  2173. );
  2174. // 5. 判断方向和最大高度 by xu 20251212
  2175. if (spaceBelow >= estimatedPopupHeight) {
  2176. // 下方空间足够,向下展开,不限制高度
  2177. popupDirection.value = "bottom";
  2178. popupMaxHeight.value = "none";
  2179. console.log("[popup] 向下展开,空间充足");
  2180. } else if (spaceAbove >= estimatedPopupHeight) {
  2181. // 上方空间足够,向上展开,不限制高度
  2182. popupDirection.value = "top";
  2183. popupMaxHeight.value = "none";
  2184. console.log("[popup] 向上展开,空间充足");
  2185. } else {
  2186. // 上下空间都不足,选择空间大的方向,并限制高度出滚动条
  2187. if (spaceBelow >= spaceAbove) {
  2188. popupDirection.value = "bottom";
  2189. popupMaxHeight.value = Math.max(spaceBelow, minPopupHeight) + "px";
  2190. console.log(
  2191. "[popup] 向下展开,空间不足,限制高度:",
  2192. popupMaxHeight.value
  2193. );
  2194. } else {
  2195. popupDirection.value = "top";
  2196. popupMaxHeight.value = Math.max(spaceAbove, minPopupHeight) + "px";
  2197. console.log(
  2198. "[popup] 向上展开,空间不足,限制高度:",
  2199. popupMaxHeight.value
  2200. );
  2201. }
  2202. }
  2203. };
  2204. //级联菜单点击事件
  2205. const togglePopup = () => {
  2206. if (!popupWinVisible.value) {
  2207. //如果当前下拉菜单是隐藏的,先ajax重新加载下拉菜单项,再显示。
  2208. showPopup();
  2209. } else {
  2210. hidePopup();
  2211. }
  2212. };
  2213. //显示下拉菜单,在此之前先清除下拉菜单项
  2214. const showPopup = () => {
  2215. //清空下拉菜单,并设置第一项的值为空
  2216. clearAndInit1stOpt();
  2217. Vue.nextTick(() => {
  2218. calculatePopupDirection();
  2219. });
  2220. let url = props.url;
  2221. let filterObj = props.param.filter;
  2222. if (filterObj) {
  2223. for (let k in filterObj) {
  2224. let v = filterObj[k];
  2225. url += "&" + k + "=" + v;
  2226. }
  2227. }
  2228. if (props.mode === "1") {
  2229. //如果是有隐藏字段的下拉菜单
  2230. console.log("666url:" + url);
  2231. // alert('url:'+url);
  2232. // 获取级联菜单所有下拉菜单项
  2233. async function getSelectItems(value) {
  2234. try {
  2235. // alert(1);
  2236. if (props.url && props.param) {
  2237. // alert(2);
  2238. /**
  2239. * param={"objectpickerparam":"{\"input\":\"false\",\"cascadingLevel\":\"hksheng,hkshi,hkxian\"," +
  2240. * "\"name\":\"hksheng\",\"cascadingName\":\"dq\"," +
  2241. * "\"cascadingInputsName\":\"hkdqm\",\"codebook\":\"sheng\"}",
  2242. * "objectpickertype":1,//2表示获取要回显的一项,1表示获取所有下拉菜单项
  2243. * "upperValue":"440000"
  2244. * };
  2245. */
  2246. const objectPickerParam = {
  2247. input: "false",
  2248. cascadingLevel: props.param.fieldOrd.join(","), //如:"hksheng,hkshi,hkxian"
  2249. name: props.name, //本下拉菜单名
  2250. cascadingName: props.param.name, //级联菜单名
  2251. cascadingInputsName: props.param.combField, //对象属性,即隐藏字段名,如:hkdqm
  2252. codebook: props.param.codebook,
  2253. };
  2254. console.log("mode1 upperValue.value:" + upperValue.value);
  2255. const objectPickerParamStr = JSON.stringify(objectPickerParam);
  2256. const params = new URLSearchParams();
  2257. params.append("objectpickerparam", objectPickerParamStr);
  2258. params.append("objectpickertype", "1");
  2259. if (upperValue.value) {
  2260. params.append("upperValue", upperValue.value);
  2261. }
  2262. // params.append('objectpickervalue', value); //需回显的值
  2263. axios
  2264. .post(url, params, {
  2265. headers: {
  2266. "Content-Type": "application/x-www-form-urlencoded", // 必须手动设置!
  2267. },
  2268. })
  2269. .then((response) => {
  2270. if ("timeout" == response.data.statusText) {
  2271. alert("网络超时!");
  2272. return;
  2273. }
  2274. if (response.data.result) {
  2275. const normalizedResult = normalizeCcpResult(
  2276. response.data.result
  2277. );
  2278. console.log(
  2279. "params:" +
  2280. params +
  2281. "@@response.data:" +
  2282. JSON.stringify(response.data)
  2283. );
  2284. if (normalizedResult.length > 0) {
  2285. normalizedResult.forEach((option) => {
  2286. props.opt.push(option);
  2287. });
  2288. console.log("props.opt11:" + JSON.stringify(props.opt));
  2289. } else {
  2290. // 没有数据时打印日志 by xu 20251212
  2291. console.log("[ccp mode1] 接口返回空数据");
  2292. }
  2293. } else {
  2294. // result不存在时打印日志 by xu 20251212
  2295. console.log("[ccp mode1] 接口返回无result");
  2296. }
  2297. // 无论是否有数据,都显示popup by xu 20251212
  2298. if (!popupWinVisible.value) {
  2299. popupWinVisible.value = true;
  2300. }
  2301. });
  2302. }
  2303. } catch (error) {
  2304. alert(error);
  2305. // callback(null, error.message); // 失败回调,传递错误
  2306. }
  2307. }
  2308. getSelectItems(props.modelValue);
  2309. } else if (props.mode === "2") {
  2310. //没隐藏字段的下拉菜单
  2311. let needInitParam = undefined;
  2312. if (Array.isArray(props.param)) {
  2313. needInitParam = props.param[props.param.length - 1]; //只初始化数组最后一项
  2314. console.log(
  2315. "needInitParam最后一项:" + JSON.stringify(needInitParam)
  2316. );
  2317. } else {
  2318. needInitParam = props.param;
  2319. }
  2320. // 获取级联菜单所有下拉菜单项
  2321. async function getSelectItems(value, sendParam) {
  2322. try {
  2323. // alert(1);
  2324. if (props.url && sendParam) {
  2325. // alert(2);
  2326. /**
  2327. * param="{\"input\":\"false\",\"cascadingLevel\":\"dwid,sjryid\",
  2328. * \"ryid\":\"111121\",\"name\":\"sjryid\",
  2329. * \"cascadingName\":\"dw_sjry\",\"codebook\":\"sjryByDw\"}"
  2330. */
  2331. const objectPickerParam = {
  2332. input: "false",
  2333. cascadingLevel: sendParam.fieldOrd.join(","), //如:"hksheng,hkshi,hkxian"
  2334. name: props.name, //本下拉菜单名
  2335. cascadingName: sendParam.name, //级联菜单名
  2336. codebook: sendParam.codebook,
  2337. };
  2338. console.log("mode2 upperValue.value:" + upperValue.value);
  2339. const objectPickerParamStr = JSON.stringify(objectPickerParam);
  2340. const params = new URLSearchParams();
  2341. params.append("objectpickerparam", objectPickerParamStr);
  2342. params.append("objectpickertype", "1");
  2343. if (upperValue.value) {
  2344. params.append("upperValue", upperValue.value);
  2345. }
  2346. // params.append('objectpickervalue', value); //需回显的值
  2347. axios
  2348. .post(url, params, {
  2349. headers: {
  2350. "Content-Type": "application/x-www-form-urlencoded", // 必须手动设置!
  2351. },
  2352. })
  2353. .then((response) => {
  2354. if ("timeout" == response.data.statusText) {
  2355. alert("网络超时!");
  2356. return;
  2357. }
  2358. if (response.data.result) {
  2359. const normalizedResult = normalizeCcpResult(
  2360. response.data.result
  2361. );
  2362. console.log(
  2363. "params:" +
  2364. params +
  2365. "@@response.data:" +
  2366. JSON.stringify(response.data)
  2367. );
  2368. if (normalizedResult.length > 0) {
  2369. normalizedResult.forEach((option) => {
  2370. props.opt.push(option);
  2371. });
  2372. console.log("props.opt11:" + JSON.stringify(props.opt));
  2373. } else {
  2374. // 没有数据时打印日志 by xu 20251212
  2375. console.log("[ccp mode2] 接口返回空数据");
  2376. }
  2377. } else {
  2378. // result不存在时打印日志 by xu 20251212
  2379. console.log("[ccp mode2] 接口返回无result");
  2380. }
  2381. // 无论是否有数据,都显示popup by xu 20251212
  2382. if (!popupWinVisible.value) {
  2383. popupWinVisible.value = true;
  2384. }
  2385. });
  2386. }
  2387. } catch (error) {
  2388. alert(error);
  2389. // callback(null, error.message); // 失败回调,传递错误
  2390. }
  2391. }
  2392. getSelectItems(props.modelValue, needInitParam);
  2393. // popupWinVisible.value = !popupWinVisible.value;
  2394. }
  2395. };
  2396. const hidePopup = () => {
  2397. popupWinVisible.value = false;
  2398. };
  2399. // 合并所有的 onMounted 逻辑
  2400. Vue.onMounted(() => {
  2401. window.addEventListener("resize", calculatePopupDirection);
  2402. // 1. 监听展开下一级事件
  2403. window.addEventListener("open-next-cascader", (event) => {
  2404. const { name, level } = event.detail;
  2405. if (name === props.name && level === props.level) {
  2406. popupWinVisible.value = true;
  2407. }
  2408. });
  2409. // 2. 监听级联事件
  2410. window.addEventListener("cascader-change", (event) => {
  2411. const { name, level, value } = event.detail;
  2412. if (name === props.name && level < props.level) {
  2413. selectItem.value = { label: "", value: "" };
  2414. emit("update:modelValue", "");
  2415. if (ssHidden) {
  2416. ssHidden.updateValue(value);
  2417. }
  2418. }
  2419. });
  2420. });
  2421. Vue.onUnmounted(() => {
  2422. window.removeEventListener("resize", calculatePopupDirection);
  2423. });
  2424. // 监听值变化,处理回显 (mode 2)
  2425. Vue.watch(
  2426. () => props.modelValue,
  2427. (newVal) => {
  2428. if (props.mode === "2" && newVal) {
  2429. // 使用 watchEffect 替代嵌套的 watch
  2430. Vue.watchEffect(() => {
  2431. if (props.opt.length > 0) {
  2432. const matchedOption = props.opt.find(
  2433. (opt) => opt.value === newVal
  2434. );
  2435. if (matchedOption) {
  2436. selectItem.value = matchedOption;
  2437. }
  2438. }
  2439. });
  2440. } else {
  2441. // 原有的值变化处理
  2442. const item = props.opt.find((it) => it.value === newVal);
  2443. if (item) {
  2444. selectItem.value = item;
  2445. } else {
  2446. selectItem.value = { label: "", value: "" };
  2447. }
  2448. }
  2449. },
  2450. { immediate: true }
  2451. );
  2452. // 监听选项变化,当数据加载完成时进行匹配
  2453. Vue.watch(
  2454. () => props.opt,
  2455. (newOptions) => {
  2456. if (newOptions.length > 0) {
  2457. const matchedOption = newOptions.find(
  2458. (opt) => opt.value === selectItem.value.value
  2459. );
  2460. if (matchedOption) {
  2461. selectItem.value = matchedOption;
  2462. emit("update:modelValue", matchedOption.value);
  2463. emit("change", matchedOption.value);
  2464. }
  2465. }
  2466. }
  2467. );
  2468. return {
  2469. selectItem,
  2470. popupWinVisible,
  2471. popupDirection,
  2472. popupMaxHeight, // 添加popup最大高度 by xu 20251212
  2473. togglePopup,
  2474. hidePopup,
  2475. doSelectItem,
  2476. };
  2477. },
  2478. template: `
  2479. <div class="input ss-ccp-container" style="position: relative" :style="{width: width}">
  2480. <input type="hidden" :name="name" :value="modelValue">
  2481. <div class="select-container" @mouseleave="hidePopup">
  2482. <div class="input" @click="togglePopup">
  2483. <input
  2484. type="hidden"
  2485. :name="name"
  2486. :value="selectItem.value"
  2487. />
  2488. <input
  2489. :placeholder="placeholder"
  2490. :value="selectItem.label"
  2491. disabled
  2492. style="pointer-events: none;"
  2493. />
  2494. <div class="suffix">
  2495. <ss-form-icon :class="popupWinVisible ? 'form-icon-transform-select select' : 'form-icon-select'" />
  2496. </div>
  2497. </div>
  2498. <!-- popup弹出层,添加maxHeight和overflowY支持空间不足时滚动 by xu 20251212 -->
  2499. <div v-show="popupWinVisible" class="popup-win " :class="popupDirection" :style="{ maxHeight: popupMaxHeight, overflowY: popupMaxHeight !== 'none' ? 'auto' : 'visible' }">
  2500. <div v-if="opt && opt.length > 0" class="popup-content">
  2501. <div class="content-area">
  2502. <div
  2503. v-for="(item, index) in opt"
  2504. :key="index"
  2505. @click="doSelectItem(item)"
  2506. :class="{ active: item.value === selectItem.value }"
  2507. >
  2508. <span class="check-icon">
  2509. <ss-form-icon class="form-icon-select-checked" />
  2510. </span>
  2511. <span>{{ item.label }}</span>
  2512. </div>
  2513. </div>
  2514. </div>
  2515. <div v-else class="popup-content">
  2516. <div class="content-area">
  2517. <div class="content-area">
  2518. <span>无选项</span>
  2519. </div>
  2520. </div>
  2521. </div>
  2522. </div>
  2523. </div>
  2524. </div>
  2525. `,
  2526. };
  2527. // ss-date-picker 日期时间选择器组件
  2528. const SsDatePicker = {
  2529. name: "SsDatePicker",
  2530. props: {
  2531. modelValue: {
  2532. type: [String, Number, Date],
  2533. default: "",
  2534. },
  2535. name: {
  2536. type: String,
  2537. required: true,
  2538. },
  2539. type: {
  2540. type: String,
  2541. default: "date",
  2542. validator: (value) => ["date", "datetime", "time"].includes(value),
  2543. },
  2544. fmt: {
  2545. type: String,
  2546. default: null,
  2547. },
  2548. placeholder: {
  2549. type: String,
  2550. default: "",
  2551. },
  2552. width: {
  2553. type: String,
  2554. default: "100%",
  2555. },
  2556. },
  2557. emits: ["update:modelValue"],
  2558. setup(props, { emit }) {
  2559. const errMsg = ref("");
  2560. const validate = () => {
  2561. if (window.ssVm) {
  2562. const result = window.ssVm.validateField(props.name);
  2563. console.log("validate", window.ssVm.validateField(props.name));
  2564. errMsg.value = result.valid ? "" : result.message;
  2565. }
  2566. };
  2567. // 根据type确定默认格式
  2568. const defaultFormat = computed(() => {
  2569. switch (props.type) {
  2570. case "datetime":
  2571. return "YYYY-MM-DD HH:mm:ss";
  2572. case "date":
  2573. return "YYYY-MM-DD";
  2574. case "time":
  2575. return "HH:mm:ss";
  2576. }
  2577. });
  2578. const convertJavaFormatToElement = (javaFormat) => {
  2579. if (!javaFormat) return null;
  2580. return javaFormat
  2581. .replace("yyyy", "YYYY")
  2582. .replace("MM", "MM")
  2583. .replace("dd", "DD")
  2584. .replace("HH", "HH")
  2585. .replace("mm", "mm")
  2586. .replace("ss", "ss");
  2587. };
  2588. const finalFormat = computed(() => {
  2589. if (props.fmt) {
  2590. return convertJavaFormatToElement(props.fmt);
  2591. }
  2592. return defaultFormat.value;
  2593. });
  2594. // 使用 resolveComponent 获取组件
  2595. const ElDatePicker = resolveComponent("ElDatePicker");
  2596. const ElTimePicker = resolveComponent("ElTimePicker");
  2597. const SsFormIcon = resolveComponent("SsFormIcon");
  2598. const ElIcon = resolveComponent("ElIcon");
  2599. const handleValueUpdate = (val) => {
  2600. emit("update:modelValue", val);
  2601. emit("change", val); // 同时触发 change 事件
  2602. setTimeout(() => {
  2603. validate();
  2604. }, 50);
  2605. };
  2606. const dateType = computed(() => {
  2607. const fmt = props.fmt || "";
  2608. if (fmt.includes("HH:mm:ss")) {
  2609. return "datetime";
  2610. } else if (fmt.includes("HH:mm")) {
  2611. return "datetime";
  2612. } else if (fmt.includes("mm:ss")) {
  2613. return "time";
  2614. }
  2615. return "date";
  2616. });
  2617. let useTimePicker = true;
  2618. //"yyyy-MM-dd HH:mm:ss"; "日期字符串格式在java的写法",传到本组件fmt属性也是按这个格式
  2619. if (props.fmt) {
  2620. //有fmt属性,则以fmt属性优先判断类型
  2621. if (/[dMy]/.test(props.fmt)) {
  2622. //如果有传入日期格式,且含年月日
  2623. useTimePicker = false;
  2624. } else {
  2625. useTimePicker = true;
  2626. }
  2627. } else if (props.type !== "time") {
  2628. useTimePicker = false;
  2629. }
  2630. return () =>
  2631. h("div", { class: "ss-date-picker", style: { width: props.width } }, [
  2632. h("input", {
  2633. type: "hidden",
  2634. name: props.name,
  2635. value: props.modelValue,
  2636. }),
  2637. // 选择组件
  2638. h(useTimePicker ? ElTimePicker : ElDatePicker, {
  2639. modelValue: props.modelValue,
  2640. "onUpdate:modelValue": handleValueUpdate,
  2641. type: dateType.value,
  2642. format: finalFormat.value,
  2643. "value-format": finalFormat.value,
  2644. clearable: true,
  2645. placeholder: props.placeholder,
  2646. class: "custom-date-picker", // 用于自定义样式
  2647. "time-arrow-control": props.type === "datetime", // 修改这里
  2648. size: "large", // 添加这一行,改为 large 尺寸
  2649. style: { width: "100%" },
  2650. "prefix-icon": h(SsFormIcon, { class: "form-icon-time" }),
  2651. }),
  2652. ]);
  2653. },
  2654. };
  2655. // ss-icon 图标
  2656. // v3.0 增加 class 属性分支:有 class 走新逻辑,否则走 v1.0 逻辑 by xu 20251212
  2657. // v3.0 用法: <ss-icon class="icon-obj-ry menu-icon" />
  2658. // v1.0 用法: <ss-icon name="setting" size="20px" />
  2659. const SsIcon = {
  2660. name: "SsIcon",
  2661. // v3.0 禁用 class 透传,手动处理 by xu 20251215
  2662. inheritAttrs: false,
  2663. props: {
  2664. // v1.0: 以下为旧属性
  2665. name: { type: String },
  2666. size: { type: [Number, String], default: 16 },
  2667. unit: { type: String, default: "px" },
  2668. color: String,
  2669. type: {
  2670. type: String,
  2671. default: ssIcon.name,
  2672. validator: function (value) {
  2673. return [ssIcon, commonIcon].some((icon) => icon.name === value);
  2674. },
  2675. },
  2676. },
  2677. emits: ["update:modelValue", "input", "blur", "change"],
  2678. setup(props, { emit, attrs }) {
  2679. // v3.0 分支:有 class 属性时直接渲染(从 attrs 获取) by xu 20251215
  2680. if (attrs.class) {
  2681. return () =>
  2682. h("i", { ...attrs, class: attrs.class + " icon-container" });
  2683. }
  2684. // v1.0 分支:原有逻辑
  2685. const useIconType = computed(() => {
  2686. return [ssIcon, commonIcon].find(
  2687. (iconConfig) => iconConfig.name === props.type
  2688. );
  2689. });
  2690. const iconName = computed(() => {
  2691. const iconConfig = useIconType.value; // 注意:使用 .value 来访问响应式引用的值
  2692. if (!iconConfig) {
  2693. console.error(`Icon type "${props.type}" not found.`);
  2694. return "";
  2695. }
  2696. const iconType = iconConfig.types[props.name];
  2697. if (!iconType) {
  2698. console.error(
  2699. `Icon name "${props.name}" not found in type "${props.type}".`
  2700. );
  2701. return "";
  2702. }
  2703. return `${iconConfig.prefix}${iconType}`;
  2704. });
  2705. // 类似地,你可以计算 fontFamily 和 style
  2706. const fontFamily = computed(() => {
  2707. return useIconType.value ? useIconType.value.family : "";
  2708. });
  2709. // console.log(iconName.value,fontFamily.value)
  2710. const style = computed(() => {
  2711. const sizeStyle = isNum(props.size)
  2712. ? `${props.size}${props.unit}`
  2713. : props.size;
  2714. const styleObj = {
  2715. fontSize: sizeStyle,
  2716. color: props.color || "",
  2717. };
  2718. return toStyleStr(styleObj);
  2719. });
  2720. // 使用渲染函数定义模板逻辑
  2721. return () =>
  2722. h("i", {
  2723. class: ["icon-container", iconName.value, fontFamily.value],
  2724. style: style.value,
  2725. });
  2726. },
  2727. };
  2728. // 通用icon
  2729. const SsCommonIcon = {
  2730. name: "SsCommonIcon",
  2731. props: {
  2732. class: {
  2733. type: String,
  2734. required: true,
  2735. },
  2736. },
  2737. setup(props) {
  2738. return () =>
  2739. h("i", {
  2740. class: props.class + " common-icon",
  2741. });
  2742. },
  2743. };
  2744. // 登录页icon
  2745. const SsLoginIcon = {
  2746. name: "SsLoginIcon",
  2747. props: {
  2748. class: {
  2749. type: String,
  2750. required: true,
  2751. },
  2752. },
  2753. setup(props) {
  2754. return () =>
  2755. h("div", {
  2756. class: props.class + " login-icon",
  2757. });
  2758. },
  2759. };
  2760. // 弹窗icon
  2761. const SsDialogIcon = {
  2762. name: "SsDialogIcon",
  2763. props: {
  2764. class: {
  2765. type: String,
  2766. required: true,
  2767. },
  2768. },
  2769. setup(props) {
  2770. return () =>
  2771. h("i", {
  2772. class: props.class + " dialog-icon",
  2773. });
  2774. },
  2775. };
  2776. // 全局左侧导航图标组件
  2777. const SsNavIcon = {
  2778. name: "SsNavIcon",
  2779. props: {
  2780. class: {
  2781. type: String,
  2782. required: true,
  2783. },
  2784. },
  2785. setup(props) {
  2786. return () =>
  2787. h("div", {
  2788. class: props.class + " nav-icon",
  2789. });
  2790. },
  2791. };
  2792. // 顶部工具栏图标组件
  2793. const SsHeaderIcon = {
  2794. name: "SsHeaderIcon",
  2795. props: {
  2796. class: {
  2797. type: String,
  2798. required: true,
  2799. },
  2800. },
  2801. setup(props) {
  2802. return () =>
  2803. h("div", {
  2804. class: props.class + " header-icon",
  2805. });
  2806. },
  2807. };
  2808. // 全局菜单图标组件
  2809. const SsGolbalMenuIcon = {
  2810. name: "SsGolbalMenuIcon",
  2811. props: {
  2812. class: {
  2813. type: String,
  2814. required: true,
  2815. },
  2816. },
  2817. setup(props) {
  2818. return () =>
  2819. h("div", {
  2820. class: props.class + " global-menu-icon",
  2821. });
  2822. },
  2823. };
  2824. // 全局查询列表卡片图标
  2825. const SsCartListIcon = {
  2826. name: "SsCartListIcon",
  2827. props: {
  2828. class: {
  2829. type: String,
  2830. required: true,
  2831. },
  2832. },
  2833. setup(props) {
  2834. return () =>
  2835. h("div", {
  2836. class: props.class + " cart-list-icon",
  2837. });
  2838. },
  2839. };
  2840. // 全局底部工具栏图标组件
  2841. const SsQuickIcon = {
  2842. name: "SsQuickIcon",
  2843. props: {
  2844. class: {
  2845. type: String,
  2846. required: true,
  2847. },
  2848. },
  2849. setup(props) {
  2850. return () =>
  2851. h("div", {
  2852. class: props.class + " quick-icon",
  2853. });
  2854. },
  2855. };
  2856. // 表单组件icon
  2857. const SsFormIcon = {
  2858. name: "SsFormIcon",
  2859. props: {
  2860. class: {
  2861. type: String,
  2862. required: true,
  2863. },
  2864. },
  2865. setup(props) {
  2866. return () =>
  2867. h("div", {
  2868. class: props.class + " form-icon",
  2869. });
  2870. },
  2871. };
  2872. // 弹窗底部按钮icon
  2873. const SsBottomDivIcon = {
  2874. name: "SsBottomDivIcon",
  2875. props: {
  2876. class: {
  2877. type: String,
  2878. required: true,
  2879. },
  2880. },
  2881. setup(props) {
  2882. return () =>
  2883. h("div", {
  2884. class: props.class + " bottom-div-icon",
  2885. });
  2886. },
  2887. };
  2888. // editor组件icon
  2889. const SsEditorIcon = {
  2890. name: "SsEditorIcon",
  2891. props: {
  2892. class: {
  2893. type: String,
  2894. required: true,
  2895. },
  2896. },
  2897. setup(props) {
  2898. return () =>
  2899. h("i", {
  2900. class: props.class + " editor-icon",
  2901. });
  2902. },
  2903. };
  2904. // ss-validate校验器
  2905. const SsValidate = {
  2906. name: "SsValidate",
  2907. props: {
  2908. errMsg: { type: String },
  2909. textAlign: { type: String, default: "left" },
  2910. style: { type: Object, default: () => ({}) },
  2911. },
  2912. template: `<div class="validate-vline"></div>
  2913. <div class="validate-tip" :style="style">
  2914. <div class="tip" :style="{ textAlign: textAlign }">{{ errMsg }}</div>
  2915. <div class="tip-more" :style="{ textAlign: textAlign }">{{ errMsg }}</div>
  2916. </div>`,
  2917. };
  2918. // ss-onoff-array 多选按钮 数组形式
  2919. const SsonoffArray = {
  2920. name: "SsonoffArray",
  2921. props: {
  2922. name: {
  2923. type: String,
  2924. required: true,
  2925. },
  2926. opt: {
  2927. type: Array,
  2928. default: () => [],
  2929. },
  2930. defaultValue: [String, Number, Array],
  2931. modelValue: [String, Number, Array],
  2932. multiple: {
  2933. // 新增多选模式属性
  2934. type: Boolean,
  2935. default: false,
  2936. },
  2937. // 是否允许一项都不选,默认true允许 by xu 20251212
  2938. null: {
  2939. type: Boolean,
  2940. default: true,
  2941. },
  2942. },
  2943. emits: ["update:modelValue"], // 允许更新 v-model 绑定的值
  2944. setup(props, { emit }) {
  2945. console.log("多选按钮", props.opt);
  2946. // 使用数组来存储选中值
  2947. const checkedValue = ref(
  2948. props.multiple
  2949. ? Array.isArray(props.defaultValue)
  2950. ? props.defaultValue
  2951. : []
  2952. : props.defaultValue
  2953. );
  2954. const errMsg = ref(props.errTip);
  2955. // 生成icon名字
  2956. const genIconName = (itemValue) => {
  2957. if (props.multiple) {
  2958. return checkedValue.value.includes(itemValue)
  2959. ? "form-icon-onoff-checked"
  2960. : "form-icon-onoff-unchecked";
  2961. }
  2962. return checkedValue.value === itemValue
  2963. ? "form-icon-onoff-checked"
  2964. : "form-icon-onoff-unchecked";
  2965. };
  2966. // 选中项
  2967. const selectItem = (value) => {
  2968. if (props.multiple) {
  2969. // 多选模式
  2970. const index = checkedValue.value.indexOf(value);
  2971. if (index === -1) {
  2972. checkedValue.value = [...checkedValue.value, value];
  2973. } else {
  2974. // 取消选中当前项
  2975. const newValue = checkedValue.value.filter((v) => v !== value);
  2976. // 如果不允许为空且取消后为空,则阻止取消操作 by xu 20251212
  2977. if (!props.null && newValue.length === 0) {
  2978. return; // 阻止取消最后一项
  2979. }
  2980. checkedValue.value = newValue;
  2981. }
  2982. } else {
  2983. // 单选模式
  2984. // 如果点击的是当前已选中的项,判断是否允许取消 by xu 20251212
  2985. if (checkedValue.value === value) {
  2986. if (!props.null) {
  2987. return; // 不允许为空时,阻止取消
  2988. }
  2989. checkedValue.value = ""; // 允许为空时,取消选中
  2990. } else {
  2991. checkedValue.value = value;
  2992. }
  2993. }
  2994. emit("update:modelValue", checkedValue.value);
  2995. nextTick(() => {
  2996. // 触发验证
  2997. if (window.ssVm) {
  2998. window.ssVm.validateField(props.name);
  2999. }
  3000. });
  3001. };
  3002. return { checkedValue, genIconName, selectItem };
  3003. },
  3004. // 使用渲染函数定义模板逻辑
  3005. render() {
  3006. const SsFormIcon = resolveComponent("ss-form-icon");
  3007. return h("div", { class: "radio-container" }, [
  3008. // 根据情况创建 input
  3009. this.multiple
  3010. ? this.checkedValue.length
  3011. ? // 多选且有选中值:为选中项创建 input
  3012. this.checkedValue.map((value) =>
  3013. h("input", {
  3014. type: "checkbox",
  3015. name: this.name,
  3016. value: value,
  3017. checked: true,
  3018. style: { display: "none" },
  3019. })
  3020. )
  3021. : // 多选但没有选中值:创建一个空值 input
  3022. h("input", {
  3023. type: "hidden",
  3024. name: this.name,
  3025. value: "",
  3026. })
  3027. : // 单选模式:创建一个 input
  3028. h("input", {
  3029. type: "hidden",
  3030. name: this.name,
  3031. value: this.checkedValue || "",
  3032. }),
  3033. this.opt.map((item, i) =>
  3034. h(
  3035. "div",
  3036. {
  3037. key: i,
  3038. class: {
  3039. checked: this.multiple
  3040. ? this.checkedValue.includes(item.value)
  3041. : this.checkedValue === item.value,
  3042. },
  3043. style: { width: item.width },
  3044. onClick: () => this.selectItem(item.value),
  3045. },
  3046. [
  3047. h("span", null, item.label),
  3048. h("div", { class: "mark" }, [
  3049. h(SsFormIcon, {
  3050. class: this.genIconName(item.value),
  3051. }),
  3052. ]),
  3053. ]
  3054. )
  3055. ),
  3056. ]);
  3057. },
  3058. };
  3059. // ss-onoff 一个按钮
  3060. const Ssonoff = {
  3061. name: "Ssonoff",
  3062. props: {
  3063. name: {
  3064. type: String,
  3065. required: true,
  3066. },
  3067. label: {
  3068. type: String,
  3069. required: true,
  3070. },
  3071. value: {
  3072. type: [String, Number],
  3073. required: true,
  3074. },
  3075. width: {
  3076. type: String,
  3077. default: "",
  3078. },
  3079. onchange: {
  3080. // 在此属性传入 onChange 的 window 全局回调函数,第一参数是当前整组值 by Ben/xu(20260320)
  3081. type: String,
  3082. required: false,
  3083. },
  3084. modelValue: [String, Number, Array],
  3085. multiple: {
  3086. type: Boolean,
  3087. default: false,
  3088. },
  3089. null: {
  3090. type: Boolean,
  3091. default: true,
  3092. },
  3093. },
  3094. emits: ["update:modelValue", "change"],
  3095. setup(props, { emit }) {
  3096. const parseModelValue = (val) => {
  3097. if (Array.isArray(val)) {
  3098. return val
  3099. .map((item) => (item == null ? "" : item.toString()))
  3100. .filter(Boolean);
  3101. }
  3102. if (val == null || val === "") return [];
  3103. // 如果以逗号开头,去掉开头的逗号
  3104. const cleanValue = val.toString().replace(/^,+/, "");
  3105. if (!cleanValue) return [];
  3106. if (cleanValue.includes("|")) {
  3107. return cleanValue.split("|").filter(Boolean);
  3108. }
  3109. if (cleanValue.includes(",")) {
  3110. return cleanValue.split(",").filter(Boolean);
  3111. }
  3112. return [cleanValue];
  3113. };
  3114. const callGlobalOnchg = (groupValue) => {
  3115. if (props.onchange && typeof props.onchange === "string") {
  3116. if (
  3117. typeof window !== "undefined" &&
  3118. window[props.onchange] &&
  3119. typeof window[props.onchange] === "function"
  3120. ) {
  3121. try {
  3122. window[props.onchange](groupValue, props.value, props.label);
  3123. } catch (error) {
  3124. console.error(`调用全局函数 ${props.onchange} 时出错:`, error);
  3125. }
  3126. } else {
  3127. console.warn(`全局函数 ${props.onchange} 未定义或不是一个函数。`);
  3128. }
  3129. }
  3130. };
  3131. // 判断当前按钮是否选中
  3132. const isChecked = computed(() => {
  3133. if (props.multiple) {
  3134. const currentValue = parseModelValue(props.modelValue);
  3135. return currentValue.includes(props.value.toString());
  3136. }
  3137. return props.modelValue + "" === props.value + ""; //强转为字符串类型再比较(改之前是数字类型和字符串类型作比较,永远为false) Ben 20251206
  3138. });
  3139. // 功能说明:watch modelValue 变化,兼容桥接 API 赋值触发 onChange by xu 20260416
  3140. let isToggleTriggering = false; // 避免 toggleSelect 内部 emit 重复触发
  3141. Vue.watch(
  3142. () => props.modelValue,
  3143. (newVal) => {
  3144. if (isToggleTriggering) return;
  3145. callGlobalOnchg(newVal);
  3146. }
  3147. );
  3148. // 切换选中状态
  3149. const toggleSelect = () => {
  3150. let newModelValue;
  3151. if (props.multiple) {
  3152. const currentValue = parseModelValue(props.modelValue);
  3153. const currentButtonValue = props.value.toString();
  3154. const index = currentValue.indexOf(currentButtonValue);
  3155. let newValue;
  3156. if (index === -1) {
  3157. // 选中当前项
  3158. newValue = [...currentValue, currentButtonValue];
  3159. } else {
  3160. // 取消选中当前项
  3161. const filteredValue = currentValue.filter(
  3162. (value) => value !== currentButtonValue
  3163. );
  3164. // 如果不允许为空且取消后为空,则阻止取消操作
  3165. if (!props.null && filteredValue.length === 0) {
  3166. return; // 阻止取消最后一项
  3167. }
  3168. newValue = filteredValue;
  3169. }
  3170. newModelValue = newValue.join(",");
  3171. } else {
  3172. // 单选模式
  3173. const currentValue = parseModelValue(props.modelValue);
  3174. const isCurrentlySelected = currentValue.includes(
  3175. props.value.toString()
  3176. );
  3177. if (!isCurrentlySelected) {
  3178. // 选中当前项
  3179. newModelValue = props.value;
  3180. } else {
  3181. // 取消选中当前项
  3182. // 如果不允许为空且当前只有这一项被选中,则阻止取消操作
  3183. if (!props.null && currentValue.length === 1) {
  3184. return; // 阻止取消唯一选中项
  3185. }
  3186. newModelValue = "";
  3187. }
  3188. }
  3189. isToggleTriggering = true; // emit 前设置,避免 watch 重复触发 onChange by xu 20260416
  3190. emit("update:modelValue", newModelValue);
  3191. emit("change", newModelValue, props.value, props.label);
  3192. nextTick(() => {
  3193. isToggleTriggering = false; // 重置标志,允许后续桥接 API 赋值触发 onChange by xu 20260416
  3194. // 触发验证
  3195. if (window.ssVm) {
  3196. window.ssVm.validateField(props.name);
  3197. }
  3198. });
  3199. };
  3200. return { isChecked, toggleSelect };
  3201. },
  3202. render() {
  3203. const SsFormIcon = resolveComponent("ss-form-icon");
  3204. return h("div", { class: "radio-container2" }, [
  3205. // 隐藏的表单元素
  3206. this.multiple
  3207. ? h("input", {
  3208. type: "hidden",
  3209. name: `${this.name}`, // 多选模式下使用数组形式的 name
  3210. value: this.isChecked ? this.value : "",
  3211. })
  3212. : this.isChecked &&
  3213. h("input", {
  3214. // 只有当前按钮被选中时才创建 input
  3215. type: "hidden",
  3216. name: this.name,
  3217. value: this.value,
  3218. }),
  3219. // 按钮显示
  3220. h(
  3221. "div",
  3222. {
  3223. class: { checked: this.isChecked },
  3224. style: { width: this.width },
  3225. onClick: this.toggleSelect,
  3226. },
  3227. [
  3228. h("span", null, this.label),
  3229. h("div", { class: "mark" }, [
  3230. h(SsFormIcon, {
  3231. class: this.isChecked
  3232. ? "form-icon-onoff-checked"
  3233. : "form-icon-onoff-unchecked",
  3234. }),
  3235. ]),
  3236. ]
  3237. ),
  3238. ]);
  3239. },
  3240. };
  3241. // ss-textarea
  3242. // ss-textarea
  3243. const SsTextarea = {
  3244. name: "SsTextarea",
  3245. props: {
  3246. name: {
  3247. type: String,
  3248. required: true,
  3249. },
  3250. placeholder: {
  3251. type: String,
  3252. default: "请输入",
  3253. },
  3254. defaultValue: [String, Number],
  3255. modelValue: [String, Number],
  3256. // 功能说明:onChange 全局回调 prop,桥接 API 赋值时自动触发 by xu 20260416
  3257. onchange: {
  3258. type: String,
  3259. required: false,
  3260. },
  3261. },
  3262. emits: ["update:modelValue"],
  3263. setup(props, { emit }) {
  3264. const inputValue = ref(props.modelValue || props.defaultValue || "");
  3265. // 功能说明:调用全局 onChange 回调 by xu 20260416
  3266. const callGlobalOnchg = (value) => {
  3267. if (props.onchange && typeof props.onchange === "string") {
  3268. if (
  3269. typeof window !== "undefined" &&
  3270. window[props.onchange] &&
  3271. typeof window[props.onchange] === "function"
  3272. ) {
  3273. try {
  3274. window[props.onchange](value);
  3275. } catch (error) {
  3276. console.error(`调用全局函数 ${props.onchange} 时出错:`, error);
  3277. }
  3278. }
  3279. }
  3280. };
  3281. // 监听 modelValue 变化
  3282. watch(
  3283. () => props.modelValue,
  3284. (newVal) => {
  3285. inputValue.value = newVal;
  3286. callGlobalOnchg(newVal);
  3287. }
  3288. );
  3289. // 输入事件处理
  3290. const onInput = (event) => {
  3291. const newValue = event.target.value;
  3292. inputValue.value = newValue;
  3293. emit("update:modelValue", newValue);
  3294. // 触发验证
  3295. if (window.ssVm) {
  3296. window.ssVm.validateField(props.name);
  3297. }
  3298. };
  3299. // 失焦时验证
  3300. const onBlur = () => {
  3301. if (window.ssVm) {
  3302. window.ssVm.validateField(props.name);
  3303. }
  3304. };
  3305. return { inputValue, onInput, onBlur };
  3306. },
  3307. render() {
  3308. return h("div", { class: "textarea-container" }, [
  3309. h("div", { class: "textarea" }, [
  3310. h("input", {
  3311. type: "hidden",
  3312. name: this.name,
  3313. value: this.inputValue || "",
  3314. }),
  3315. h("textarea", {
  3316. placeholder: this.placeholder,
  3317. value: this.inputValue,
  3318. onInput: this.onInput,
  3319. onBlur: this.onBlur,
  3320. }),
  3321. ]),
  3322. ]);
  3323. },
  3324. };
  3325. // ss-editor 富文本编辑器 基于Jodit
  3326. const SsEditor = {
  3327. name: "SsEditor",
  3328. props: {
  3329. modelValue: {
  3330. type: String,
  3331. default: "",
  3332. },
  3333. html: {
  3334. type: String,
  3335. default: "",
  3336. },
  3337. htmlname: {
  3338. type: String,
  3339. default: "",
  3340. },
  3341. storename: {
  3342. type: String,
  3343. default: "",
  3344. },
  3345. name: {
  3346. type: String,
  3347. default: "",
  3348. },
  3349. url: {
  3350. type: String,
  3351. default: "",
  3352. },
  3353. height: {
  3354. type: [Number, String],
  3355. default: 400,
  3356. },
  3357. placeholder: {
  3358. type: String,
  3359. default: "请输入内容",
  3360. },
  3361. mode: {
  3362. type: String,
  3363. default: "edit", // 'edit' | 'play'
  3364. },
  3365. uploadUrl: {
  3366. type: String,
  3367. default: "/ulByHttp", //原值为“upload” Ben(20251205)
  3368. },
  3369. param: {
  3370. type: Object,
  3371. default: () => ({}),
  3372. },
  3373. },
  3374. emits: ["update:modelValue", "ready", "change"],
  3375. setup(props, { emit }) {
  3376. const editorRef = ref(null);
  3377. const editorContent = ref("");
  3378. const currentModelValue = ref(props.modelValue || "");
  3379. const uniqueId = "editor-" + Date.now();
  3380. const errMsg = Vue.ref("");
  3381. // button 支持对象(旧格式,单个附件按钮)或数组(新格式,多个按钮)by xu 20250331
  3382. const buttonConfigRaw = props.param && props.param.button ? props.param.button : null;
  3383. const buttonArray = Array.isArray(buttonConfigRaw)
  3384. ? buttonConfigRaw
  3385. : buttonConfigRaw
  3386. ? [buttonConfigRaw]
  3387. : [];
  3388. // 找到附件按钮配置(有 cmsAddUrl 的)
  3389. const fjButton = buttonArray.find(btn => btn && btn.cmsAddUrl && btn.cmsUpdUrl) || {};
  3390. const fjid = ref(fjButton.val || null);
  3391. const attachmentFieldName = fjButton.name || "fjid";
  3392. const attachmentLabel = fjButton.desc || fjButton.text || "附件";
  3393. const resolveStoreFieldName = () => {
  3394. if (props.storename) {
  3395. return props.storename;
  3396. }
  3397. if (!props.name) {
  3398. return "";
  3399. }
  3400. return /wj$/i.test(props.name) ? props.name : props.name + "wj";
  3401. };
  3402. const resolveHtmlFieldName = () => {
  3403. if (props.htmlname) {
  3404. return props.htmlname;
  3405. }
  3406. const storeFieldName = resolveStoreFieldName();
  3407. if (storeFieldName && /wj$/i.test(storeFieldName)) {
  3408. return storeFieldName.replace(/wj$/i, "") + "Edit";
  3409. }
  3410. if (!props.name) {
  3411. return "";
  3412. }
  3413. return props.name.replace(/wj$/i, "") + "Edit";
  3414. };
  3415. const resolvePageSearchParam = (key) => {
  3416. try {
  3417. return new URL(window.location.href).searchParams.get(key) || "";
  3418. } catch (error) {
  3419. return "";
  3420. }
  3421. };
  3422. const resolveAttachmentObjName = () =>
  3423. props.param?.obj ||
  3424. props.param?.ssObjName ||
  3425. document.querySelector("[name='ssObjName']")?.value ||
  3426. window?.ss?.dom?.ssObjName ||
  3427. resolvePageSearchParam("ssObjName") ||
  3428. "";
  3429. const resolveAttachmentObjId = () =>
  3430. props.param?.ssObjId ||
  3431. props.param?.objId ||
  3432. document.querySelector("[name='ssObjId']")?.value ||
  3433. resolvePageSearchParam("ssObjId") ||
  3434. "";
  3435. const buildAttachmentCreatePayload = () => ({
  3436. name: attachmentFieldName,
  3437. ssNrObjName: resolveAttachmentObjName(),
  3438. ssNrObjId: resolveAttachmentObjId(),
  3439. });
  3440. const buildAttachmentDialogQuery = () =>
  3441. "&nrid=T-" +
  3442. fjid.value +
  3443. "&objectId=" +
  3444. fjid.value +
  3445. "&objectName=" +
  3446. attachmentFieldName +
  3447. "&callback=" +
  3448. (window[attachmentFieldName + "CallbackName"] || "");
  3449. const ensureAttachmentId = () => {
  3450. if (fjid.value != null && fjid.value !== "") {
  3451. return true;
  3452. }
  3453. if (!fjButton.cmsAddUrl) {
  3454. console.warn("ss-editor 未配置附件创建地址,无法初始化附件记录");
  3455. return false;
  3456. }
  3457. $.ajax({
  3458. type: "post",
  3459. url: fjButton.cmsAddUrl,
  3460. async: false,
  3461. data: buildAttachmentCreatePayload(),
  3462. success: function (_fjid) {
  3463. console.log("cmsAddUrl success", _fjid);
  3464. fjid.value = _fjid;
  3465. },
  3466. });
  3467. return fjid.value != null && fjid.value !== "";
  3468. };
  3469. const openAttachmentDialog = () => {
  3470. if (!fjButton.cmsUpdUrl) {
  3471. console.warn("ss-editor 未配置附件编辑地址,忽略附件操作");
  3472. return;
  3473. }
  3474. if (!ensureAttachmentId()) {
  3475. return;
  3476. }
  3477. const str = buildAttachmentDialogQuery();
  3478. console.log("str", str);
  3479. SS.openDialog({
  3480. src: fjButton.cmsUpdUrl + str,
  3481. headerTitle: "编辑",
  3482. width: 900,
  3483. high: 664,
  3484. zIndex: 51,
  3485. });
  3486. };
  3487. // 筛选出自定义按钮(有 func 的)
  3488. const customButtonsFromParam = buttonArray.filter(btn => btn.func).map(btn => ({
  3489. name: btn.name,
  3490. text: btn.desc || btn.text,
  3491. tooltip: btn.desc || btn.tooltip,
  3492. icon: btn.icon || 'editor-icon-file',
  3493. onClick: btn.func // 函数名字符串
  3494. }));
  3495. const mode = props.param ? props.param.mode : null;
  3496. const normalizeHtml = (rawHtml) => {
  3497. if (rawHtml == null) {
  3498. return "";
  3499. }
  3500. const html = String(rawHtml).trim();
  3501. if (!html) {
  3502. return "";
  3503. }
  3504. if (
  3505. /<html[\s>]/i.test(html) ||
  3506. /<body[\s>]/i.test(html) ||
  3507. /<!doctype/i.test(html)
  3508. ) {
  3509. try {
  3510. const doc = new DOMParser().parseFromString(html, "text/html");
  3511. if (doc && doc.body) {
  3512. return doc.body.innerHTML || "";
  3513. }
  3514. } catch (e) {
  3515. console.warn("ss-editor 解析完整HTML失败,回退原始内容:", e);
  3516. }
  3517. }
  3518. return html;
  3519. };
  3520. const syncHiddenContentInput = (html) => {
  3521. const contentElements = document.getElementsByName(resolveHtmlFieldName());
  3522. if (contentElements.length > 0) {
  3523. contentElements[0].value = html;
  3524. }
  3525. };
  3526. const setEditorHtml = (html) => {
  3527. const normalizedHtml = normalizeHtml(html);
  3528. editorContent.value = normalizedHtml;
  3529. syncHiddenContentInput(normalizedHtml);
  3530. if (editorRef.value && editorRef.value.value !== normalizedHtml) {
  3531. editorRef.value.value = normalizedHtml;
  3532. }
  3533. };
  3534. const resolveWindowFunction = (handlerName) => {
  3535. if (!handlerName || typeof handlerName !== "string") {
  3536. return null;
  3537. }
  3538. return handlerName.split(".").reduce((current, key) => {
  3539. return current && current[key] != null ? current[key] : null;
  3540. }, window);
  3541. };
  3542. const getCustomButtonKey = (button, index) => {
  3543. const baseName =
  3544. (button &&
  3545. (button.key || button.name || button.text || button.tooltip)) ||
  3546. `button${index + 1}`;
  3547. return `ssCustomButton_${String(baseName).replace(
  3548. /[^a-zA-Z0-9_-]/g,
  3549. "_"
  3550. )}_${index}`;
  3551. };
  3552. const normalizeCustomButtons = (buttons = []) => {
  3553. return Array.isArray(buttons)
  3554. ? buttons.filter(Boolean).map((button, index) => ({
  3555. ...button,
  3556. _buttonKey: getCustomButtonKey(button, index),
  3557. }))
  3558. : [];
  3559. };
  3560. const renderButtonIcon = (icon) => {
  3561. if (!icon) {
  3562. return null;
  3563. }
  3564. if (typeof icon === "string" && icon.trim().startsWith("<")) {
  3565. return icon;
  3566. }
  3567. return `<span class="editor-icon ${icon}"></span>`;
  3568. };
  3569. const buildCustomButtonRegistry = (buttons = []) => {
  3570. const controls = {};
  3571. const buttonNames = [];
  3572. const iconMap = {};
  3573. normalizeCustomButtons(buttons).forEach((button) => {
  3574. const buttonKey = button._buttonKey;
  3575. const handler =
  3576. button.onClick ||
  3577. button.click ||
  3578. button.handler ||
  3579. button.exec ||
  3580. null;
  3581. const tooltip =
  3582. button.tooltip ||
  3583. button.text ||
  3584. button.label ||
  3585. button.name ||
  3586. "自定义按钮";
  3587. buttonNames.push(buttonKey);
  3588. if (button.icon) {
  3589. iconMap[buttonKey] = button.icon;
  3590. }
  3591. controls[buttonKey] = {
  3592. name: button.name || buttonKey,
  3593. tooltip,
  3594. exec: function (editor) {
  3595. const context = {
  3596. editor,
  3597. button,
  3598. props,
  3599. value:
  3600. editor && typeof editor.value !== "undefined"
  3601. ? editor.value
  3602. : "",
  3603. setValue: (value) => setEditorHtml(value),
  3604. getValue: () =>
  3605. editor && typeof editor.value !== "undefined"
  3606. ? editor.value
  3607. : "",
  3608. emit,
  3609. currentModelValue: currentModelValue.value,
  3610. fjid: fjid.value,
  3611. };
  3612. if (typeof handler === "function") {
  3613. return handler(context);
  3614. }
  3615. if (typeof handler === "string") {
  3616. const windowHandler = resolveWindowFunction(handler);
  3617. if (typeof windowHandler === "function") {
  3618. return windowHandler(context);
  3619. }
  3620. console.warn("ss-editor 自定义按钮未找到点击事件:", handler);
  3621. return undefined;
  3622. }
  3623. console.warn("ss-editor 自定义按钮缺少点击事件配置:", button);
  3624. return undefined;
  3625. },
  3626. };
  3627. });
  3628. return {
  3629. controls,
  3630. buttonNames,
  3631. iconMap,
  3632. };
  3633. };
  3634. const validate = () => {
  3635. if (window.ssVm) {
  3636. const result = window.ssVm.validateField(props.name);
  3637. console.log("validate", window.ssVm.validateField(props.name));
  3638. errMsg.value = result.valid ? "" : result.message;
  3639. }
  3640. };
  3641. onMounted(() => {
  3642. validate();
  3643. // 只读模式下不初始化 Jodit,直接设置内容 by xu 20250402
  3644. if (props.mode === "play") {
  3645. if (props.html) {
  3646. setEditorHtml(props.html);
  3647. } else if (props.url) {
  3648. const params = new URLSearchParams();
  3649. if (mode) params.append("mode", mode);
  3650. if (props.modelValue) params.append("path", props.modelValue);
  3651. axios
  3652. .post(props.url, params, {
  3653. headers: {
  3654. "Content-Type": "application/x-www-form-urlencoded",
  3655. },
  3656. })
  3657. .then((response) => {
  3658. if ("timeout" == response.data.statusText) {
  3659. alert("网络超时!");
  3660. return;
  3661. }
  3662. const content = response.data.content;
  3663. if (content != null) {
  3664. setEditorHtml(content);
  3665. }
  3666. const filePath = response.data.path;
  3667. if (filePath) {
  3668. currentModelValue.value = filePath;
  3669. emit("update:modelValue", filePath);
  3670. }
  3671. });
  3672. } else {
  3673. setEditorHtml(props.html);
  3674. }
  3675. return;
  3676. }
  3677. // 读取按钮配置 by xu 20250408(移除废弃的 props.customButtons)
  3678. let buttonsToUse = [];
  3679. // 1. 优先从 param.button 数组中筛选(新格式)by xu 20250331
  3680. if (customButtonsFromParam && customButtonsFromParam.length > 0) {
  3681. buttonsToUse = customButtonsFromParam;
  3682. }
  3683. // 2. 尝试从 param.customButtons 读取(旧格式,兼容)
  3684. if (!buttonsToUse || buttonsToUse.length === 0) {
  3685. if (props.param && props.param.customButtons && props.param.customButtons.length > 0) {
  3686. buttonsToUse = props.param.customButtons;
  3687. }
  3688. }
  3689. // 3. 尝试通过桥接 API 读取
  3690. if (!buttonsToUse || buttonsToUse.length === 0) {
  3691. const vm = window.SS.dom.getVueApp({ scope: "chain" });
  3692. if (vm && vm.zwwjCustomButtons) {
  3693. buttonsToUse = vm.zwwjCustomButtons;
  3694. }
  3695. }
  3696. // 4. 从 formElemConfig 读取(兜底)
  3697. if (!buttonsToUse || buttonsToUse.length === 0) {
  3698. const zwwjConfig = window.SS.dom.formElemConfig?.zwwj;
  3699. if (zwwjConfig?.customButtons) {
  3700. buttonsToUse = zwwjConfig.customButtons;
  3701. } else {
  3702. buttonsToUse = window.SS.dom.formElemConfig?.zwwjCustomButtons;
  3703. }
  3704. }
  3705. const {
  3706. controls: customButtonControls,
  3707. buttonNames: customButtonNames,
  3708. iconMap: customButtonIconMap,
  3709. } = buildCustomButtonRegistry(buttonsToUse);
  3710. console.log(
  3711. "[SsEditor] 解析后的按钮:",
  3712. customButtonNames,
  3713. customButtonControls
  3714. );
  3715. const appendCustomButtons = (buttons = []) => {
  3716. if (!customButtonNames.length) {
  3717. return buttons;
  3718. }
  3719. const toolbarButtons = [...buttons];
  3720. const insertIndex = toolbarButtons.includes("dots")
  3721. ? toolbarButtons.indexOf("dots")
  3722. : toolbarButtons.includes("print")
  3723. ? toolbarButtons.indexOf("print")
  3724. : -1;
  3725. if (insertIndex >= 0) {
  3726. toolbarButtons.splice(insertIndex, 0, ...customButtonNames);
  3727. return toolbarButtons;
  3728. }
  3729. return [...toolbarButtons, ...customButtonNames];
  3730. };
  3731. const editor = Jodit.make(`#${uniqueId}`, {
  3732. height: props.height,
  3733. placeholder: props.placeholder,
  3734. readonly: props.mode === "play",
  3735. language: "zh_cn",
  3736. i18n: {
  3737. zh_cn: {
  3738. Link: "链接",
  3739. URL: "链接",
  3740. "No follow": "无跟踪",
  3741. "Class name": "类名",
  3742. Image: "图片",
  3743. File: "文件",
  3744. "Line height": "行高",
  3745. Alternative: "描述",
  3746. "Alternative text": "描述",
  3747. "Lower Alpha": "小写字母",
  3748. "Upper Alpha": "大写字母",
  3749. "Upper Roman": "大写罗马数字",
  3750. "Lower Roman": "小写罗马数字",
  3751. "Lower Greek": "小写希腊字母",
  3752. "Lower Letter": "小写字母",
  3753. "Upper Letter": "大写字母",
  3754. },
  3755. },
  3756. showXPathInStatusbar: false,
  3757. showCharsCounter: false,
  3758. showWordsCounter: false,
  3759. allowResizeY: false,
  3760. toolbarSticky: false,
  3761. statusbar: false,
  3762. uploader: {
  3763. url: props.uploadUrl,
  3764. format: "json",
  3765. method: "POST",
  3766. filesVariableName: function (i) {
  3767. return "imgs[" + i + "]";
  3768. },
  3769. headers: {
  3770. Accept: "application/json",
  3771. },
  3772. prepareData: function (formData) {
  3773. return formData;
  3774. },
  3775. isSuccess: function (resp) {
  3776. console.log("isSuccess resp:", resp);
  3777. return resp.code === 0;
  3778. },
  3779. getMessage: function (resp) {
  3780. console.log("getMessage resp:", resp);
  3781. return resp.msg || "上传失败";
  3782. },
  3783. process: function (resp) {
  3784. console.log("process resp:", resp);
  3785. return resp.data.url;
  3786. },
  3787. error: function (e) {
  3788. console.error("上传失败:", e.message);
  3789. },
  3790. defaultHandlerSuccess: function (resp) {
  3791. console.log("上传成功:", resp);
  3792. },
  3793. defaultHandlerError: function (err) {
  3794. console.error("上传错误:", err);
  3795. },
  3796. contentType: function () {
  3797. return false;
  3798. },
  3799. },
  3800. controls: {
  3801. font: {
  3802. list: {
  3803. Arial: "Arial",
  3804. SimSun: "宋体",
  3805. SimHei: "黑体",
  3806. "Microsoft YaHei": "微软雅黑",
  3807. KaiTi: "楷体",
  3808. FangSong: "仿宋",
  3809. "Times New Roman": "Times New Roman",
  3810. "Courier New": "Courier New",
  3811. },
  3812. },
  3813. customLinkButton: {
  3814. name: "link",
  3815. tooltip: attachmentLabel,
  3816. exec: function () {
  3817. openAttachmentDialog();
  3818. },
  3819. },
  3820. ...customButtonControls,
  3821. },
  3822. toolbarAdaptive: true,
  3823. // 调试:记录最终按钮配置
  3824. buttons: (() => {
  3825. const finalButtons = appendCustomButtons([
  3826. "fullsize",
  3827. "bold",
  3828. "italic",
  3829. "underline",
  3830. "strikethrough",
  3831. "eraser",
  3832. "|",
  3833. "font",
  3834. "fontsize",
  3835. "brush",
  3836. "paragraph",
  3837. "|",
  3838. "left",
  3839. "center",
  3840. "right",
  3841. "justify",
  3842. "|",
  3843. "ul",
  3844. "ol",
  3845. "indent",
  3846. "outdent",
  3847. "|",
  3848. "image",
  3849. "table",
  3850. "customLinkButton",
  3851. "print",
  3852. "|",
  3853. "undo",
  3854. "redo",
  3855. "find",
  3856. ]);
  3857. console.log("[SsEditor] 最终 buttons 配置:", finalButtons);
  3858. return finalButtons;
  3859. })(),
  3860. buttonsMD: appendCustomButtons([
  3861. "fullsize",
  3862. "bold",
  3863. "italic",
  3864. "underline",
  3865. "strikethrough",
  3866. "eraser",
  3867. "|",
  3868. "font",
  3869. "fontsize",
  3870. "brush",
  3871. "paragraph",
  3872. "|",
  3873. "font",
  3874. "fontsize",
  3875. "|",
  3876. "left",
  3877. "center",
  3878. "right",
  3879. "justify",
  3880. "|",
  3881. "image",
  3882. "customLinkButton",
  3883. "|",
  3884. "dots",
  3885. ]),
  3886. buttonsSM: appendCustomButtons([
  3887. "fullsize",
  3888. "bold",
  3889. "italic",
  3890. "|",
  3891. "image",
  3892. "|",
  3893. "dots",
  3894. ]),
  3895. buttonsXS: appendCustomButtons(["fullsize", "bold", "|", "dots"]),
  3896. sizeLG: 1024,
  3897. sizeMD: 768,
  3898. sizeSM: 576,
  3899. getIcon: function (name, clearName) {
  3900. const iconMap = {
  3901. bold: "editor-icon-bold",
  3902. italic: "editor-icon-italic",
  3903. underline: "editor-icon-underline",
  3904. strikethrough: "editor-icon-strikethrough",
  3905. eraser: "editor-icon-eraser",
  3906. copyformat: "editor-icon-copyformat",
  3907. font: "editor-icon-font",
  3908. fontsize: "editor-icon-fontsize",
  3909. brush: "editor-icon-brush",
  3910. paragraph: "editor-icon-paragraph",
  3911. left: "editor-icon-align-left",
  3912. center: "editor-icon-align-center",
  3913. right: "editor-icon-align-right",
  3914. justify: "editor-icon-align-justify",
  3915. ul: "editor-icon-ul",
  3916. ol: "editor-icon-ol",
  3917. indent: "editor-icon-indent",
  3918. outdent: "editor-icon-outdent",
  3919. image: "editor-icon-image",
  3920. file: "editor-icon-file",
  3921. video: "editor-icon-video",
  3922. table: "editor-icon-table",
  3923. link: "editor-icon-link",
  3924. source: "editor-icon-source",
  3925. eye: "editor-icon-preview",
  3926. fullsize: "editor-icon-fullsize",
  3927. shrink: "editor-icon-fullsize-exit",
  3928. print: "editor-icon-print",
  3929. undo: "editor-icon-undo",
  3930. redo: "editor-icon-redo",
  3931. search: "editor-icon-find",
  3932. selectall: "editor-icon-selectall",
  3933. };
  3934. const customIcon =
  3935. customButtonIconMap[clearName] || customButtonIconMap[name];
  3936. if (customIcon) {
  3937. return renderButtonIcon(customIcon);
  3938. }
  3939. const iconClass = iconMap[clearName] || iconMap[name];
  3940. if (iconClass) {
  3941. return renderButtonIcon(iconClass);
  3942. }
  3943. return null;
  3944. },
  3945. });
  3946. editorRef.value = editor;
  3947. editor.events.on("change", () => {
  3948. const html = editor.value || "";
  3949. editorContent.value = html;
  3950. syncHiddenContentInput(html);
  3951. emit("change", html);
  3952. setTimeout(() => {
  3953. validate();
  3954. }, 50);
  3955. });
  3956. emit("ready", editor);
  3957. if (props.html) {
  3958. setEditorHtml(props.html);
  3959. } else if (props.url) {
  3960. const params = new URLSearchParams();
  3961. if (mode) params.append("mode", mode);
  3962. if (props.modelValue) params.append("path", props.modelValue);
  3963. axios
  3964. .post(props.url, params, {
  3965. headers: {
  3966. "Content-Type": "application/x-www-form-urlencoded",
  3967. },
  3968. })
  3969. .then((response) => {
  3970. if ("timeout" == response.data.statusText) {
  3971. alert("网络超时!");
  3972. return;
  3973. }
  3974. const content = response.data.content;
  3975. if (content != null) {
  3976. setEditorHtml(content);
  3977. }
  3978. const filePath = response.data.path;
  3979. if (filePath) {
  3980. currentModelValue.value = filePath;
  3981. emit("update:modelValue", filePath);
  3982. }
  3983. });
  3984. } else {
  3985. setEditorHtml(props.html);
  3986. }
  3987. });
  3988. watch(
  3989. () => props.html,
  3990. (newValue) => {
  3991. setEditorHtml(newValue);
  3992. }
  3993. );
  3994. watch(
  3995. () => props.modelValue,
  3996. (newValue) => {
  3997. currentModelValue.value = newValue || "";
  3998. }
  3999. );
  4000. watch(
  4001. () => props.mode,
  4002. (newMode) => {
  4003. if (editorRef.value) {
  4004. editorRef.value.setReadOnly(newMode === "play");
  4005. }
  4006. }
  4007. );
  4008. onBeforeUnmount(() => {
  4009. if (editorRef.value) {
  4010. editorRef.value.destruct();
  4011. }
  4012. });
  4013. return () => {
  4014. const htmlFieldName = resolveHtmlFieldName();
  4015. const storeFieldName = resolveStoreFieldName();
  4016. const editorPathField = storeFieldName || props.name || "";
  4017. // 只读模式:不初始化 Jodit,直接渲染 HTML + 附件按钮 by xu 20250402
  4018. if (props.mode === "play") {
  4019. return h("div", { class: "ss-editor-container ss-editor-readonly" }, [
  4020. fjid.value &&
  4021. h("input", {
  4022. type: "hidden",
  4023. name: attachmentFieldName,
  4024. value: fjid.value,
  4025. }),
  4026. h("input", {
  4027. type: "hidden",
  4028. name: htmlFieldName,
  4029. value: editorContent.value,
  4030. }),
  4031. h("input", {
  4032. type: "hidden",
  4033. name: storeFieldName,
  4034. value: currentModelValue.value,
  4035. }),
  4036. h("input", {
  4037. type: "hidden",
  4038. name: "ueditorpath",
  4039. value: editorPathField,
  4040. }),
  4041. // 附件按钮(只读模式下仍显示)
  4042. fjButton.cmsAddUrl && fjButton.cmsUpdUrl &&
  4043. h("div", {
  4044. class: "ss-editor-attach-btn",
  4045. onClick: openAttachmentDialog,
  4046. }, [
  4047. h("span", { class: "editor-icon editor-icon-file" }),
  4048. h("span", { class: "ss-editor-attach-text" }, attachmentLabel)
  4049. ]),
  4050. // HTML 内容展示
  4051. h("div", {
  4052. class: "ss-editor-readonly-content",
  4053. innerHTML: editorContent.value,
  4054. }),
  4055. ]);
  4056. }
  4057. // 正常编辑模式:渲染 textarea 供 Jodit 初始化
  4058. return h("div", { class: "ss-editor-container" }, [
  4059. fjid.value &&
  4060. h("input", {
  4061. type: "hidden",
  4062. name: attachmentFieldName,
  4063. value: fjid.value,
  4064. }),
  4065. h("input", {
  4066. type: "hidden",
  4067. name: htmlFieldName,
  4068. value: editorContent.value,
  4069. }),
  4070. h("input", {
  4071. type: "hidden",
  4072. name: storeFieldName,
  4073. value: currentModelValue.value,
  4074. }),
  4075. h("input", {
  4076. type: "hidden",
  4077. name: "ueditorpath",
  4078. value: editorPathField,
  4079. }),
  4080. h("textarea", { id: uniqueId }),
  4081. ]);
  4082. };
  4083. },
  4084. };
  4085. // 弹窗右边图标
  4086. const SsFullStyleHeader = {
  4087. name: "SsFullStyleHeader",
  4088. props: {
  4089. title: {
  4090. type: String,
  4091. default: "标题",
  4092. },
  4093. },
  4094. emits: ["close"],
  4095. setup(props, { emit }) {
  4096. // console.log(props.title)
  4097. const onClose = () => {
  4098. emit("close");
  4099. };
  4100. const SsIcon = resolveComponent("ss-icon");
  4101. return () =>
  4102. h("div", { class: "header-container" }, [
  4103. h("div", { class: "title" }, props.title),
  4104. h("div", { class: "handle-bar" }, [
  4105. h("div", { class: "left-bar" }, [
  4106. h(SsDialogIcon, { class: "dialog-icon-download" }),
  4107. h(SsDialogIcon, { class: "dialog-icon-print" }),
  4108. h(SsDialogIcon, { class: "dialog-icon-setting" }),
  4109. h(SsDialogIcon, { class: "dialog-icon-collect" }),
  4110. h(SsDialogIcon, { class: "dialog-icon-help" }),
  4111. h(SsDialogIcon, { class: "dialog-icon-full-screen" }),
  4112. h(SsDialogIcon, { class: "dialog-icon-lock" }),
  4113. ]),
  4114. h("div", { class: "close-bar", onClick: onClose }, [
  4115. h(SsDialogIcon, { class: "dialog-icon-close" }),
  4116. ]),
  4117. ]),
  4118. ]);
  4119. },
  4120. };
  4121. // ss-dialog弹窗
  4122. const SsDialog = {
  4123. name: "SsDialog",
  4124. props: {
  4125. src: {
  4126. type: String,
  4127. },
  4128. headerTitle: {
  4129. type: String,
  4130. // required: true,
  4131. default: "弹窗",
  4132. },
  4133. width: {
  4134. type: String,
  4135. default: "1400",
  4136. },
  4137. height: {
  4138. type: String,
  4139. default: "600",
  4140. },
  4141. params: {
  4142. type: Object,
  4143. default: () => ({}),
  4144. },
  4145. zIndex: {
  4146. type: Number,
  4147. default: 1000,
  4148. },
  4149. },
  4150. emits: ["close"],
  4151. setup(props, { slots, emit }) {
  4152. // 关闭窗口方法
  4153. const onClose = () => {
  4154. emit("close");
  4155. };
  4156. const showHeader = ref(true);
  4157. const headerVisible = ref(false);
  4158. const popupHieght = ref(props.height);
  4159. // 状态:存储位置信息
  4160. const position = reactive({
  4161. // 页面居中
  4162. x: (window.innerWidth - props.width) / 2,
  4163. y: (window.innerHeight - popupHieght.value) / 2,
  4164. isDragging: false,
  4165. offsetX: 0,
  4166. offsetY: 0,
  4167. });
  4168. // 鼠标按下时设置起始坐标并开始拖拽
  4169. const startDrag = (event) => {
  4170. position.isDragging = true;
  4171. position.offsetX = event.clientX - position.x;
  4172. position.offsetY = event.clientY - position.y;
  4173. };
  4174. // 鼠标移动时更新位置
  4175. const onDrag = (event) => {
  4176. if (position.isDragging) {
  4177. position.x = event.clientX - position.offsetX;
  4178. position.y = event.clientY - position.offsetY;
  4179. }
  4180. };
  4181. // 鼠标放开时结束拖拽
  4182. const endDrag = () => {
  4183. position.isDragging = false;
  4184. };
  4185. // 监听来自 iframe 的消息
  4186. const handleMessage = (event) => {
  4187. // 顶天立地
  4188. if (event.data && typeof event.data.hasScrollBar !== "undefined") {
  4189. if (event.data.hasScrollBar) {
  4190. // console.log(event);
  4191. position.y = 10;
  4192. showHeader.value = false;
  4193. headerVisible.value = true;
  4194. popupHieght.value = window.innerHeight - 20;
  4195. // console.log(popupHieght.value);
  4196. document.querySelector(".body").style.height = "100%";
  4197. document.querySelector(".body").style.paddingTop = "30px";
  4198. document.querySelector(".header-container ").style.position =
  4199. "absolute";
  4200. document.querySelector(".header-container ").style.zIndex = "10";
  4201. }
  4202. }
  4203. };
  4204. // 鼠标移入关闭按钮区域时显示头部
  4205. const onMouseEnterCloseButton = () => {
  4206. headerVisible.value = false;
  4207. };
  4208. // 鼠标移出关闭按钮区域时隐藏头部
  4209. const onMouseLeaveCloseButton = () => {
  4210. headerVisible.value = true;
  4211. };
  4212. // 在组件挂载时添加全局事件监听器
  4213. Vue.onMounted(() => {
  4214. // 如果传过来的高度大于窗口高度,则设置为窗口高度减去20 否则保持传过来的高度
  4215. popupHieght.value =
  4216. popupHieght.value > window.innerHeight
  4217. ? window.innerHeight - 20
  4218. : popupHieght.value;
  4219. const container = document.querySelector(".header-container");
  4220. if (container) {
  4221. container.addEventListener("mousedown", startDrag);
  4222. }
  4223. document.addEventListener("mousemove", onDrag);
  4224. document.addEventListener("mouseup", endDrag);
  4225. window.addEventListener("message", handleMessage);
  4226. });
  4227. // 在组件卸载时移除全局事件监听器
  4228. Vue.onUnmounted(() => {
  4229. document.removeEventListener("mousemove", onDrag);
  4230. document.removeEventListener("mouseup", endDrag);
  4231. window.removeEventListener("message", handleMessage);
  4232. });
  4233. const SsMark = resolveComponent("ss-mark");
  4234. const SsFullStyleHeader = resolveComponent("ss-full-style-header");
  4235. // render函数定义组件结构
  4236. return () =>
  4237. h(
  4238. Teleport,
  4239. { to: "body" }, // 使用 Teleport 将弹窗内容挂载到 body
  4240. h(SsMark, {}, [
  4241. h(
  4242. "div",
  4243. {
  4244. class: "popup-container",
  4245. style: {
  4246. position: "absolute",
  4247. left: `${position.x}px`,
  4248. top: `${position.y}px`,
  4249. width: props.width + "px",
  4250. height: popupHieght.value + "px",
  4251. zIndex: props.zIndex, // 确保弹窗在最上层
  4252. },
  4253. },
  4254. [
  4255. h(SsFullStyleHeader, {
  4256. class: "header",
  4257. title: props.headerTitle,
  4258. onClose: onClose,
  4259. onMousedown: startDrag, // 绑定拖动事件
  4260. onMouseUp: endDrag,
  4261. ...(!showHeader.value && {
  4262. onMouseenter: onMouseEnterCloseButton,
  4263. onMouseleave: onMouseLeaveCloseButton,
  4264. }),
  4265. style: {
  4266. cursor: position.isDragging ? "grabbing" : "grab",
  4267. visibility: headerVisible.value ? "hidden" : "visible",
  4268. },
  4269. }),
  4270. h(
  4271. "div",
  4272. {
  4273. class: "body",
  4274. style: {},
  4275. },
  4276. [
  4277. h("iframe", {
  4278. src: props.src,
  4279. frameborder: 0,
  4280. style: { width: "100%", height: "100%" },
  4281. }),
  4282. ]
  4283. ),
  4284. headerVisible.value &&
  4285. h("div", {
  4286. class: "close-button",
  4287. onMouseenter: onMouseEnterCloseButton,
  4288. onMouseleave: onMouseLeaveCloseButton,
  4289. style: {
  4290. position: "absolute",
  4291. top: "0",
  4292. right: "0",
  4293. // background: 'black',
  4294. width: "60px",
  4295. height: "60px",
  4296. cursor: "pointer",
  4297. },
  4298. }),
  4299. ]
  4300. ),
  4301. ])
  4302. );
  4303. },
  4304. };
  4305. // ss-mark遮罩层
  4306. const SsMark = {
  4307. name: "SsMark",
  4308. setup(props, { slots, emit }) {
  4309. return () =>
  4310. h("div", { class: "dialog-container" }, [
  4311. h("div", { class: "mark-content" }, [
  4312. h("div", { class: "dialog-contianer" }, [
  4313. slots.default ? slots.default() : "",
  4314. ]),
  4315. ]),
  4316. ]);
  4317. },
  4318. };
  4319. // ss-bottom-button 底部按钮
  4320. // 修改支持更多按钮 by xu 20251211
  4321. const SsBottomButton = {
  4322. name: "SsBottomButton",
  4323. props: {
  4324. text: {
  4325. type: String,
  4326. required: false,
  4327. },
  4328. type: {
  4329. type: String,
  4330. default: "button",
  4331. },
  4332. iconClass: {
  4333. type: String,
  4334. },
  4335. class: {
  4336. type: String,
  4337. default: "",
  4338. },
  4339. onclick: {
  4340. type: [Function, String],
  4341. default: null,
  4342. },
  4343. // 修改支持更多按钮 by xu 20251211
  4344. more: {
  4345. type: [Boolean, String],
  4346. default: false,
  4347. },
  4348. },
  4349. setup(props, { emit }) {
  4350. const SsBottomDivIcon = Vue.resolveComponent("ss-bottom-div-icon");
  4351. const showDropdown = Vue.ref(false);
  4352. // 修改支持更多按钮 by xu 20251211
  4353. const moreKey = Vue.computed(() => {
  4354. const val = props.more;
  4355. if (val === false || val === null || typeof val === "undefined") {
  4356. return null;
  4357. }
  4358. if (val === true || val === "" || val === "true") {
  4359. return "moreChg";
  4360. }
  4361. return val;
  4362. });
  4363. // 从配置中读取按钮信息和下拉选项
  4364. const config = Vue.computed(() => {
  4365. if (
  4366. moreKey.value &&
  4367. window.ss &&
  4368. window.ss.dom &&
  4369. window.ss.dom.btnElemConfig
  4370. ) {
  4371. return window.ss.dom.btnElemConfig[moreKey.value] || {};
  4372. }
  4373. return {};
  4374. });
  4375. const buttonText = Vue.computed(() => {
  4376. return props.text || config.value.desc || "";
  4377. });
  4378. const dropOptions = Vue.computed(() => {
  4379. return config.value.dropOptions || [];
  4380. });
  4381. const hasDropdown = Vue.computed(() => {
  4382. return dropOptions.value.length > 0;
  4383. });
  4384. const handleMouseEnter = () => {
  4385. if (hasDropdown.value) {
  4386. showDropdown.value = true;
  4387. }
  4388. };
  4389. const handleMouseLeave = () => {
  4390. showDropdown.value = false;
  4391. };
  4392. const handleDropItemClick = (option) => {
  4393. if (option.callback && typeof option.callback === "function") {
  4394. option.callback();
  4395. }
  4396. showDropdown.value = false;
  4397. };
  4398. return () =>
  4399. h(
  4400. "div",
  4401. {
  4402. class: "ss-bottom-button-wrapper",
  4403. onMouseenter: handleMouseEnter,
  4404. onMouseleave: handleMouseLeave,
  4405. },
  4406. [
  4407. h(
  4408. "button",
  4409. {
  4410. class: props.class,
  4411. onClick: (e) => {
  4412. e.stopPropagation();
  4413. emit("click", e);
  4414. if (props.onclick) {
  4415. // 如果是函数直接调用
  4416. if (typeof props.onclick === "function") {
  4417. props.onclick(e);
  4418. } else if (typeof props.onclick === "string") {
  4419. // 如果是字符串,使用直接的方法执行
  4420. // 临时存储按钮元素到全局变量
  4421. window.__ss_current_button = e.currentTarget;
  4422. // 直接执行代码,使用eval以保留原始上下文
  4423. try {
  4424. eval(props.onclick);
  4425. } finally {
  4426. // 清理全局变量
  4427. delete window.__ss_current_button;
  4428. }
  4429. }
  4430. }
  4431. },
  4432. type: props.type,
  4433. },
  4434. [
  4435. h("span", null, [
  4436. h(SsBottomDivIcon, {
  4437. class: props.iconClass,
  4438. }),
  4439. ]),
  4440. h("span", null, buttonText.value),
  4441. ]
  4442. ),
  4443. // 渲染下拉菜单
  4444. hasDropdown.value && showDropdown.value
  4445. ? h(
  4446. "div",
  4447. {
  4448. class: "ss-bottom-button-dropdown",
  4449. },
  4450. dropOptions.value.map((option) =>
  4451. h(
  4452. "div",
  4453. {
  4454. class: "ss-bottom-button-dropdown-item",
  4455. onClick: (e) => {
  4456. e.stopPropagation();
  4457. handleDropItemClick(option);
  4458. },
  4459. },
  4460. option.desc
  4461. )
  4462. )
  4463. )
  4464. : null,
  4465. ]
  4466. );
  4467. },
  4468. };
  4469. // ss-search搜索框
  4470. const SsSearch = {
  4471. name: "SsSearch",
  4472. props: {
  4473. theme: {
  4474. type: String,
  4475. default: "light",
  4476. validator: function (value) {
  4477. return ["dark", "light"].includes(value);
  4478. },
  4479. },
  4480. placeholder: {
  4481. type: String,
  4482. default: "请输入搜索条件",
  4483. },
  4484. },
  4485. setup(props, { emit }) {
  4486. const onClick = () => {
  4487. console.log("Search clicked");
  4488. emit("click");
  4489. };
  4490. const SsIcon = Vue.resolveComponent("ss-icon");
  4491. return () =>
  4492. Vue.h(
  4493. "div",
  4494. {
  4495. class: ["search-container", props.theme],
  4496. onClick: onClick,
  4497. },
  4498. [
  4499. Vue.h("input", {
  4500. placeholder: props.placeholder,
  4501. disabled: true,
  4502. }),
  4503. Vue.h(SsIcon, {
  4504. name: "search-result",
  4505. size: "20px",
  4506. }),
  4507. ]
  4508. );
  4509. },
  4510. };
  4511. // ss-cart-item 菜单页面的卡片 左右结构
  4512. const SsCartItem = {
  4513. name: "SsCartItem",
  4514. props: {
  4515. active: Boolean,
  4516. item: {
  4517. type: Object,
  4518. default: () => ({
  4519. thumb: "images/example/project-img.png",
  4520. title: "广州(国际)科技成果转化天河基地专",
  4521. description: "佳能中国广州分公司",
  4522. all: 50,
  4523. finish: 5,
  4524. }),
  4525. },
  4526. },
  4527. setup(props, { emit }) {
  4528. const item = props.item;
  4529. const itemWidth = Vue.computed(() => {
  4530. const containerWidth =
  4531. document.body.clientWidth || document.body.scrollWidth - 520;
  4532. const halfWidth = containerWidth / 2;
  4533. if (halfWidth < 480) {
  4534. return Math.min(containerWidth, 702) + "px";
  4535. } else {
  4536. return Math.min(halfWidth, 702) + "px";
  4537. }
  4538. });
  4539. const onItemClick = (e) => {
  4540. emit("click", e);
  4541. };
  4542. return {
  4543. item,
  4544. itemWidth,
  4545. onItemClick,
  4546. };
  4547. },
  4548. render() {
  4549. const SsIcon = Vue.resolveComponent("ss-icon");
  4550. return Vue.h(
  4551. "div",
  4552. {
  4553. class: { "item-container": true, active: this.active },
  4554. onClick: this.onItemClick,
  4555. style: { width: this.itemWidth },
  4556. },
  4557. [
  4558. Vue.h("div", { class: "header" }, [
  4559. Vue.h(SsIcon, { name: "setting", size: "20px" }),
  4560. ]),
  4561. Vue.h("div", { class: "body" }, [
  4562. Vue.h("div", { class: "left" }, [
  4563. Vue.h("img", {
  4564. src: this.item.thumb,
  4565. alt: "Thumbnail",
  4566. class: "imgUnHandle",
  4567. style: { "object-fit": "cover", width: "100%", height: "100%" },
  4568. }),
  4569. ]),
  4570. Vue.h("div", { class: "right" }, [
  4571. Vue.h("div", { class: "title" }, this.item.title),
  4572. Vue.h("div", { class: "desc" }, this.item.description),
  4573. Vue.h("div", { class: "progress" }, [
  4574. Vue.h(
  4575. "div",
  4576. {
  4577. style: {
  4578. width: `${(this.item.finish / this.item.all) * 100}%`,
  4579. },
  4580. },
  4581. [Vue.h("div", `${this.item.finish}/${this.item.all}`)]
  4582. ),
  4583. ]),
  4584. ]),
  4585. ]),
  4586. ]
  4587. );
  4588. },
  4589. };
  4590. // ss-cart-item2 菜单页面的卡片 上下结构
  4591. const SsCartItem2 = {
  4592. name: "SsCartItem2",
  4593. props: {
  4594. active: Boolean,
  4595. item: {
  4596. type: Object,
  4597. default: () => ({
  4598. thumb: "images/example/project-img.png",
  4599. title: "广州(国际)科技成果转化天河基地专",
  4600. description: "佳能中国广州分公司",
  4601. all: 50,
  4602. finish: 5,
  4603. }),
  4604. },
  4605. },
  4606. setup(props, { emit }) {
  4607. const item = props.item;
  4608. const itemWidth = Vue.computed(() => {
  4609. const containerWidth =
  4610. document.body.clientWidth || document.body.scrollWidth - 520;
  4611. const halfWidth = containerWidth / 2;
  4612. if (halfWidth < 480) {
  4613. return Math.min(containerWidth, 702) + "px";
  4614. } else {
  4615. return Math.min(halfWidth, 702) + "px";
  4616. }
  4617. });
  4618. const onItemClick = (e) => {
  4619. emit("click", e);
  4620. };
  4621. return {
  4622. item,
  4623. itemWidth,
  4624. onItemClick,
  4625. };
  4626. },
  4627. render() {
  4628. const SsIcon = Vue.resolveComponent("ss-icon");
  4629. return Vue.h(
  4630. "div",
  4631. {
  4632. class: { "item-container2": true, active: this.active },
  4633. onClick: this.onItemClick,
  4634. style: { width: this.itemWidth },
  4635. },
  4636. [
  4637. Vue.h("div", { class: "action-bar" }, [
  4638. Vue.h(SsIcon, { name: "setting", size: "20px" }),
  4639. ]),
  4640. Vue.h("div", { class: "header" }, [
  4641. Vue.h("div", { class: "title" }, `${this.item.title}`),
  4642. ]),
  4643. Vue.h("div", { class: "body" }, [
  4644. Vue.h("div", { class: "left" }, [
  4645. Vue.h("img", {
  4646. src: this.item.thumb,
  4647. alt: "Thumbnail",
  4648. class: "imgUnHandle",
  4649. style: { "object-fit": "cover", width: "100%", height: "100%" },
  4650. }),
  4651. ]),
  4652. Vue.h("div", { class: "right" }, [
  4653. Vue.h("div", { class: "content" }, this.item.description),
  4654. Vue.h("div", { class: "tip" }, [
  4655. Vue.h("div", { class: "progress" }, [
  4656. Vue.h(
  4657. "div",
  4658. {
  4659. style: {
  4660. width: `${(this.item.finish / this.item.all) * 100}%`,
  4661. },
  4662. },
  4663. [Vue.h("div", `${this.item.finish}/${this.item.all}`)]
  4664. ),
  4665. ]),
  4666. ]),
  4667. ]),
  4668. ]),
  4669. ]
  4670. );
  4671. },
  4672. };
  4673. /**
  4674. * SsListCard - 列表卡片组件
  4675. *
  4676. * @description 用于显示列表项的卡片组件,支持缩略图、标签、状态、操作按钮和选择功能
  4677. *
  4678. * @prop {Object} item - 卡片数据对象
  4679. * @prop {String} item.title - 卡片标题
  4680. * @prop {String} [item.thumb] - 缩略图 URL(可选)
  4681. * @prop {String} [item.thumbType] - 缩略图类型:'thumbnail'(缩略图)或默认(证件照)
  4682. * @prop {String} [item.status] - 卡片状态:'available'(可用-绿色)、'unavailable'(不可用-黄色)、'disabled'(禁用-红色)
  4683. * @prop {Array} item.tags - 标签数组,格式:[{键: 值}, ...]
  4684. * @prop {Function} item.onclick - 点击卡片的回调函数
  4685. * @prop {Array} [item.buttons] - 操作按钮数组(可选),显示在右上角齿轮
  4686. * @prop {Array} [item.statusIcons] - 状态图标数组(可选),显示在右上角,格式:[{class: '图标类名', title: '提示文字'}, ...]
  4687. *
  4688. * @example
  4689. * // 基础用法
  4690. * const item = {
  4691. * title: "卡片标题",
  4692. * tags: [
  4693. * { 类型: '文档' },
  4694. * { 状态: '进行中' }
  4695. * ],
  4696. * onclick: () => console.log('点击了卡片')
  4697. * };
  4698. *
  4699. * @example
  4700. * // 带缩略图和状态
  4701. * const item = {
  4702. * title: "场地预定",
  4703. * thumbType: 'thumbnail',
  4704. * thumb: "https://example.com/image.jpg",
  4705. * status: "available", // 绿色背景
  4706. * tags: [{ 容量: '50人' }],
  4707. * onclick: () => {}
  4708. * };
  4709. *
  4710. * @example
  4711. * // 带操作按钮和状态图标
  4712. * const item = {
  4713. * title: "会议室A",
  4714. * tags: [{ 楼层: '3F' }],
  4715. * onclick: () => {},
  4716. * // 右上角操作按钮(齿轮)
  4717. * buttons: [{
  4718. * class: 'cart-list-setting',
  4719. * title: '编辑',
  4720. * onclick: () => console.log('编辑')
  4721. * }],
  4722. * // 右上角状态图标(在齿轮右边)
  4723. * statusIcons: [{
  4724. * class: 'icon-emoji',
  4725. * title: '清洁中'
  4726. * }]
  4727. * };
  4728. *
  4729. * @features
  4730. * - 卡片选择:鼠标悬停右下角显示选择角标,点击切换选中状态,选中后显示底部深灰色线条
  4731. * - 状态颜色:根据 status 字段显示不同背景色(可用/不可用/禁用)
  4732. * - 图片类型:支持证件照(73×100px)和缩略图(180×100px)两种尺寸
  4733. * - 操作按钮:右上角齿轮,hover 显示,支持多个按钮下拉菜单
  4734. * - 状态图标:右上角显示状态图标,齿轮会根据图标数量自动左移
  4735. *
  4736. * @author xu
  4737. * @date 20260105
  4738. */
  4739. // 组件文档补全(JSDoc) by xu 20260108
  4740. /**
  4741. * SsListCard(左侧对象卡片)
  4742. *
  4743. * 用途:
  4744. * - 渲染左侧卡片(标题 + tags)
  4745. * - 右下角“角标”用于选中/取消选中(不会触发卡片 click)
  4746. *
  4747. * 调用示例:
  4748. * ```html
  4749. * <ss-list-card :item="item" @toggle-select="handleToggleSelect" @click="openDetail"></ss-list-card>
  4750. * ```
  4751. *
  4752. * Props:
  4753. * - `item`:卡片数据对象(建议含 `id/title/tags[]`;内部会读写 `item._ssSelected` 作为选中态)
  4754. *
  4755. * Emits:
  4756. * - `toggle-select`:点击角标触发,参数 `{ item, selected }`
  4757. * - `click`:点击卡片主体触发(用于打开详情等)
  4758. */
  4759. const SsListCard = {
  4760. name: "SsListCard",
  4761. props: {
  4762. ssObjName: { type: String, default: "" }, // 功能:业务对象名(用于默认缩略图 icon) by xu 20260109
  4763. cardClickAction: { type: String, default: "view" }, // 功能:卡片主体点击动作(view=查看;single=单选互斥) by xu 20260109
  4764. item: {
  4765. type: Object,
  4766. required: true,
  4767. },
  4768. },
  4769. emits: ["click", "change", "toggle-select"],
  4770. setup(props, { emit }) {
  4771. const item = props.item;
  4772. // 移除 itemWidth 计算属性,不再需要 by xu 20260105
  4773. // 判断卡片类型 by xu 20260105
  4774. const cardType = Vue.computed(() => {
  4775. // 支持“无图但保留缩略图占位”(同一业务列表图片形态一致) by xu 20260109
  4776. if (!item.thumb && !item.thumbType) return ""; // 业务列表“无图”形态
  4777. // 根据 thumbType 字段判断,如果没有则默认为证件照
  4778. return item.thumbType === "thumbnail" ? "card-thumbnail" : "card-photo";
  4779. });
  4780. // 判断状态类型 - 场地预定状态 by xu 20260105
  4781. const statusClass = Vue.computed(() => {
  4782. if (!item.status) return ""; // 无状态,默认白色
  4783. // 映射状态值到 CSS 类名
  4784. const statusMap = {
  4785. available: "status-available",
  4786. unavailable: "status-unavailable",
  4787. disabled: "status-disabled",
  4788. };
  4789. return statusMap[item.status] || "";
  4790. });
  4791. const onItemClick = (e) => {
  4792. // 清除所有类型卡片的 active 状态(卡片主体点击仅做 active 高亮) by xu 20260109
  4793. const allListCards = document.querySelectorAll(
  4794. ".knowledge-item-container"
  4795. );
  4796. const allFolderCards = document.querySelectorAll(".ss-folder-list");
  4797. allListCards.forEach((card) => card.classList.remove("active"));
  4798. allFolderCards.forEach((card) => card.classList.remove("active"));
  4799. // 设置当前项的 active 状态
  4800. e.currentTarget.classList.add("active");
  4801. // 卡片主体点击动作由页面级配置控制 by xu 20260109
  4802. if (props.cardClickAction === "view") {
  4803. props.item.onclick?.();
  4804. // 通知父级:卡片点击(查看) by xu 20260109
  4805. emit("click", props.item);
  4806. }
  4807. };
  4808. const onItemChange = (e, icon, index) => {
  4809. e.stopPropagation(); // 阻止事件冒泡到卡片
  4810. props.item.buttons[0].onclick();
  4811. // emit("change", { item: props.item, icon, index });
  4812. };
  4813. return {
  4814. item,
  4815. cardType,
  4816. statusClass,
  4817. onItemClick,
  4818. onItemChange,
  4819. };
  4820. },
  4821. data() {
  4822. return {
  4823. showButtons: false,
  4824. selected: false, // 选择状态 by xu 20260105
  4825. showTextPopover: false, // 功能:右侧文字区 hover 展示全量 by xu 20260108
  4826. textPopoverType: "", // second-summary / second-tags / third / third-full by xu 20260108
  4827. textPopoverBottom: 0, // 功能:popover 从当前省略行位置向上展开 by xu 20260108
  4828. hideTextPopoverTimer: null, // 功能:鼠标从省略行移到浮层的缓冲 by xu 20260108
  4829. textPopoverPayload: null, // { kind, text?, lines? } by xu 20260108
  4830. ellipsisVisible: {
  4831. // 功能:只在真实出现 ... 时才显示命中区/允许 goheight by xu 20260109
  4832. secondSummary: false,
  4833. secondTags: false,
  4834. third: false,
  4835. thirdFull: false,
  4836. },
  4837. };
  4838. },
  4839. methods: {
  4840. __allowSelect() {
  4841. // 功能说明:无 rbarObj 时禁用选中能力(隐藏右下角勾选并禁止 toggle) by xu 20260122
  4842. try {
  4843. if (this?.$root && this.$root.hasObjPanel === false) return false;
  4844. if (
  4845. typeof window !== "undefined" &&
  4846. window.__objListVm &&
  4847. window.__objListVm.hasObjPanel === false
  4848. )
  4849. return false;
  4850. } catch (_) {}
  4851. return true;
  4852. },
  4853. // 切换选择状态(对外 emit,支持方案A父级 state 中转) by xu 20260106
  4854. toggleSelect(e) {
  4855. e.stopPropagation();
  4856. if (!this.__allowSelect()) return; // 功能说明:无 rbarObj 时禁止选中 by xu 20260122
  4857. // 使用 item 上的状态,便于父级/右侧边栏反向同步 by xu 20260106
  4858. this.item._ssSelected = !this.item?._ssSelected;
  4859. this.$emit("toggle-select", {
  4860. item: this.item,
  4861. selected: !!this.item?._ssSelected,
  4862. });
  4863. },
  4864. // 卡片主体点击=单选互斥:只有“本次切到选中”才清理其他选中 by xu 20260109
  4865. toggleSelectExclusive(e) {
  4866. e?.stopPropagation?.();
  4867. if (!this.__allowSelect()) return; // 功能说明:无 rbarObj 时禁止选中 by xu 20260122
  4868. this.item._ssSelected = !this.item?._ssSelected;
  4869. const selected = !!this.item?._ssSelected;
  4870. this.$emit("toggle-select", {
  4871. item: this.item,
  4872. selected,
  4873. exclusive: true,
  4874. });
  4875. },
  4876. // 功能:无缩略图时,用业务对象 icon 做默认图(ss-icon + icon-obj-xx) by xu 20260109
  4877. getBizThumbIconClass() {
  4878. const name = String(
  4879. this.ssObjName ||
  4880. this.item?.ssObjName ||
  4881. this.$root?.ssObjName ||
  4882. window?.ss?.dom?.ssObjName ||
  4883. ""
  4884. ).trim();
  4885. if (!name) return "";
  4886. return `icon-obj-${name}`;
  4887. },
  4888. // 功能:构造右侧文字区 4 行(摘要/类目或标签/对象号) by xu 20260108
  4889. buildRightTextLines() {
  4890. const item = this.item || {};
  4891. const summary = String(item?.desc ?? "").trim(); // 后端字段后续映射 by xu 20260108
  4892. const objNum = String(item?.objNum ?? "").trim(); // 后端字段后续映射 by xu 20260108
  4893. const categoryArr = Array.isArray(item?.category) ? item.category : [];
  4894. const tagsArr = Array.isArray(item?.tags) ? item.tags : [];
  4895. const hasTags = tagsArr.length > 0;
  4896. const hasCategory = categoryArr.length > 0;
  4897. // 第二部分(L1-L3):摘要优先,其次物品参数 by xu 20260108
  4898. const secondKind = summary ? "summary" : hasTags ? "tags" : "";
  4899. const hasSecond = !!secondKind;
  4900. // 第三部分(L4):对象号优先,其次类目 by xu 20260108
  4901. const thirdKind = objNum ? "objNum" : hasCategory ? "category" : "";
  4902. const hasThird = !!thirdKind;
  4903. const thirdFull = !hasSecond && hasThird; // 第二部分为空则第三部分占满 4 行 by xu 20260108
  4904. const secondFull = hasSecond && !hasThird && secondKind === "tags"; // 仅标签时占满 4 行(不留空行) by xu 20260109
  4905. const toValueText = (obj) => {
  4906. // 功能说明:类目/物品参数回显展示 key: value(否则只显示值看不懂) by xu 20260114
  4907. const [k, v] = Object.entries(obj || {})[0] || ["", ""];
  4908. const key = k !== undefined && k !== null ? String(k).trim() : "";
  4909. const val = v !== undefined && v !== null ? String(v).trim() : "";
  4910. if (key && val) return `${key}:${val}`;
  4911. if (val) return val;
  4912. if (key) return key;
  4913. return "";
  4914. };
  4915. const toLineList = (arr) =>
  4916. (arr || [])
  4917. .map(toValueText)
  4918. .map((s) => String(s ?? "").trim())
  4919. .filter(Boolean);
  4920. const flat = (arr) => toLineList(arr).join(" ");
  4921. // 第二部分 tags:默认 3 行;仅标签时占满 4 行(避免底部空一行) by xu 20260109
  4922. const secondTagsMaxLines = secondFull ? 4 : 3;
  4923. const secondTagsLinesFull = toLineList(tagsArr);
  4924. const secondTagsHead = secondTagsLinesFull.slice(
  4925. 0,
  4926. Math.max(0, secondTagsMaxLines - 1)
  4927. );
  4928. const secondTagsTail = secondTagsLinesFull.slice(
  4929. Math.max(0, secondTagsMaxLines - 1)
  4930. );
  4931. const secondTagsLast =
  4932. secondTagsTail.length <= 1
  4933. ? secondTagsTail[0] || ""
  4934. : secondTagsTail.join(" "); // 功能:最后一行平铺剩余 by xu 20260108
  4935. // 第三部分类目:卡片上串成一行;goheight 展开时一条一行 by xu 20260109
  4936. const categoryLinesFull = toLineList(categoryArr);
  4937. const categoryLine = categoryLinesFull.join(" ");
  4938. const thirdText =
  4939. thirdKind === "objNum"
  4940. ? objNum
  4941. : thirdKind === "category"
  4942. ? categoryLine
  4943. : "";
  4944. return {
  4945. secondKind,
  4946. thirdKind,
  4947. hasSecond,
  4948. hasThird,
  4949. thirdFull,
  4950. secondFull,
  4951. summary,
  4952. secondTagsMaxLines,
  4953. secondTagsHead,
  4954. secondTagsLast,
  4955. secondTagsLinesFull,
  4956. objNum,
  4957. categoryLine,
  4958. categoryLinesFull,
  4959. thirdText,
  4960. };
  4961. },
  4962. measureTextOverflowByLines(text, maxLines, width) {
  4963. const w = Number(width) || 0;
  4964. if (!w || !text) return false;
  4965. const probe = document.createElement("div");
  4966. probe.style.position = "fixed";
  4967. probe.style.left = "-99999px";
  4968. probe.style.top = "0";
  4969. probe.style.width = w + "px";
  4970. probe.style.fontSize = "18px";
  4971. probe.style.lineHeight = "24px";
  4972. probe.style.whiteSpace = "normal";
  4973. probe.style.wordBreak = "break-word";
  4974. probe.style.visibility = "hidden";
  4975. probe.textContent = text;
  4976. document.body.appendChild(probe);
  4977. const h = probe.getBoundingClientRect().height || 0;
  4978. document.body.removeChild(probe);
  4979. return h > maxLines * 24 + 1;
  4980. },
  4981. measureSingleLineOverflow(text, width) {
  4982. const w = Number(width) || 0;
  4983. if (!w || !text) return false;
  4984. const probe = document.createElement("span");
  4985. probe.style.position = "fixed";
  4986. probe.style.left = "-99999px";
  4987. probe.style.top = "0";
  4988. probe.style.display = "inline-block";
  4989. probe.style.maxWidth = w + "px";
  4990. probe.style.fontSize = "18px";
  4991. probe.style.lineHeight = "24px";
  4992. probe.style.whiteSpace = "nowrap";
  4993. probe.style.visibility = "hidden";
  4994. probe.textContent = text;
  4995. document.body.appendChild(probe);
  4996. const overflow =
  4997. (probe.scrollWidth || 0) > (probe.clientWidth || w) + 1;
  4998. document.body.removeChild(probe);
  4999. return overflow;
  5000. },
  5001. // 功能:根据当前卡片宽度刷新「是否出现 ...」状态(用于控制命中区显示) by xu 20260109
  5002. refreshEllipsisVisible() {
  5003. try {
  5004. const right = this.$el?.querySelector?.(".right");
  5005. const rawWidth =
  5006. right?.getBoundingClientRect?.().width || right?.clientWidth || 0;
  5007. const width = Math.max(0, Math.round(rawWidth)); // 修复:内容区不再使用 padding-right 预留,测量按真实宽度 by xu 20260109
  5008. const model = this.buildRightTextLines();
  5009. const next = {
  5010. secondSummary: false,
  5011. secondTags: false,
  5012. third: false,
  5013. thirdFull: false,
  5014. };
  5015. if (model.secondKind === "summary" && model.summary) {
  5016. next.secondSummary = this.measureTextOverflowByLines(
  5017. model.summary,
  5018. 3,
  5019. width
  5020. );
  5021. }
  5022. if (model.secondKind === "tags") {
  5023. // 功能说明:tags 采用「最后一行平铺剩余」策略,是否出现 ... 仅取决于最后一行是否溢出(数量多但平铺放得下不算溢出) by xu 20260114
  5024. next.secondTags = this.measureSingleLineOverflow(
  5025. model.secondTagsLast,
  5026. width
  5027. );
  5028. }
  5029. if (model.hasThird && !model.thirdFull) {
  5030. next.third = this.measureSingleLineOverflow(model.thirdText, width);
  5031. }
  5032. if (model.hasThird && model.thirdFull) {
  5033. next.thirdFull = this.measureTextOverflowByLines(
  5034. model.thirdText,
  5035. 4,
  5036. width
  5037. );
  5038. }
  5039. const prev = this.ellipsisVisible || {};
  5040. const changed =
  5041. prev.secondSummary !== next.secondSummary ||
  5042. prev.secondTags !== next.secondTags ||
  5043. prev.third !== next.third ||
  5044. prev.thirdFull !== next.thirdFull;
  5045. if (changed) this.ellipsisVisible = next;
  5046. } catch (e) {
  5047. // ignore by xu 20260109
  5048. }
  5049. },
  5050. showTextPopoverFor(el, kind) {
  5051. // 调试开关:window.__SS_LISTCARD_DEBUG__ = true 时打印 hover/溢出判断日志 by xu 20260108
  5052. const debug =
  5053. typeof window !== "undefined" && !!window.__SS_LISTCARD_DEBUG__;
  5054. if (debug) {
  5055. console.log("[SsListCard] ellipsis hover", {
  5056. kind,
  5057. el: el?.className,
  5058. });
  5059. }
  5060. const model = this.buildRightTextLines();
  5061. const lineEl = el?.closest?.(".ss-card-text__line") || el;
  5062. const right = lineEl?.closest?.(".right") || el?.closest?.(".right");
  5063. const rawWidth =
  5064. right?.getBoundingClientRect?.().width || right?.clientWidth || 0;
  5065. const width = Math.max(0, Math.round(rawWidth)); // 修复:内容区不再预留 padding-right,测量按真实宽度 by xu 20260109
  5066. const textEl =
  5067. kind === "second-summary"
  5068. ? lineEl?.querySelector?.(".ss-card-text__secondSummary")
  5069. : kind === "second-tags"
  5070. ? lineEl?.querySelector?.(".ss-card-text__tagLineLast")
  5071. : kind === "third"
  5072. ? lineEl?.querySelector?.(".ss-card-text__thirdLine")
  5073. : lineEl?.querySelector?.(".ss-card-text__thirdFull");
  5074. let payload = null;
  5075. // 仅当真实会出现 ... 时才允许 goheight(避免“没超出也能出 goheight”) by xu 20260109
  5076. const overflowed =
  5077. kind === "second-summary"
  5078. ? this.measureTextOverflowByLines(model.summary, 3, width)
  5079. : kind === "second-tags"
  5080. ? this.measureSingleLineOverflow(model.secondTagsLast, width) // 功能说明:同 refreshEllipsisVisible,tags 仅看最后一行是否溢出 by xu 20260114
  5081. : kind === "third"
  5082. ? this.measureSingleLineOverflow(model.thirdText, width)
  5083. : this.measureTextOverflowByLines(model.thirdText, 4, width);
  5084. if (!overflowed) return;
  5085. if (kind === "second-summary") {
  5086. if (model.summary) payload = { kind, text: model.summary };
  5087. } else if (kind === "second-tags") {
  5088. if (
  5089. Array.isArray(model.secondTagsLinesFull) &&
  5090. model.secondTagsLinesFull.length
  5091. ) {
  5092. payload = { kind, lines: model.secondTagsLinesFull };
  5093. }
  5094. } else if (kind === "third") {
  5095. if (
  5096. model.thirdKind === "category" &&
  5097. Array.isArray(model.categoryLinesFull) &&
  5098. model.categoryLinesFull.length
  5099. ) {
  5100. payload = { kind, lines: model.categoryLinesFull }; // 功能:类目展开一条一行 by xu 20260109
  5101. } else if (model.thirdText) {
  5102. payload = { kind, text: model.thirdText };
  5103. }
  5104. } else if (kind === "third-full") {
  5105. if (
  5106. model.thirdKind === "category" &&
  5107. Array.isArray(model.categoryLinesFull) &&
  5108. model.categoryLinesFull.length
  5109. ) {
  5110. payload = { kind, lines: model.categoryLinesFull }; // 功能:类目占满模式展开一条一行 by xu 20260109
  5111. } else if (model.thirdText) {
  5112. payload = { kind, text: model.thirdText };
  5113. }
  5114. }
  5115. if (debug) {
  5116. console.log("[SsListCard] ellipsis decide", {
  5117. kind,
  5118. rawWidth: Math.round(rawWidth),
  5119. width,
  5120. hasPayload: !!payload,
  5121. textEl: textEl?.className,
  5122. textClient: textEl
  5123. ? {
  5124. cw: textEl.clientWidth,
  5125. ch: textEl.clientHeight,
  5126. sw: textEl.scrollWidth,
  5127. sh: textEl.scrollHeight,
  5128. }
  5129. : null,
  5130. });
  5131. }
  5132. if (!payload) return;
  5133. this.clearHideTextPopoverTimer();
  5134. const container = lineEl?.closest?.(".right");
  5135. const containerRect = container?.getBoundingClientRect?.();
  5136. const lineRect = lineEl?.getBoundingClientRect?.();
  5137. if (containerRect && lineRect) {
  5138. const bottom = Math.max(
  5139. 0,
  5140. Math.round(containerRect.bottom - lineRect.bottom)
  5141. );
  5142. this.textPopoverBottom = bottom;
  5143. } else {
  5144. this.textPopoverBottom = 0;
  5145. }
  5146. this.textPopoverPayload = payload;
  5147. this.textPopoverType = kind;
  5148. this.showTextPopover = true;
  5149. if (debug) console.log("[SsListCard] goheight show", payload);
  5150. },
  5151. isOverflowing(el) {
  5152. if (!el) return false;
  5153. // 单行/多行省略统一判断:scroll 尺寸大于 client 尺寸即认为有 ... by xu 20260108
  5154. return (
  5155. (el.scrollWidth &&
  5156. el.clientWidth &&
  5157. el.scrollWidth > el.clientWidth + 1) ||
  5158. (el.scrollHeight &&
  5159. el.clientHeight &&
  5160. el.scrollHeight > el.clientHeight + 1)
  5161. );
  5162. },
  5163. isSummaryOverflowing(el) {
  5164. if (!el) return false;
  5165. // -webkit-line-clamp 场景下 scrollHeight 不稳定,改用“无 clamp 的离屏测量”判断是否超过 2 行 by xu 20260108
  5166. const text = String(this.item?.desc ?? "").trim();
  5167. if (!text) return false;
  5168. const rect = el.getBoundingClientRect?.();
  5169. const width = rect?.width || el.clientWidth || 0;
  5170. if (!width) return false;
  5171. const probe = document.createElement("div");
  5172. probe.style.position = "fixed";
  5173. probe.style.left = "-99999px";
  5174. probe.style.top = "0";
  5175. probe.style.width = width + "px";
  5176. probe.style.fontSize = "18px";
  5177. probe.style.lineHeight = "24px";
  5178. probe.style.whiteSpace = "normal";
  5179. probe.style.wordBreak = "break-word";
  5180. probe.style.visibility = "hidden";
  5181. probe.textContent = text;
  5182. document.body.appendChild(probe);
  5183. const h = probe.getBoundingClientRect().height || 0;
  5184. document.body.removeChild(probe);
  5185. return h > 48 + 1;
  5186. },
  5187. clearHideTextPopoverTimer() {
  5188. if (this.hideTextPopoverTimer) {
  5189. clearTimeout(this.hideTextPopoverTimer);
  5190. this.hideTextPopoverTimer = null;
  5191. }
  5192. },
  5193. // 修复 goheight hover 无响应:移除重复方法覆盖,统一使用上面的 showTextPopoverFor(el, kind) by xu 20260109
  5194. hideTextPopoverLater() {
  5195. this.clearHideTextPopoverTimer();
  5196. this.hideTextPopoverTimer = setTimeout(() => {
  5197. this.showTextPopover = false;
  5198. this.textPopoverType = "";
  5199. this.textPopoverPayload = null;
  5200. }, 120);
  5201. },
  5202. hideTextPopover() {
  5203. this.clearHideTextPopoverTimer();
  5204. this.showTextPopover = false;
  5205. this.textPopoverType = "";
  5206. this.textPopoverPayload = null;
  5207. },
  5208. // 功能:新需求下不在 updated 内做测量,避免死循环 by xu 20260108
  5209. },
  5210. mounted() {
  5211. // 无需在 mounted/updated 里做 overflow 测量(避免死循环),只在 hover 触发时判断 by xu 20260108
  5212. // 仅用于控制“...命中区是否显示”,不会触发循环更新 by xu 20260109
  5213. this.$nextTick?.(() => {
  5214. requestAnimationFrame(() => this.refreshEllipsisVisible?.());
  5215. });
  5216. this.__ssListCardResizeHandler = () => this.refreshEllipsisVisible?.(); // 功能:窗口变化时刷新 ... 显示 by xu 20260109
  5217. window.addEventListener?.("resize", this.__ssListCardResizeHandler);
  5218. },
  5219. updated() {
  5220. // 卡片数据更新后刷新一次 ... 显示状态(避免“宽度/内容变了但命中区不变”) by xu 20260109
  5221. this.$nextTick?.(() => {
  5222. requestAnimationFrame(() => this.refreshEllipsisVisible?.());
  5223. });
  5224. },
  5225. beforeUnmount() {
  5226. // 清理 timer,避免残留导致异常 by xu 20260108
  5227. this.clearHideTextPopoverTimer?.();
  5228. if (this.__ssListCardResizeHandler) {
  5229. window.removeEventListener?.("resize", this.__ssListCardResizeHandler);
  5230. this.__ssListCardResizeHandler = null;
  5231. }
  5232. },
  5233. render() {
  5234. const SsCartListIcon = Vue.resolveComponent("ss-cart-list-icon");
  5235. const SsIcon = Vue.resolveComponent("ss-icon");
  5236. const hasThumbArea = !!(this.item?.thumb || this.item?.thumbType); // 功能:无图但有 thumbType 时仍保留占位 by xu 20260109
  5237. const thumbSrc = (() => {
  5238. // 功能说明:兼容 thumb 为 raw path 或 {val}/{value},组件内统一转为 dlByHttp URL by xu 20260122
  5239. const t = this.item?.thumb;
  5240. if (!t) return "";
  5241. if (typeof t === "string") {
  5242. const s = t.trim();
  5243. if (!s) return "";
  5244. // 已经是 URL/绝对路径则直接使用;否则按 path 构建 dlByHttp by xu 20260122
  5245. if (
  5246. /^https?:\/\//i.test(s) ||
  5247. s.startsWith("/service?") ||
  5248. s.startsWith("/")
  5249. )
  5250. return s;
  5251. return buildThumbUrl(s);
  5252. }
  5253. return buildThumbUrl(t);
  5254. })();
  5255. return Vue.h(
  5256. "div",
  5257. {
  5258. class: {
  5259. "knowledge-item-container": true,
  5260. active: this.item.active,
  5261. [this.cardType]: !!this.cardType, // 动态添加卡片类型类名 by xu 20260105
  5262. [this.statusClass]: !!this.statusClass,
  5263. },
  5264. onClick: (e) => {
  5265. this.onItemClick?.(e);
  5266. if (this.__allowSelect() && this.cardClickAction === "single") {
  5267. // 功能说明:无 rbarObj 时不允许单选互斥 by xu 20260122
  5268. this.toggleSelectExclusive?.(e);
  5269. }
  5270. }, // 功能:卡片主体点击动作(view/single) by xu 20260109
  5271. // 移除固定宽度,由 CSS min-width 控制 by xu 20260105
  5272. },
  5273. [
  5274. // 右上角状态图标区域 by xu 20260105
  5275. this.item?.statusIcons?.length > 0 &&
  5276. Vue.h(
  5277. "div",
  5278. { class: "card-status-icons" },
  5279. this.item.statusIcons.map((icon) =>
  5280. Vue.h(SsIcon, {
  5281. class: `status-icon ${icon.class}`,
  5282. title: icon.title,
  5283. })
  5284. )
  5285. ),
  5286. this.item?.buttons?.length > 0 &&
  5287. Vue.h(
  5288. "div",
  5289. {
  5290. class: "header",
  5291. style:
  5292. this.item?.statusIcons?.length > 0
  5293. ? {
  5294. right: `${this.item.statusIcons.length * 48}px`,
  5295. borderTopRightRadius: "0",
  5296. }
  5297. : {},
  5298. onMouseenter: () => (this.showButtons = true),
  5299. onMouseleave: () => (this.showButtons = false),
  5300. onClick: (e) => this.onItemChange(e, this.item.buttons[0], 0),
  5301. },
  5302. [
  5303. // 只在有按钮时渲染设置图标
  5304. // this.item?.buttons?.length > 0 &&
  5305. Vue.h("div", {
  5306. class: "cart-list-setting cart-list-icon",
  5307. title: this.item?.buttons?.[0]?.title,
  5308. }),
  5309. // 鼠标移入时显示按钮列表,与图标同级
  5310. // this.item?.buttons?.length > 0 &&
  5311. this.showButtons &&
  5312. this.item?.buttons?.length > 1 &&
  5313. Vue.h(
  5314. "div",
  5315. {
  5316. class: "cart-list-button-popup",
  5317. },
  5318. this.item.buttons.map((btn) =>
  5319. Vue.h(
  5320. "div",
  5321. {
  5322. onClick: (e) => {
  5323. e.stopPropagation();
  5324. btn.onclick?.();
  5325. },
  5326. },
  5327. [
  5328. // 如果有 class,显示对应的图标
  5329. btn.class &&
  5330. Vue.h(SsCartListIcon, {
  5331. class: [btn.class],
  5332. }),
  5333. // 显示按钮文本
  5334. Vue.h("span", null, btn.title),
  5335. ]
  5336. )
  5337. )
  5338. ),
  5339. ]
  5340. ),
  5341. Vue.h("div", { class: "body" }, [
  5342. Vue.h("div", { class: "box-header" }, [
  5343. Vue.h("div", `${this.item.title}`),
  5344. ]),
  5345. Vue.h(
  5346. "div",
  5347. {
  5348. class: !hasThumbArea ? "no-thumb box-body" : "box-body",
  5349. },
  5350. [
  5351. hasThumbArea
  5352. ? thumbSrc
  5353. ? Vue.h("div", { class: "left" }, [
  5354. Vue.h("img", {
  5355. src: thumbSrc,
  5356. alt: "Thumbnail",
  5357. class: "imgUnHandle",
  5358. style: {
  5359. "object-fit": "cover",
  5360. width: "100%",
  5361. height: "100%",
  5362. },
  5363. }),
  5364. ])
  5365. : Vue.h(
  5366. // 功能:无图占位(ss-icon + biz icon,居中) by xu 20260109
  5367. "div",
  5368. { class: "left ss-objlist-thumbPlaceholder" },
  5369. [
  5370. Vue.h(SsIcon, {
  5371. class: `${this.getBizThumbIconClass()} ss-objlist-thumbIcon`,
  5372. }),
  5373. ]
  5374. )
  5375. : null,
  5376. Vue.h(
  5377. "div",
  5378. {
  5379. class: "right",
  5380. },
  5381. (() => {
  5382. const model = this.buildRightTextLines(); // 功能:右侧文字区新规则(第二部分/第三部分优先级) by xu 20260108
  5383. const hasAny = !!(model?.hasSecond || model?.hasThird);
  5384. if (!hasAny) return [];
  5385. const children = [];
  5386. // 第二部分:L1-L3(摘要优先,其次 tags;不足留空;超出 L3 ...) by xu 20260108
  5387. if (model.hasSecond) {
  5388. if (model.secondKind === "summary") {
  5389. children.push(
  5390. Vue.h(
  5391. "div",
  5392. {
  5393. class:
  5394. "ss-card-text__line ss-card-text__secondBlock",
  5395. },
  5396. [
  5397. Vue.h(
  5398. "div",
  5399. {
  5400. class: "ss-card-text__secondSummary",
  5401. title: model.summary,
  5402. },
  5403. model.summary
  5404. ),
  5405. Vue.h("span", {
  5406. class: [
  5407. "ss-card-text__ellipsisHit",
  5408. "ss-card-text__ellipsisHit--second",
  5409. this.ellipsisVisible?.secondSummary
  5410. ? "is-on"
  5411. : "",
  5412. ],
  5413. title: "查看完整摘要",
  5414. onMouseenter: (e) =>
  5415. this.showTextPopoverFor(
  5416. e?.currentTarget,
  5417. "second-summary"
  5418. ),
  5419. onClick: (e) => {
  5420. e?.stopPropagation?.();
  5421. this.showTextPopoverFor(
  5422. e?.currentTarget,
  5423. "second-summary"
  5424. );
  5425. }, // 功能:点击 ... 也可展开(避免 hover 受遮挡) by xu 20260109
  5426. onMouseleave: () => this.hideTextPopoverLater(),
  5427. }),
  5428. ]
  5429. )
  5430. );
  5431. } else if (model.secondKind === "tags") {
  5432. children.push(
  5433. Vue.h(
  5434. "div",
  5435. {
  5436. class: [
  5437. "ss-card-text__line",
  5438. model.secondFull
  5439. ? "ss-card-text__secondFullBlock"
  5440. : "ss-card-text__secondBlock",
  5441. ],
  5442. },
  5443. [
  5444. // 功能:仅标签时占满 4 行 by xu 20260109
  5445. Vue.h(
  5446. "div",
  5447. { class: "ss-card-text__secondTags" },
  5448. [
  5449. ...model.secondTagsHead.map((t) =>
  5450. Vue.h(
  5451. "div",
  5452. {
  5453. class: "ss-card-text__tagLine",
  5454. title: t,
  5455. },
  5456. t
  5457. )
  5458. ),
  5459. // 第三行:平铺剩余(可能为空) by xu 20260108
  5460. Vue.h(
  5461. "div",
  5462. {
  5463. class:
  5464. "ss-card-text__tagLine is-last ss-card-text__tagLineLast",
  5465. title: model.secondTagsLast,
  5466. },
  5467. model.secondTagsLast
  5468. ),
  5469. ].filter(Boolean)
  5470. ),
  5471. // 只在最后一行出现 ... 时才触发 goheight by xu 20260108
  5472. Vue.h("span", {
  5473. class: [
  5474. "ss-card-text__ellipsisHit",
  5475. "ss-card-text__ellipsisHit--second",
  5476. this.ellipsisVisible?.secondTags
  5477. ? "is-on"
  5478. : "",
  5479. ],
  5480. title: "查看完整物品参数",
  5481. onMouseenter: (e) =>
  5482. this.showTextPopoverFor(
  5483. e?.currentTarget,
  5484. "second-tags"
  5485. ),
  5486. onClick: (e) => {
  5487. e?.stopPropagation?.();
  5488. this.showTextPopoverFor(
  5489. e?.currentTarget,
  5490. "second-tags"
  5491. );
  5492. }, // 功能:点击 ... 也可展开(避免 hover 受遮挡) by xu 20260109
  5493. onMouseleave: () => this.hideTextPopoverLater(),
  5494. }),
  5495. ]
  5496. )
  5497. );
  5498. }
  5499. }
  5500. // 第三部分:默认 L4;第二部分为空则占满 L1-L4 by xu 20260108
  5501. if (model.hasThird) {
  5502. if (model.thirdFull) {
  5503. children.push(
  5504. Vue.h(
  5505. "div",
  5506. {
  5507. class:
  5508. "ss-card-text__line ss-card-text__thirdFullBlock",
  5509. },
  5510. [
  5511. Vue.h(
  5512. "div",
  5513. {
  5514. class: "ss-card-text__thirdFull",
  5515. title: model.thirdText,
  5516. },
  5517. model.thirdText
  5518. ),
  5519. Vue.h("span", {
  5520. class: [
  5521. "ss-card-text__ellipsisHit",
  5522. "ss-card-text__ellipsisHit--third",
  5523. this.ellipsisVisible?.thirdFull
  5524. ? "is-on"
  5525. : "",
  5526. ],
  5527. title: "查看完整信息",
  5528. onMouseenter: (e) =>
  5529. this.showTextPopoverFor(
  5530. e?.currentTarget,
  5531. "third-full"
  5532. ),
  5533. onClick: (e) => {
  5534. e?.stopPropagation?.();
  5535. this.showTextPopoverFor(
  5536. e?.currentTarget,
  5537. "third-full"
  5538. );
  5539. }, // 功能:点击 ... 也可展开(避免 hover 受遮挡) by xu 20260109
  5540. onMouseleave: () => this.hideTextPopoverLater(),
  5541. }),
  5542. ]
  5543. )
  5544. );
  5545. } else {
  5546. children.push(
  5547. Vue.h(
  5548. "div",
  5549. {
  5550. class:
  5551. "ss-card-text__line ss-card-text__thirdLineWrap",
  5552. },
  5553. [
  5554. Vue.h(
  5555. "div",
  5556. {
  5557. class: "ss-card-text__thirdLine",
  5558. title: model.thirdText,
  5559. },
  5560. model.thirdText
  5561. ),
  5562. Vue.h("span", {
  5563. class: [
  5564. "ss-card-text__ellipsisHit",
  5565. "ss-card-text__ellipsisHit--third",
  5566. this.ellipsisVisible?.third ? "is-on" : "",
  5567. ],
  5568. title: "查看完整信息",
  5569. onMouseenter: (e) =>
  5570. this.showTextPopoverFor(
  5571. e?.currentTarget,
  5572. "third"
  5573. ),
  5574. onClick: (e) => {
  5575. e?.stopPropagation?.();
  5576. this.showTextPopoverFor(
  5577. e?.currentTarget,
  5578. "third"
  5579. );
  5580. }, // 功能:点击 ... 也可展开(避免 hover 受遮挡) by xu 20260109
  5581. onMouseleave: () => this.hideTextPopoverLater(),
  5582. }),
  5583. ]
  5584. )
  5585. );
  5586. }
  5587. }
  5588. // hover 展开浮层:宽度=右侧文字区,底对齐向上展开,带阴影 by xu 20260108
  5589. // popover 作为 `.right` 的 sibling 渲染,避免被 `.ss-card-text{overflow:hidden}` 裁剪 by xu 20260108
  5590. const popover =
  5591. this.showTextPopover &&
  5592. Vue.h(
  5593. "div",
  5594. {
  5595. class: "ss-card-text-popover",
  5596. style: { bottom: this.textPopoverBottom + "px" },
  5597. onMouseenter: () => {
  5598. this.clearHideTextPopoverTimer();
  5599. this.showTextPopover = true;
  5600. },
  5601. onMouseleave: () => this.hideTextPopoverLater(),
  5602. },
  5603. (() => {
  5604. const p = this.textPopoverPayload || {};
  5605. if (p.kind === "second-summary" && p.text) {
  5606. return [
  5607. Vue.h(
  5608. "div",
  5609. { class: "ss-card-text-popover__summary" },
  5610. p.text
  5611. ),
  5612. ];
  5613. }
  5614. if (Array.isArray(p.lines)) {
  5615. return [
  5616. Vue.h(
  5617. "div",
  5618. { class: "ss-card-text-popover__kvlist" },
  5619. p.lines.map((t) =>
  5620. Vue.h(
  5621. "div",
  5622. { class: "ss-card-text-popover__kv" },
  5623. t
  5624. )
  5625. )
  5626. ),
  5627. ];
  5628. }
  5629. if (
  5630. (p.kind === "third" || p.kind === "third-full") &&
  5631. p.text
  5632. ) {
  5633. return [
  5634. Vue.h(
  5635. "div",
  5636. { class: "ss-card-text-popover__objno" },
  5637. p.text
  5638. ),
  5639. ];
  5640. }
  5641. return [];
  5642. })()
  5643. );
  5644. return [
  5645. Vue.h("div", { class: "ss-card-text" }, children),
  5646. popover,
  5647. ];
  5648. })()
  5649. ),
  5650. ]
  5651. ),
  5652. ]),
  5653. // 右下角卡片选择图标 by xu 20260105
  5654. this.__allowSelect()
  5655. ? Vue.h(SsIcon, {
  5656. class: this.item?._ssSelected
  5657. ? "card-icon icon-cardChk-on"
  5658. : "card-icon icon-cardChk",
  5659. onClick: this.toggleSelect,
  5660. })
  5661. : null,
  5662. // 选中后底部线条 by xu 20260105
  5663. this.__allowSelect() &&
  5664. this.item?._ssSelected &&
  5665. Vue.h("div", { class: "select-bottom-line" }),
  5666. ]
  5667. );
  5668. },
  5669. };
  5670. // 二级对象卡片:复用一级对象新卡片布局/省略浮层,但去掉勾选与 single 选中,仅支持点击查看 by xu 20260115
  5671. const SsCObjCardList = {
  5672. name: "SsCObjCardList",
  5673. props: {
  5674. ssObjName: { type: String, default: "" }, // 功能说明:业务对象名(用于默认缩略图 icon) by xu 20260115
  5675. dataType: { type: String, default: "" }, // 功能说明:页面类型(play=查看模式不显示右上角按钮) by xu 20250408
  5676. item: {
  5677. type: Object,
  5678. required: true,
  5679. },
  5680. },
  5681. emits: ["click", "change"],
  5682. setup(props, { emit }) {
  5683. const item = props.item;
  5684. const dataType = props.dataType; // 功能说明:页面类型 by xu 20250408
  5685. const cardType = Vue.computed(() => {
  5686. if (!item.thumb && !item.thumbType) return "";
  5687. return item.thumbType === "thumbnail" ? "card-thumbnail" : "card-photo";
  5688. });
  5689. const statusClass = Vue.computed(() => {
  5690. if (!item.status) return "";
  5691. const statusMap = {
  5692. available: "status-available",
  5693. unavailable: "status-unavailable",
  5694. disabled: "status-disabled",
  5695. };
  5696. return statusMap[item.status] || "";
  5697. });
  5698. const onItemClick = (e) => {
  5699. // 清除所有类型卡片的 active 状态(保持与一级对象一致) by xu 20260115
  5700. const allListCards = document.querySelectorAll(
  5701. ".knowledge-item-container"
  5702. );
  5703. const allFolderCards = document.querySelectorAll(".ss-folder-list");
  5704. allListCards.forEach((card) => card.classList.remove("active"));
  5705. allFolderCards.forEach((card) => card.classList.remove("active"));
  5706. e.currentTarget.classList.add("active");
  5707. // 二级对象卡片:点击仅查看(调用 item.onclick) by xu 20260115
  5708. props.item.onclick?.();
  5709. emit("click", props.item);
  5710. };
  5711. const onItemChange = (e) => {
  5712. e.stopPropagation();
  5713. props.item.buttons?.[0]?.onclick?.();
  5714. };
  5715. return { item, dataType, cardType, statusClass, onItemClick, onItemChange };
  5716. },
  5717. data() {
  5718. return {
  5719. showButtons: false,
  5720. showTextPopover: false, // 功能:右侧文字区 hover 展示全量 by xu 20260115
  5721. textPopoverType: "", // second-summary / second-tags / third / third-full by xu 20260115
  5722. textPopoverBottom: 0, // 功能:popover 从当前省略行位置向上展开 by xu 20260115
  5723. hideTextPopoverTimer: null, // 功能:鼠标从省略行移到浮层的缓冲 by xu 20260115
  5724. textPopoverPayload: null, // { kind, text?, lines? } by xu 20260115
  5725. ellipsisVisible: {
  5726. secondSummary: false,
  5727. secondTags: false,
  5728. third: false,
  5729. thirdFull: false,
  5730. }, // 功能:只在真实出现 ... 时才显示命中区/允许 goheight by xu 20260115
  5731. };
  5732. },
  5733. methods: {
  5734. getBizThumbIconClass() {
  5735. // 功能:无缩略图时,用业务对象 icon 做默认图(ss-icon + icon-obj-xx) by xu 20260115
  5736. const name = String(
  5737. this.ssObjName ||
  5738. this.item?.ssObjName ||
  5739. this.$root?.ssObjName ||
  5740. window?.ss?.dom?.ssObjName ||
  5741. ""
  5742. ).trim();
  5743. if (!name) return "";
  5744. return "icon-obj-" + name;
  5745. },
  5746. buildRightTextLines() {
  5747. // 功能:沿用一级对象卡片右侧文字区规则 by xu 20260115
  5748. const item = this.item || {};
  5749. const summary = String(item?.desc ?? "").trim();
  5750. const objNum = String(item?.objNum ?? "").trim();
  5751. const categoryArr = Array.isArray(item?.category) ? item.category : [];
  5752. const tagsArr = Array.isArray(item?.tags) ? item.tags : [];
  5753. const hasTags = tagsArr.length > 0;
  5754. const hasCategory = categoryArr.length > 0;
  5755. const secondKind = summary ? "summary" : hasTags ? "tags" : "";
  5756. const hasSecond = !!secondKind;
  5757. const thirdKind = objNum ? "objNum" : hasCategory ? "category" : "";
  5758. const hasThird = !!thirdKind;
  5759. const thirdFull = !hasSecond && hasThird;
  5760. const secondFull = hasSecond && !hasThird && secondKind === "tags";
  5761. const toValueText = (obj) => {
  5762. // 功能说明:类目/物品参数回显展示 key: value(否则只显示值看不懂) by xu 20260115
  5763. const [k, v] = Object.entries(obj || {})[0] || ["", ""];
  5764. const key = k !== undefined && k !== null ? String(k).trim() : "";
  5765. const val = v !== undefined && v !== null ? String(v).trim() : "";
  5766. if (key && val) return key + ":" + val;
  5767. if (val) return val;
  5768. if (key) return key;
  5769. return "";
  5770. };
  5771. const toLineList = (arr) =>
  5772. (arr || [])
  5773. .map(toValueText)
  5774. .map((s) => String(s ?? "").trim())
  5775. .filter(Boolean);
  5776. const secondTagsMaxLines = secondFull ? 4 : 3;
  5777. const secondTagsLinesFull = toLineList(tagsArr);
  5778. const secondTagsHead = secondTagsLinesFull.slice(
  5779. 0,
  5780. Math.max(0, secondTagsMaxLines - 1)
  5781. );
  5782. const secondTagsTail = secondTagsLinesFull.slice(
  5783. Math.max(0, secondTagsMaxLines - 1)
  5784. );
  5785. const secondTagsLast =
  5786. secondTagsTail.length <= 1
  5787. ? secondTagsTail[0] || ""
  5788. : secondTagsTail.join(" ");
  5789. const categoryLinesFull = toLineList(categoryArr);
  5790. const categoryLine = categoryLinesFull.join(" ");
  5791. const thirdText =
  5792. thirdKind === "objNum"
  5793. ? objNum
  5794. : thirdKind === "category"
  5795. ? categoryLine
  5796. : "";
  5797. return {
  5798. secondKind,
  5799. thirdKind,
  5800. hasSecond,
  5801. hasThird,
  5802. thirdFull,
  5803. secondFull,
  5804. summary,
  5805. secondTagsMaxLines,
  5806. secondTagsHead,
  5807. secondTagsLast,
  5808. secondTagsLinesFull,
  5809. objNum,
  5810. categoryLine,
  5811. categoryLinesFull,
  5812. thirdText,
  5813. };
  5814. },
  5815. measureTextOverflowByLines(text, maxLines, width) {
  5816. const w = Number(width) || 0;
  5817. if (!w || !text) return false;
  5818. const probe = document.createElement("div");
  5819. probe.style.position = "fixed";
  5820. probe.style.left = "-99999px";
  5821. probe.style.top = "0";
  5822. probe.style.width = w + "px";
  5823. probe.style.fontSize = "18px";
  5824. probe.style.lineHeight = "24px";
  5825. probe.style.whiteSpace = "normal";
  5826. probe.style.wordBreak = "break-word";
  5827. probe.style.visibility = "hidden";
  5828. probe.textContent = text;
  5829. document.body.appendChild(probe);
  5830. const h = probe.getBoundingClientRect().height || 0;
  5831. document.body.removeChild(probe);
  5832. return h > maxLines * 24 + 1;
  5833. },
  5834. measureSingleLineOverflow(text, width) {
  5835. const w = Number(width) || 0;
  5836. if (!w || !text) return false;
  5837. const probe = document.createElement("span");
  5838. probe.style.position = "fixed";
  5839. probe.style.left = "-99999px";
  5840. probe.style.top = "0";
  5841. probe.style.display = "inline-block";
  5842. probe.style.maxWidth = w + "px";
  5843. probe.style.fontSize = "18px";
  5844. probe.style.lineHeight = "24px";
  5845. probe.style.whiteSpace = "nowrap";
  5846. probe.style.visibility = "hidden";
  5847. probe.textContent = text;
  5848. document.body.appendChild(probe);
  5849. const overflow =
  5850. (probe.scrollWidth || 0) > (probe.clientWidth || w) + 1;
  5851. document.body.removeChild(probe);
  5852. return overflow;
  5853. },
  5854. refreshEllipsisVisible() {
  5855. // 功能:刷新「是否出现 ...」状态(用于控制命中区显示) by xu 20260115
  5856. try {
  5857. const right = this.$el?.querySelector?.(".right");
  5858. const rawWidth =
  5859. right?.getBoundingClientRect?.().width || right?.clientWidth || 0;
  5860. const width = Math.max(0, Math.round(rawWidth));
  5861. const model = this.buildRightTextLines();
  5862. const next = {
  5863. secondSummary: false,
  5864. secondTags: false,
  5865. third: false,
  5866. thirdFull: false,
  5867. };
  5868. if (model.secondKind === "summary" && model.summary) {
  5869. next.secondSummary = this.measureTextOverflowByLines(
  5870. model.summary,
  5871. 3,
  5872. width
  5873. );
  5874. }
  5875. if (model.secondKind === "tags") {
  5876. next.secondTags = this.measureSingleLineOverflow(
  5877. model.secondTagsLast,
  5878. width
  5879. ); // 功能说明:tags 仅看最后一行是否溢出 by xu 20260115
  5880. }
  5881. if (model.hasThird && !model.thirdFull) {
  5882. next.third = this.measureSingleLineOverflow(model.thirdText, width);
  5883. }
  5884. if (model.hasThird && model.thirdFull) {
  5885. next.thirdFull = this.measureTextOverflowByLines(
  5886. model.thirdText,
  5887. 4,
  5888. width
  5889. );
  5890. }
  5891. const prev = this.ellipsisVisible || {};
  5892. const changed =
  5893. prev.secondSummary !== next.secondSummary ||
  5894. prev.secondTags !== next.secondTags ||
  5895. prev.third !== next.third ||
  5896. prev.thirdFull !== next.thirdFull;
  5897. if (changed) this.ellipsisVisible = next;
  5898. } catch (e) {
  5899. // ignore by xu 20260115
  5900. }
  5901. },
  5902. clearHideTextPopoverTimer() {
  5903. if (this.hideTextPopoverTimer) {
  5904. clearTimeout(this.hideTextPopoverTimer);
  5905. this.hideTextPopoverTimer = null;
  5906. }
  5907. },
  5908. hideTextPopoverLater() {
  5909. this.clearHideTextPopoverTimer();
  5910. this.hideTextPopoverTimer = setTimeout(() => {
  5911. this.showTextPopover = false;
  5912. this.textPopoverType = "";
  5913. this.textPopoverPayload = null;
  5914. }, 120);
  5915. },
  5916. showTextPopoverFor(el, kind) {
  5917. const model = this.buildRightTextLines();
  5918. const lineEl = el?.closest?.(".ss-card-text__line") || el;
  5919. const right = lineEl?.closest?.(".right") || el?.closest?.(".right");
  5920. const rawWidth =
  5921. right?.getBoundingClientRect?.().width || right?.clientWidth || 0;
  5922. const width = Math.max(0, Math.round(rawWidth));
  5923. const overflowed =
  5924. kind === "second-summary"
  5925. ? this.measureTextOverflowByLines(model.summary, 3, width)
  5926. : kind === "second-tags"
  5927. ? this.measureSingleLineOverflow(model.secondTagsLast, width)
  5928. : kind === "third"
  5929. ? this.measureSingleLineOverflow(model.thirdText, width)
  5930. : this.measureTextOverflowByLines(model.thirdText, 4, width);
  5931. if (!overflowed) return;
  5932. let payload = null;
  5933. if (kind === "second-summary") {
  5934. if (model.summary) payload = { kind, text: model.summary };
  5935. } else if (kind === "second-tags") {
  5936. if (
  5937. Array.isArray(model.secondTagsLinesFull) &&
  5938. model.secondTagsLinesFull.length
  5939. ) {
  5940. payload = { kind, lines: model.secondTagsLinesFull };
  5941. }
  5942. } else if (kind === "third") {
  5943. if (
  5944. model.thirdKind === "category" &&
  5945. Array.isArray(model.categoryLinesFull) &&
  5946. model.categoryLinesFull.length
  5947. ) {
  5948. payload = { kind, lines: model.categoryLinesFull };
  5949. } else if (model.thirdText) {
  5950. payload = { kind, text: model.thirdText };
  5951. }
  5952. } else if (kind === "third-full") {
  5953. if (
  5954. model.thirdKind === "category" &&
  5955. Array.isArray(model.categoryLinesFull) &&
  5956. model.categoryLinesFull.length
  5957. ) {
  5958. payload = { kind, lines: model.categoryLinesFull };
  5959. } else if (model.thirdText) {
  5960. payload = { kind, text: model.thirdText };
  5961. }
  5962. }
  5963. if (!payload) return;
  5964. this.clearHideTextPopoverTimer();
  5965. const container = lineEl?.closest?.(".right");
  5966. const containerRect = container?.getBoundingClientRect?.();
  5967. const lineRect = lineEl?.getBoundingClientRect?.();
  5968. if (containerRect && lineRect) {
  5969. const bottom = Math.max(
  5970. 0,
  5971. Math.round(containerRect.bottom - lineRect.bottom)
  5972. );
  5973. this.textPopoverBottom = bottom;
  5974. } else {
  5975. this.textPopoverBottom = 0;
  5976. }
  5977. this.textPopoverPayload = payload;
  5978. this.textPopoverType = kind;
  5979. this.showTextPopover = true;
  5980. },
  5981. },
  5982. mounted() {
  5983. this.$nextTick?.(() => {
  5984. requestAnimationFrame(() => this.refreshEllipsisVisible?.());
  5985. });
  5986. this.__ssCObjCardResizeHandler = () => this.refreshEllipsisVisible?.(); // 功能说明:窗口变化时刷新 ... 显示 by xu 20260115
  5987. window.addEventListener?.("resize", this.__ssCObjCardResizeHandler);
  5988. },
  5989. updated() {
  5990. this.$nextTick?.(() => {
  5991. requestAnimationFrame(() => this.refreshEllipsisVisible?.());
  5992. });
  5993. },
  5994. beforeUnmount() {
  5995. this.clearHideTextPopoverTimer?.();
  5996. if (this.__ssCObjCardResizeHandler) {
  5997. window.removeEventListener?.("resize", this.__ssCObjCardResizeHandler);
  5998. this.__ssCObjCardResizeHandler = null;
  5999. }
  6000. },
  6001. render() {
  6002. const SsCartListIcon = Vue.resolveComponent("ss-cart-list-icon");
  6003. const SsIcon = Vue.resolveComponent("ss-icon");
  6004. const hasThumbArea = !!(this.item?.thumb || this.item?.thumbType);
  6005. const thumbSrc = (() => {
  6006. // 功能说明:兼容 thumb 为 raw path 或 {val}/{value},组件内统一转为 dlByHttp URL by xu 20260122
  6007. const t = this.item?.thumb;
  6008. if (!t) return "";
  6009. if (typeof t === "string") {
  6010. const s = t.trim();
  6011. if (!s) return "";
  6012. if (
  6013. /^https?:\/\//i.test(s) ||
  6014. s.startsWith("/service?") ||
  6015. s.startsWith("/")
  6016. )
  6017. return s;
  6018. return buildThumbUrl(s);
  6019. }
  6020. return buildThumbUrl(t);
  6021. })();
  6022. return Vue.h(
  6023. "div",
  6024. {
  6025. class: {
  6026. "knowledge-item-container": true,
  6027. active: this.item.active,
  6028. [this.cardType]: !!this.cardType,
  6029. [this.statusClass]: !!this.statusClass,
  6030. },
  6031. onClick: (e) => this.onItemClick?.(e), // 功能说明:二级对象卡片点击仅查看 by xu 20260115
  6032. },
  6033. [
  6034. this.item?.statusIcons?.length > 0 &&
  6035. Vue.h(
  6036. "div",
  6037. { class: "card-status-icons" },
  6038. this.item.statusIcons.map((icon) =>
  6039. Vue.h(SsIcon, {
  6040. class: "status-icon " + icon.class,
  6041. title: icon.title,
  6042. })
  6043. )
  6044. ),
  6045. this.item?.buttons?.length > 0 && this.dataType !== "play" &&
  6046. Vue.h(
  6047. "div",
  6048. {
  6049. class: "header",
  6050. style:
  6051. this.item?.statusIcons?.length > 0
  6052. ? {
  6053. right: String(this.item.statusIcons.length * 48) + "px",
  6054. borderTopRightRadius: "0",
  6055. }
  6056. : {},
  6057. onMouseenter: () => (this.showButtons = true),
  6058. onMouseleave: () => (this.showButtons = false),
  6059. onClick: (e) => this.onItemChange(e),
  6060. },
  6061. [
  6062. Vue.h("div", {
  6063. class: "cart-list-setting cart-list-icon",
  6064. title: this.item?.buttons?.[0]?.title,
  6065. }),
  6066. this.showButtons &&
  6067. this.item?.buttons?.length > 1 &&
  6068. Vue.h(
  6069. "div",
  6070. { class: "cart-list-button-popup" },
  6071. this.item.buttons.map((btn) =>
  6072. Vue.h(
  6073. "div",
  6074. {
  6075. onClick: (e) => {
  6076. e.stopPropagation();
  6077. btn.onclick?.();
  6078. },
  6079. },
  6080. [
  6081. btn.class &&
  6082. Vue.h(SsCartListIcon, { class: [btn.class] }),
  6083. Vue.h("span", null, btn.title),
  6084. ]
  6085. )
  6086. )
  6087. ),
  6088. ]
  6089. ),
  6090. Vue.h("div", { class: "body" }, [
  6091. Vue.h("div", { class: "box-header" }, [
  6092. Vue.h("div", String(this.item.title || "")),
  6093. ]),
  6094. Vue.h(
  6095. "div",
  6096. { class: !hasThumbArea ? "no-thumb box-body" : "box-body" },
  6097. [
  6098. hasThumbArea
  6099. ? thumbSrc
  6100. ? Vue.h("div", { class: "left" }, [
  6101. Vue.h("img", {
  6102. src: thumbSrc,
  6103. alt: "Thumbnail",
  6104. class: "imgUnHandle",
  6105. style: {
  6106. "object-fit": "cover",
  6107. width: "100%",
  6108. height: "100%",
  6109. },
  6110. }),
  6111. ])
  6112. : Vue.h(
  6113. "div",
  6114. { class: "left ss-objlist-thumbPlaceholder" },
  6115. [
  6116. Vue.h(SsIcon, {
  6117. class:
  6118. this.getBizThumbIconClass() +
  6119. " ss-objlist-thumbIcon",
  6120. }),
  6121. ]
  6122. )
  6123. : null,
  6124. Vue.h(
  6125. "div",
  6126. { class: "right" },
  6127. (() => {
  6128. const model = this.buildRightTextLines();
  6129. const hasAny = !!(model?.hasSecond || model?.hasThird);
  6130. if (!hasAny) return [];
  6131. const children = [];
  6132. if (model.hasSecond && model.secondKind === "summary") {
  6133. children.push(
  6134. Vue.h(
  6135. "div",
  6136. {
  6137. class:
  6138. "ss-card-text__line ss-card-text__secondBlock",
  6139. },
  6140. [
  6141. Vue.h(
  6142. "div",
  6143. {
  6144. class: "ss-card-text__secondSummary",
  6145. title: model.summary,
  6146. },
  6147. model.summary
  6148. ),
  6149. Vue.h("span", {
  6150. class: [
  6151. "ss-card-text__ellipsisHit",
  6152. "ss-card-text__ellipsisHit--second",
  6153. this.ellipsisVisible?.secondSummary
  6154. ? "is-on"
  6155. : "",
  6156. ],
  6157. title: "查看完整信息",
  6158. onMouseenter: (e) =>
  6159. this.showTextPopoverFor(
  6160. e?.currentTarget,
  6161. "second-summary"
  6162. ),
  6163. onClick: (e) => {
  6164. e?.stopPropagation?.();
  6165. this.showTextPopoverFor(
  6166. e?.currentTarget,
  6167. "second-summary"
  6168. );
  6169. },
  6170. onMouseleave: () => this.hideTextPopoverLater(),
  6171. }),
  6172. ]
  6173. )
  6174. );
  6175. }
  6176. if (model.hasSecond && model.secondKind === "tags") {
  6177. children.push(
  6178. Vue.h(
  6179. "div",
  6180. {
  6181. class: [
  6182. "ss-card-text__line",
  6183. model.secondFull
  6184. ? "ss-card-text__secondFullBlock"
  6185. : "ss-card-text__secondBlock",
  6186. ],
  6187. },
  6188. [
  6189. Vue.h(
  6190. "div",
  6191. { class: "ss-card-text__secondTags" },
  6192. [
  6193. ...model.secondTagsHead.map((t) =>
  6194. Vue.h(
  6195. "div",
  6196. {
  6197. class: "ss-card-text__tagLine",
  6198. title: t,
  6199. },
  6200. t
  6201. )
  6202. ),
  6203. Vue.h(
  6204. "div",
  6205. {
  6206. class:
  6207. "ss-card-text__tagLine is-last ss-card-text__tagLineLast",
  6208. title: model.secondTagsLast,
  6209. },
  6210. model.secondTagsLast
  6211. ),
  6212. ]
  6213. ),
  6214. Vue.h("span", {
  6215. class: [
  6216. "ss-card-text__ellipsisHit",
  6217. "ss-card-text__ellipsisHit--second",
  6218. this.ellipsisVisible?.secondTags ? "is-on" : "",
  6219. ],
  6220. title: "查看完整信息",
  6221. onMouseenter: (e) =>
  6222. this.showTextPopoverFor(
  6223. e?.currentTarget,
  6224. "second-tags"
  6225. ),
  6226. onClick: (e) => {
  6227. e?.stopPropagation?.();
  6228. this.showTextPopoverFor(
  6229. e?.currentTarget,
  6230. "second-tags"
  6231. );
  6232. },
  6233. onMouseleave: () => this.hideTextPopoverLater(),
  6234. }),
  6235. ]
  6236. )
  6237. );
  6238. }
  6239. if (model.hasThird) {
  6240. if (model.thirdFull) {
  6241. children.push(
  6242. Vue.h(
  6243. "div",
  6244. {
  6245. class:
  6246. "ss-card-text__line ss-card-text__thirdFullBlock",
  6247. },
  6248. [
  6249. Vue.h(
  6250. "div",
  6251. {
  6252. class: "ss-card-text__thirdFull",
  6253. title: model.thirdText,
  6254. },
  6255. model.thirdText
  6256. ),
  6257. Vue.h("span", {
  6258. class: [
  6259. "ss-card-text__ellipsisHit",
  6260. "ss-card-text__ellipsisHit--third",
  6261. this.ellipsisVisible?.thirdFull
  6262. ? "is-on"
  6263. : "",
  6264. ],
  6265. title: "查看完整信息",
  6266. onMouseenter: (e) =>
  6267. this.showTextPopoverFor(
  6268. e?.currentTarget,
  6269. "third-full"
  6270. ),
  6271. onClick: (e) => {
  6272. e?.stopPropagation?.();
  6273. this.showTextPopoverFor(
  6274. e?.currentTarget,
  6275. "third-full"
  6276. );
  6277. },
  6278. onMouseleave: () => this.hideTextPopoverLater(),
  6279. }),
  6280. ]
  6281. )
  6282. );
  6283. } else {
  6284. children.push(
  6285. Vue.h(
  6286. "div",
  6287. {
  6288. class:
  6289. "ss-card-text__line ss-card-text__thirdLineWrap",
  6290. },
  6291. [
  6292. Vue.h(
  6293. "div",
  6294. {
  6295. class: "ss-card-text__thirdLine",
  6296. title: model.thirdText,
  6297. },
  6298. model.thirdText
  6299. ),
  6300. Vue.h("span", {
  6301. class: [
  6302. "ss-card-text__ellipsisHit",
  6303. "ss-card-text__ellipsisHit--third",
  6304. this.ellipsisVisible?.third ? "is-on" : "",
  6305. ],
  6306. title: "查看完整信息",
  6307. onMouseenter: (e) =>
  6308. this.showTextPopoverFor(
  6309. e?.currentTarget,
  6310. "third"
  6311. ),
  6312. onClick: (e) => {
  6313. e?.stopPropagation?.();
  6314. this.showTextPopoverFor(
  6315. e?.currentTarget,
  6316. "third"
  6317. );
  6318. },
  6319. onMouseleave: () => this.hideTextPopoverLater(),
  6320. }),
  6321. ]
  6322. )
  6323. );
  6324. }
  6325. }
  6326. const popover =
  6327. this.showTextPopover &&
  6328. Vue.h(
  6329. "div",
  6330. {
  6331. class: "ss-card-text-popover",
  6332. style: { bottom: this.textPopoverBottom + "px" },
  6333. onMouseenter: () => {
  6334. this.clearHideTextPopoverTimer();
  6335. this.showTextPopover = true;
  6336. },
  6337. onMouseleave: () => this.hideTextPopoverLater(),
  6338. },
  6339. (() => {
  6340. const p = this.textPopoverPayload || {};
  6341. if (p.kind === "second-summary" && p.text) {
  6342. return [
  6343. Vue.h(
  6344. "div",
  6345. { class: "ss-card-text-popover__summary" },
  6346. p.text
  6347. ),
  6348. ];
  6349. }
  6350. if (Array.isArray(p.lines)) {
  6351. return [
  6352. Vue.h(
  6353. "div",
  6354. { class: "ss-card-text-popover__kvlist" },
  6355. p.lines.map((t) =>
  6356. Vue.h(
  6357. "div",
  6358. { class: "ss-card-text-popover__kv" },
  6359. t
  6360. )
  6361. )
  6362. ),
  6363. ];
  6364. }
  6365. if (
  6366. (p.kind === "third" || p.kind === "third-full") &&
  6367. p.text
  6368. ) {
  6369. return [
  6370. Vue.h(
  6371. "div",
  6372. { class: "ss-card-text-popover__objno" },
  6373. p.text
  6374. ),
  6375. ];
  6376. }
  6377. return [];
  6378. })()
  6379. );
  6380. return [
  6381. Vue.h("div", { class: "ss-card-text" }, children),
  6382. popover,
  6383. ];
  6384. })()
  6385. ),
  6386. ]
  6387. ),
  6388. ]),
  6389. ]
  6390. );
  6391. },
  6392. };
  6393. // ss-sidebar 右侧边栏(容器 + 子组件),用于 objList 右侧区域 by xu 20260106
  6394. // 组件文档补全(JSDoc) by xu 20260108
  6395. /**
  6396. * SsSidebarButtons(右侧边栏顶部按钮栏)
  6397. *
  6398. * 用途:
  6399. * - 渲染 objList 右侧顶部快捷操作(预定/入住/退房/清洁...)
  6400. * - 内部复用 `ss-search-button`(项目现有按钮样式/交互)
  6401. *
  6402. * 调用示例:
  6403. * ```html
  6404. * <ss-sidebar-buttons :items="sidebarButtons" />
  6405. * ```
  6406. *
  6407. * Props:
  6408. * - `items`: 按钮配置数组
  6409. * - `{ id, text, icon?, onClick? }`
  6410. *
  6411. * Emits:
  6412. * - `click`:点击按钮时触发,参数为按钮对象
  6413. */
  6414. const SsSidebarButtons = {
  6415. name: "SsSidebarButtons",
  6416. props: {
  6417. items: { type: Array, default: () => [] },
  6418. },
  6419. emits: ["click"],
  6420. render() {
  6421. const SsSearchButton = Vue.resolveComponent("ss-search-button");
  6422. const items = this.items || [];
  6423. if (!items.length) return null;
  6424. return Vue.h(
  6425. "div",
  6426. { class: "ss-sidebar-actions" },
  6427. items.map((btn) =>
  6428. // 顶部操作按钮复用 ss-search-button(先 mock 固定按钮) by xu 20260106
  6429. Vue.h(SsSearchButton, {
  6430. text: btn?.text ?? "",
  6431. iconClass: btn?.iconClass ?? "",
  6432. opt: btn?.opt ?? [],
  6433. checkId: btn?.checkId ?? "0",
  6434. width: btn?.width,
  6435. id: btn?.id,
  6436. onClick: (e) => {
  6437. e?.stopPropagation?.();
  6438. btn?.onClick?.(btn);
  6439. this.$emit("click", btn);
  6440. },
  6441. })
  6442. )
  6443. );
  6444. },
  6445. };
  6446. // 组件文档补全(JSDoc) by xu 20260108
  6447. /**
  6448. * SsSidebarChart(ECharts 容器渲染)
  6449. *
  6450. * 用途:
  6451. * - 仅负责 echarts init / setOption / resize / dispose
  6452. * - 被 `ss-sidebar-chart-hover` 与图表面板复用
  6453. *
  6454. * 调用示例:
  6455. * ```html
  6456. * <ss-sidebar-chart :options="option" height="220px" />
  6457. * ```
  6458. *
  6459. * Props:
  6460. * - `options`:ECharts option(Object)
  6461. * - `height`:容器高度(String)
  6462. */
  6463. const SsSidebarChart = {
  6464. name: "SsSidebarChart",
  6465. props: {
  6466. options: { type: Object, default: () => ({}) },
  6467. height: { type: String, default: "200px" },
  6468. },
  6469. setup(props) {
  6470. const elRef = Vue.ref(null);
  6471. let chart = null;
  6472. const renderChart = () => {
  6473. if (!elRef.value || !window.echarts) return;
  6474. if (!chart) {
  6475. chart = window.echarts.init(elRef.value);
  6476. }
  6477. chart.setOption(props.options || {}, true);
  6478. };
  6479. const resizeChart = () => {
  6480. chart?.resize?.();
  6481. };
  6482. Vue.onMounted(() => {
  6483. renderChart();
  6484. window.addEventListener("resize", resizeChart);
  6485. });
  6486. Vue.onBeforeUnmount(() => {
  6487. window.removeEventListener("resize", resizeChart);
  6488. chart?.dispose?.();
  6489. chart = null;
  6490. });
  6491. Vue.watch(
  6492. () => props.options,
  6493. () => {
  6494. renderChart();
  6495. },
  6496. { deep: true }
  6497. );
  6498. return { elRef };
  6499. },
  6500. render() {
  6501. return Vue.h("div", {
  6502. ref: "elRef",
  6503. style: {
  6504. width: "100%",
  6505. height: this.height,
  6506. // 图表容器不加 padding/border,由外层布局控制 by xu 20260106
  6507. background: "transparent",
  6508. border: "none",
  6509. "border-radius": "0",
  6510. },
  6511. });
  6512. },
  6513. };
  6514. // ss-sidebar-chart-hover:hover 弹出左侧大图(支持图钉/全屏) by xu 20260106
  6515. // 组件文档补全(JSDoc) by xu 20260108
  6516. /**
  6517. * SsSidebarChartHover(小图 + hover 左侧大图预览 + 图钉固定 + 全屏)
  6518. *
  6519. * 用途:
  6520. * - 右侧统计图小卡片:hover 时在左侧弹出大图预览
  6521. * - 预览头部:左侧图标+标题;右侧固定/全屏按钮(icon-base)
  6522. * - 全屏:方案A(浏览器 Fullscreen API)
  6523. *
  6524. * 调用示例(由 ss-sidebar chart panel 内部调用):
  6525. * ```html
  6526. * <ss-sidebar-chart-hover
  6527. * title="校舍建筑面积和总体分布"
  6528. * icon-class="menu-icon icon-obj-jzw"
  6529. * :options="option"
  6530. * height="220px"
  6531. * />
  6532. * ```
  6533. *
  6534. * Props:
  6535. * - `title/iconClass/icon`:用于预览/全屏 header 显示(与面板 header 一致)
  6536. * - `options`:ECharts option
  6537. * - `height`:小图高度
  6538. * - `previewWidth/previewHeight`:预览建议尺寸(会按视口自适应)
  6539. */
  6540. const SsSidebarChartHover = {
  6541. name: "SsSidebarChartHover",
  6542. props: {
  6543. // hover 大图标题/图标(与小图面板 header 一致) by xu 20260108
  6544. title: { type: String, default: "" },
  6545. iconClass: { type: String, default: "" },
  6546. icon: { type: String, default: "" },
  6547. options: { type: Object, default: () => ({}) },
  6548. height: { type: String, default: "220px" },
  6549. // hover 弹窗建议尺寸:默认 1000x650(比例由逻辑统一管控),实际渲染会按比例自适应视口 by xu 20260115
  6550. previewWidth: { type: Number, default: 1000 },
  6551. previewHeight: { type: Number, default: 650 },
  6552. },
  6553. setup(props) {
  6554. const triggerRef = Vue.ref(null);
  6555. const fullscreenRef = Vue.ref(null);
  6556. const open = Vue.ref(false);
  6557. const pinned = Vue.ref(false);
  6558. const fullscreen = Vue.ref(false);
  6559. const hoveringTrigger = Vue.ref(false);
  6560. const hoveringPreview = Vue.ref(false);
  6561. const previewStyle = Vue.ref({});
  6562. let closeTimer = null;
  6563. const updatePreviewPosition = () => {
  6564. const el = triggerRef.value;
  6565. if (!el) return;
  6566. const rect = el.getBoundingClientRect();
  6567. // 功能说明:优先使用 visualViewport(避免浏览器 UI/缩放导致可视区与 innerHeight 偏差,出现预览被遮挡约 70px) by xu 20260116
  6568. const docEl = document.documentElement;
  6569. const vv = window.visualViewport;
  6570. let viewportLeft = Number(vv?.offsetLeft ?? 0) || 0;
  6571. let viewportTop = Number(vv?.offsetTop ?? 0) || 0;
  6572. let vw =
  6573. Number(vv?.width ?? 0) ||
  6574. Number(docEl?.clientWidth || 0) ||
  6575. window.innerWidth;
  6576. let vh =
  6577. Number(vv?.height ?? 0) ||
  6578. Number(docEl?.clientHeight || 0) ||
  6579. window.innerHeight;
  6580. // 功能说明:若页面在 iframe 内,父页面可能裁切 iframe 可见区域(overflow/弹窗容器),需要用“iframe可见区域”做二次约束 by xu 20260116
  6581. try {
  6582. const inIframe = window.top && window.top !== window;
  6583. const frameEl = window.frameElement;
  6584. if (inIframe && frameEl && window.top?.document) {
  6585. const topVv = window.top.visualViewport;
  6586. const topDocEl = window.top.document.documentElement;
  6587. const topVw =
  6588. Number(topVv?.width ?? 0) ||
  6589. Number(topDocEl?.clientWidth || 0) ||
  6590. window.top.innerWidth;
  6591. const topVh =
  6592. Number(topVv?.height ?? 0) ||
  6593. Number(topDocEl?.clientHeight || 0) ||
  6594. window.top.innerHeight;
  6595. const fr = frameEl.getBoundingClientRect?.();
  6596. if (fr && fr.width > 0 && fr.height > 0) {
  6597. const visibleW = Math.max(
  6598. 0,
  6599. Math.min(fr.right, topVw) - Math.max(fr.left, 0)
  6600. );
  6601. const visibleH = Math.max(
  6602. 0,
  6603. Math.min(fr.bottom, topVh) - Math.max(fr.top, 0)
  6604. );
  6605. if (visibleW > 0) {
  6606. vw = Math.min(vw, visibleW);
  6607. viewportLeft = Math.max(0, -fr.left); // iframe内坐标系偏移(左侧被裁切时) by xu 20260116
  6608. }
  6609. if (visibleH > 0) {
  6610. vh = Math.min(vh, visibleH);
  6611. viewportTop = Math.max(0, -fr.top); // iframe内坐标系偏移(顶部被裁切时) by xu 20260116
  6612. }
  6613. }
  6614. }
  6615. } catch (_) {}
  6616. // 预览窗尺寸:优先保证“完整可见”,其次再尽量对齐右侧 header 顶部 by xu 20260116
  6617. const viewportPaddingX = 40;
  6618. const viewportPaddingTop = 20;
  6619. const viewportPaddingBottom = 10;
  6620. // 功能说明:hover 预览框不要覆盖右侧栏,优先放在 ss-sidebar 左侧;必要时动态缩小宽度 by xu 20260115
  6621. const sidebarEl = el.closest ? el.closest(".ss-sidebar") : null;
  6622. const sidebarRect = sidebarEl?.getBoundingClientRect?.();
  6623. const maxWidthByViewport = Math.max(240, vw - viewportPaddingX);
  6624. const maxWidthByLeftSpace = sidebarRect
  6625. ? Math.max(
  6626. 240,
  6627. sidebarRect.left - viewportPaddingX - 14 /* gapFromSidebar */
  6628. )
  6629. : maxWidthByViewport;
  6630. // 功能说明:预览框尺寸按比例(默认 5:3)缩放,并提供最大/最小值约束 by xu 20260115
  6631. const ratio = 3 / 5;
  6632. const minWidth = 320;
  6633. const minHeight = 240;
  6634. const maxHeightByViewport = Math.max(
  6635. minHeight,
  6636. vh - viewportPaddingTop - viewportPaddingBottom
  6637. );
  6638. const maxWidthByProp = Number(props.previewWidth) || 1000;
  6639. const maxHeightByProp = Number(props.previewHeight) || 650;
  6640. // 优先按高度撑满可视区(保证预览完整可见),再根据左侧可用宽度回退 by xu 20260116
  6641. const maxHeight = Math.min(maxHeightByProp, maxHeightByViewport);
  6642. let height = Math.max(minHeight, maxHeight);
  6643. let width = Math.round(height / ratio);
  6644. width = Math.min(
  6645. width,
  6646. maxWidthByProp,
  6647. maxWidthByViewport,
  6648. maxWidthByLeftSpace
  6649. );
  6650. width = Math.max(minWidth, width);
  6651. height = Math.round(width * ratio);
  6652. if (height > maxHeight) {
  6653. height = maxHeight;
  6654. width = Math.round(height / ratio);
  6655. }
  6656. // 默认贴着小图左侧弹出,右边缘与小图左边缘轻微重叠,避免 1px 缝隙导致 hover 闪断 by xu 20260108
  6657. const overlap = 2;
  6658. const gapFromSidebar = 14; // 功能说明:弹窗与右侧边栏留出距离(更不贴近) by xu 20260108
  6659. // 优先:贴在 sidebar 左侧(不压住右侧栏内容) by xu 20260115
  6660. let left = sidebarRect
  6661. ? sidebarRect.left - gapFromSidebar - width + overlap
  6662. : rect.left - width - gapFromSidebar + overlap;
  6663. // 如果左侧空间不足,则贴右侧(兜底,同样重叠) by xu 20260108
  6664. if (left < 0) left = rect.right + gapFromSidebar - overlap;
  6665. left = Math.max(
  6666. viewportLeft,
  6667. Math.min(left, viewportLeft + vw - width)
  6668. );
  6669. // top:优先保证完整可见,然后才贴近 header 顶部 by xu 20260116
  6670. let headerEl = el;
  6671. while (headerEl && !headerEl.classList?.contains("ss-sidebar-panel")) {
  6672. headerEl = headerEl.parentElement;
  6673. }
  6674. let headerRect = headerEl
  6675. ?.querySelector(".ss-sidebar-panel__header")
  6676. ?.getBoundingClientRect();
  6677. let top = headerRect?.top ?? rect.top;
  6678. top = Math.max(
  6679. viewportTop + viewportPaddingTop,
  6680. Math.min(top, viewportTop + vh - height - viewportPaddingBottom)
  6681. );
  6682. previewStyle.value = {
  6683. position: "fixed",
  6684. left: `${Math.round(left)}px`,
  6685. top: `${Math.round(top)}px`,
  6686. width: `${width}px`,
  6687. height: `${height}px`,
  6688. zIndex: 2147483647, // 功能说明:提高层级到接近浏览器上限,避免仍被页面固定栏/弹窗遮挡 by xu 20260116
  6689. };
  6690. };
  6691. const clearCloseTimer = () => {
  6692. if (closeTimer) {
  6693. clearTimeout(closeTimer);
  6694. closeTimer = null;
  6695. }
  6696. };
  6697. const scheduleClose = () => {
  6698. clearCloseTimer();
  6699. if (pinned.value || fullscreen.value) return;
  6700. if (hoveringTrigger.value || hoveringPreview.value) return; // 功能:鼠标在小图/大图之间移动不关闭 by xu 20260108
  6701. closeTimer = setTimeout(() => {
  6702. open.value = false;
  6703. }, 100);
  6704. };
  6705. const openPreview = () => {
  6706. clearCloseTimer();
  6707. updatePreviewPosition();
  6708. open.value = true;
  6709. };
  6710. const togglePin = () => {
  6711. pinned.value = !pinned.value;
  6712. if (pinned.value) {
  6713. open.value = true;
  6714. updatePreviewPosition();
  6715. }
  6716. };
  6717. const toggleFullscreen = () => {
  6718. // 全屏:采用浏览器 Fullscreen API(方案A),不使用遮罩弹窗 by xu 20260108
  6719. if (!fullscreen.value) {
  6720. open.value = false; // 避免同时渲染预览与全屏 by xu 20260108
  6721. fullscreen.value = true;
  6722. Vue.nextTick(() => {
  6723. const el = fullscreenRef.value;
  6724. if (el?.requestFullscreen) {
  6725. el.requestFullscreen().catch(() => {
  6726. // requestFullscreen 失败则回退为非全屏状态 by xu 20260108
  6727. fullscreen.value = false;
  6728. });
  6729. } else {
  6730. fullscreen.value = false;
  6731. }
  6732. });
  6733. } else {
  6734. if (document?.exitFullscreen) {
  6735. document.exitFullscreen().catch(() => {});
  6736. }
  6737. }
  6738. };
  6739. const handleFullscreenChange = () => {
  6740. const isFs = !!document.fullscreenElement;
  6741. fullscreen.value = isFs; // 功能说明:同步 ESC/系统退出全屏状态 by xu 20260108
  6742. if (isFs) {
  6743. open.value = false;
  6744. clearCloseTimer();
  6745. return;
  6746. }
  6747. // 退出全屏后:若固定或仍 hover,则恢复预览,否则关闭 by xu 20260108
  6748. if (pinned.value || hoveringTrigger.value || hoveringPreview.value) {
  6749. open.value = true;
  6750. updatePreviewPosition();
  6751. } else {
  6752. open.value = false;
  6753. }
  6754. };
  6755. Vue.onMounted(() => {
  6756. window.addEventListener("resize", updatePreviewPosition);
  6757. window.addEventListener("scroll", updatePreviewPosition, true);
  6758. document.addEventListener("fullscreenchange", handleFullscreenChange); // 功能说明:监听全屏状态变化 by xu 20260108
  6759. });
  6760. Vue.onBeforeUnmount(() => {
  6761. clearCloseTimer();
  6762. window.removeEventListener("resize", updatePreviewPosition);
  6763. window.removeEventListener("scroll", updatePreviewPosition, true);
  6764. document.removeEventListener(
  6765. "fullscreenchange",
  6766. handleFullscreenChange
  6767. );
  6768. });
  6769. return {
  6770. triggerRef,
  6771. fullscreenRef,
  6772. open,
  6773. pinned,
  6774. fullscreen,
  6775. hoveringTrigger,
  6776. hoveringPreview,
  6777. previewStyle,
  6778. openPreview,
  6779. scheduleClose,
  6780. clearCloseTimer,
  6781. togglePin,
  6782. toggleFullscreen,
  6783. };
  6784. },
  6785. render() {
  6786. const SsIcon = Vue.resolveComponent("ss-icon");
  6787. const Chart = Vue.resolveComponent("ss-sidebar-chart");
  6788. const hasHeader = !!(this.title || this.iconClass || this.icon); // 功能:hover 大图显示左侧图标+标题 by xu 20260108
  6789. const previewContent = Vue.h(
  6790. "div",
  6791. {
  6792. class: { "ss-sidebar-chart-preview": true, "is-pinned": this.pinned },
  6793. style: this.previewStyle,
  6794. onMouseenter: () => {
  6795. this.hoveringPreview = true;
  6796. this.clearCloseTimer();
  6797. },
  6798. onMouseleave: () => {
  6799. this.hoveringPreview = false;
  6800. this.scheduleClose();
  6801. },
  6802. },
  6803. [
  6804. hasHeader
  6805. ? Vue.h(
  6806. "div",
  6807. {
  6808. class:
  6809. "ss-sidebar-panel__header ss-sidebar-chart-preview__header",
  6810. },
  6811. [
  6812. Vue.h("div", { class: "ss-sidebar-panel__title" }, [
  6813. this.iconClass
  6814. ? Vue.h(SsIcon, {
  6815. class: this.iconClass + " ss-sidebar-panel__icon",
  6816. })
  6817. : this.icon
  6818. ? Vue.h(SsIcon, {
  6819. name: this.icon,
  6820. size: "16px",
  6821. class: "ss-sidebar-panel__icon",
  6822. })
  6823. : null,
  6824. Vue.h("span", null, this.title || "统计图"),
  6825. ]),
  6826. Vue.h("div", { class: "ss-sidebar-panel__tools" }, [
  6827. Vue.h(
  6828. "button",
  6829. {
  6830. type: "button",
  6831. class: {
  6832. "ss-sidebar-chart-tool": true,
  6833. "is-active": this.pinned,
  6834. },
  6835. title: this.pinned ? "取消固定" : "固定",
  6836. onClick: (e) => {
  6837. e.stopPropagation();
  6838. this.togglePin();
  6839. },
  6840. },
  6841. // 功能说明:右侧栏 hover 工具图标使用 ss-sidebar-base-icon(不复用左侧 menu-base-icon) by xu 20260123
  6842. [
  6843. Vue.h(SsIcon, {
  6844. class: this.pinned
  6845. ? "ss-sidebar-base-icon icon-fix-bold"
  6846. : "ss-sidebar-base-icon icon-fix",
  6847. }),
  6848. ]
  6849. ),
  6850. Vue.h(
  6851. "button",
  6852. {
  6853. type: "button",
  6854. class: "ss-sidebar-chart-tool",
  6855. title: "全屏",
  6856. onClick: (e) => {
  6857. e.stopPropagation();
  6858. this.toggleFullscreen();
  6859. },
  6860. },
  6861. [
  6862. Vue.h(SsIcon, {
  6863. class: this.fullscreen
  6864. ? "ss-sidebar-base-icon icon-fs-exit"
  6865. : "ss-sidebar-base-icon icon-fs",
  6866. }),
  6867. ]
  6868. ),
  6869. ]),
  6870. ]
  6871. )
  6872. : Vue.h(
  6873. "div",
  6874. {
  6875. class:
  6876. "ss-sidebar-chart-preview__header ss-sidebar-chart-preview__header--simple",
  6877. },
  6878. [
  6879. Vue.h("div", { class: "ss-sidebar-panel__tools" }, [
  6880. Vue.h(
  6881. "button",
  6882. {
  6883. type: "button",
  6884. class: {
  6885. "ss-sidebar-chart-tool": true,
  6886. "is-active": this.pinned,
  6887. },
  6888. title: this.pinned ? "取消固定" : "固定",
  6889. onClick: (e) => {
  6890. e.stopPropagation();
  6891. this.togglePin();
  6892. },
  6893. },
  6894. [
  6895. Vue.h(SsIcon, {
  6896. class: this.pinned
  6897. ? "ss-sidebar-base-icon icon-fix-bold"
  6898. : "ss-sidebar-base-icon icon-fix",
  6899. }),
  6900. ]
  6901. ),
  6902. Vue.h(
  6903. "button",
  6904. {
  6905. type: "button",
  6906. class: "ss-sidebar-chart-tool",
  6907. title: "全屏",
  6908. onClick: (e) => {
  6909. e.stopPropagation();
  6910. this.toggleFullscreen();
  6911. },
  6912. },
  6913. [
  6914. Vue.h(SsIcon, {
  6915. class: this.fullscreen
  6916. ? "ss-sidebar-base-icon icon-chk-on"
  6917. : "ss-sidebar-base-icon icon-chk",
  6918. }),
  6919. ]
  6920. ),
  6921. ]),
  6922. ]
  6923. ),
  6924. Vue.h("div", { class: "ss-sidebar-chart-preview__body" }, [
  6925. Vue.h(Chart, { options: this.options, height: "100%" }),
  6926. ]),
  6927. ]
  6928. );
  6929. const fullscreenContent =
  6930. this.fullscreen &&
  6931. Vue.h(
  6932. "div",
  6933. {
  6934. ref: "fullscreenRef",
  6935. class: "ss-sidebar-chart-fullscreen",
  6936. },
  6937. [
  6938. Vue.h(
  6939. "div",
  6940. {
  6941. class:
  6942. "ss-sidebar-panel__header ss-sidebar-chart-fullscreen__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. [
  6975. Vue.h(SsIcon, {
  6976. class: this.pinned
  6977. ? "ss-sidebar-base-icon icon-fix-bold"
  6978. : "ss-sidebar-base-icon icon-fix",
  6979. }),
  6980. ]
  6981. ),
  6982. Vue.h(
  6983. "button",
  6984. {
  6985. type: "button",
  6986. class: "ss-sidebar-chart-tool",
  6987. title: "退出全屏",
  6988. onClick: (e) => {
  6989. e.stopPropagation();
  6990. this.toggleFullscreen();
  6991. },
  6992. },
  6993. [
  6994. Vue.h(SsIcon, {
  6995. class: "ss-sidebar-base-icon icon-fs-exit",
  6996. }),
  6997. ]
  6998. ),
  6999. ]),
  7000. ]
  7001. ),
  7002. Vue.h("div", { class: "ss-sidebar-chart-fullscreen__body" }, [
  7003. Vue.h(Chart, { options: this.options, height: "100%" }),
  7004. ]),
  7005. ]
  7006. );
  7007. return Vue.h("div", { class: "ss-sidebar-chart-hover" }, [
  7008. Vue.h(
  7009. "div",
  7010. {
  7011. ref: "triggerRef",
  7012. class: "ss-sidebar-chart-hover__trigger",
  7013. onMouseenter: () => {
  7014. this.hoveringTrigger = true;
  7015. this.openPreview();
  7016. },
  7017. onMouseleave: () => {
  7018. this.hoveringTrigger = false;
  7019. this.scheduleClose();
  7020. },
  7021. },
  7022. [Vue.h(Chart, { options: this.options, height: this.height })]
  7023. ),
  7024. (this.open || this.fullscreen) &&
  7025. Vue.h(Vue.Teleport, { to: "body" }, [
  7026. this.open ? previewContent : null,
  7027. fullscreenContent || null,
  7028. ]),
  7029. ]);
  7030. },
  7031. };
  7032. // 组件文档补全(JSDoc) by xu 20260108
  7033. /**
  7034. * SsSidebarList(右侧业务面板:人员/已选/服务/预定...)
  7035. *
  7036. * 用途:
  7037. * - 统一渲染面板 header(图标/标题/数量/右侧按钮)
  7038. * - 统一渲染 list(固定行高、hover、右侧移除按钮等)
  7039. *
  7040. * 调用示例(由 ss-sidebar 通过 panels 配置驱动):
  7041. * ```js
  7042. * { type:'list', title:'已选', iconClass:'menu-icon icon-obj-xcd', mode:'selected', items:selectedItems, closable:true }
  7043. * ```
  7044. *
  7045. * Props(核心):
  7046. * - `title`:header 标题
  7047. * - `iconClass/icon`:header 图标(优先 iconClass)
  7048. * - `count`:数量回显(图表面板可不传)
  7049. * - `closable`:是否显示“清空”按钮(触发 emit clear)
  7050. * - `headerFilters`:header 条件数组(组件名 + props),用于联调接口搜索
  7051. * - `headerSearchButton`:是否显示搜索按钮(触发 emit search)
  7052. * - `items`:列表数据
  7053. * - `mode`:`selected` 时右侧按钮语义为“移除”
  7054. * - `itemLayout`:`simple` / `person`(人员号槽位)
  7055. * - `itemAction`:是否显示 item 右侧操作按钮(hover 才出现)
  7056. *
  7057. * Emits:
  7058. * - `remove(item)`:点击 item 右侧移除
  7059. * - `clear()`:点击 header 清空
  7060. * - `search({keyword, filters})`:点击 header 搜索
  7061. */
  7062. const SsSidebarList = {
  7063. name: "SsSidebarList",
  7064. props: {
  7065. title: { type: String, default: "" },
  7066. // header 图标:优先使用 iconClass(走 ss-icon v3.0 class 分支) by xu 20260106
  7067. iconClass: { type: String, default: "" },
  7068. icon: { type: String, default: "" }, // 兼容旧写法(ss-icon name)
  7069. count: { type: [Number, String], default: "" },
  7070. // 选中类分区:右侧关闭按钮=清空分区数据 by xu 20260106
  7071. closable: { type: Boolean, default: false },
  7072. searchable: { type: Boolean, default: false },
  7073. // 搜索框是否放在 header 内(人员块需要该布局) by xu 20260106
  7074. searchInHeader: { type: Boolean, default: false },
  7075. // header 搜索:下拉条件 + 搜索按钮(适合“人员”块) by xu 20260106
  7076. headerFilters: { type: Array, default: () => [] },
  7077. headerSearchButton: { type: Boolean, default: false },
  7078. searchPlaceholder: { type: String, default: "搜索" },
  7079. // 列表项布局:simple(仅标题) / person(标题+人员号槽位) by xu 20260106
  7080. itemLayout: { type: String, default: "simple" },
  7081. itemAction: { type: Boolean, default: true },
  7082. collapsible: { type: Boolean, default: true }, // 功能说明:是否允许双击 header 折叠/展开 by xu 20260116
  7083. collapsed: { type: Boolean, default: false }, // 功能说明:折叠态仅展示 header by xu 20260116
  7084. items: { type: Array, default: () => [] },
  7085. mode: { type: String, default: "search" }, // search / selected
  7086. },
  7087. emits: ["select", "remove", "clear", "search", "toggle-collapse"],
  7088. data() {
  7089. return {
  7090. keyword: "",
  7091. filterValues: {},
  7092. }; // 功能说明:折叠状态完全由 props.collapsed 驱动,避免多面板复用导致状态不同步 by xu 20260116
  7093. },
  7094. created() {
  7095. // header 下拉条件默认值初始化 by xu 20260106
  7096. (this.headerFilters || []).forEach((f) => {
  7097. if (!f || !f.key) return;
  7098. if (this.filterValues[f.key] !== undefined) return;
  7099. const first = f?.options?.[0]?.value ?? "";
  7100. this.filterValues[f.key] = f.value !== undefined ? f.value : first;
  7101. });
  7102. },
  7103. methods: {
  7104. __shouldIgnoreHeaderToggle(e) {
  7105. // 功能说明:忽略工具区/输入区触发折叠,避免误触 by xu 20260116
  7106. const t = e?.target;
  7107. if (!t || !t.closest) return false;
  7108. if (t.closest(".ss-sidebar-panel__tools")) return true;
  7109. if (t.closest(".ss-sidebar-panel__filters")) return true;
  7110. if (t.closest("input,textarea,select,button")) return true;
  7111. return false;
  7112. },
  7113. __toggleCollapseInternal(e, source) {
  7114. if (!this.collapsible) return;
  7115. if (this.__shouldIgnoreHeaderToggle(e)) return;
  7116. const nextCollapsed = !this.collapsed;
  7117. console.log("[SsSidebarList] toggle emit", {
  7118. title: this.title,
  7119. source,
  7120. to: nextCollapsed,
  7121. }); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  7122. // 功能说明:由父组件(SsSidebar.toggleSectionCollapse)统一控制 section 高度与折叠数组 by xu 20260116
  7123. this.$emit("toggle-collapse");
  7124. },
  7125. },
  7126. render() {
  7127. const items = this.items || [];
  7128. const SsIcon = Vue.resolveComponent("ss-icon");
  7129. const isSelectedMode = this.mode === "selected";
  7130. const activeKeyword = this.filterValues?.keyword ?? this.keyword; // 功能:keyword 优先取 headerFilters.keyword by xu 20260106
  7131. const hasHeaderKeyword = (this.headerFilters || []).some(
  7132. (f) => f?.key === "keyword"
  7133. ); // 功能:header 内 keyword 过滤 by xu 20260106
  7134. const renderHeaderFilter = (f) => {
  7135. if (!f) return null;
  7136. const key = f.key;
  7137. const componentName = f.component;
  7138. if (!key || !componentName) return null;
  7139. const Comp = Vue.resolveComponent(componentName);
  7140. if (!Comp) return null;
  7141. const modelValue = this.filterValues[key];
  7142. const props = f.props || {};
  7143. return Vue.h(Comp, {
  7144. ...props,
  7145. modelValue,
  7146. "onUpdate:modelValue": (v) => {
  7147. this.filterValues[key] = v;
  7148. },
  7149. });
  7150. };
  7151. const filteredItems =
  7152. this.searchable && activeKeyword
  7153. ? items.filter((it) =>
  7154. String(it?.title ?? "")
  7155. .toLowerCase()
  7156. .includes(String(activeKeyword).toLowerCase())
  7157. )
  7158. : items;
  7159. if (!filteredItems.length && !this.title) return null;
  7160. if (this.collapsed) {
  7161. return Vue.h("div", { class: "ss-sidebar-panel" }, [
  7162. this.title
  7163. ? Vue.h(
  7164. "div",
  7165. {
  7166. class: "ss-sidebar-panel__header",
  7167. // 功能说明:折叠触发绑定到整个 header(dblclick + click.detail==2 兜底) by xu 20260116
  7168. onDblclick: (e) => {
  7169. e?.preventDefault?.();
  7170. e?.stopPropagation?.();
  7171. console.log("[SsSidebarList] header dblclick", {
  7172. title: this.title,
  7173. collapsed: true,
  7174. }); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  7175. this.__toggleCollapseInternal(e, "dblclick");
  7176. },
  7177. // 功能说明:移除 click.detail==2 兜底,避免双击同时触发 click+dblclick 导致“折叠又立刻展开” by xu 20260116
  7178. },
  7179. [
  7180. Vue.h("div", { class: "ss-sidebar-panel__title" }, [
  7181. this.iconClass
  7182. ? Vue.h(SsIcon, {
  7183. class: this.iconClass + " ss-sidebar-panel__icon",
  7184. })
  7185. : this.icon
  7186. ? Vue.h(SsIcon, {
  7187. name: this.icon,
  7188. size: "16px",
  7189. class: "ss-sidebar-panel__icon",
  7190. })
  7191. : null,
  7192. Vue.h("span", null, this.title),
  7193. this.count !== ""
  7194. ? Vue.h(
  7195. "span",
  7196. { class: "ss-sidebar-panel__count" },
  7197. `(${this.count})`
  7198. )
  7199. : null,
  7200. ]),
  7201. Vue.h("div", { class: "ss-sidebar-panel__tools" }, [
  7202. this.closable
  7203. ? Vue.h(
  7204. "button",
  7205. {
  7206. type: "button",
  7207. class: "ss-sidebar-icon-btn ss-sidebar-header-btn",
  7208. title: "清空",
  7209. onClick: (e) => {
  7210. e.stopPropagation();
  7211. this.$emit("clear");
  7212. },
  7213. },
  7214. [
  7215. Vue.h(SsIcon, {
  7216. class: "ss-sidebar-base-icon icon-cl",
  7217. }),
  7218. ] // 功能说明:右侧栏“已选”清空按钮图标使用 ss-sidebar-base-icon by xu 20260123
  7219. )
  7220. : null,
  7221. ]),
  7222. ]
  7223. )
  7224. : null,
  7225. ]);
  7226. }
  7227. return Vue.h("div", { class: "ss-sidebar-panel" }, [
  7228. this.title
  7229. ? Vue.h(
  7230. "div",
  7231. {
  7232. class: "ss-sidebar-panel__header",
  7233. // 功能说明:折叠触发绑定到整个 header(dblclick + click.detail==2 兜底) by xu 20260116
  7234. onDblclick: (e) => {
  7235. e?.preventDefault?.();
  7236. e?.stopPropagation?.();
  7237. console.log("[SsSidebarList] header dblclick", {
  7238. title: this.title,
  7239. collapsed: false,
  7240. }); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  7241. this.__toggleCollapseInternal(e, "dblclick");
  7242. },
  7243. // 功能说明:移除 click.detail==2 兜底,避免双击同时触发 click+dblclick 导致“折叠又立刻展开” by xu 20260116
  7244. },
  7245. [
  7246. Vue.h("div", { class: "ss-sidebar-panel__title" }, [
  7247. // 图标 + 标题(每个分区都有) by xu 20260106
  7248. this.iconClass
  7249. ? Vue.h(SsIcon, {
  7250. class: this.iconClass + " ss-sidebar-panel__icon",
  7251. })
  7252. : this.icon
  7253. ? Vue.h(SsIcon, {
  7254. name: this.icon,
  7255. size: "16px",
  7256. class: "ss-sidebar-panel__icon",
  7257. })
  7258. : null,
  7259. Vue.h("span", null, this.title),
  7260. // 数量回显:图表分区可不传 count by xu 20260106
  7261. this.count !== ""
  7262. ? Vue.h(
  7263. "span",
  7264. { class: "ss-sidebar-panel__count" },
  7265. `(${this.count})`
  7266. )
  7267. : null,
  7268. ]),
  7269. Vue.h("div", { class: "ss-sidebar-panel__tools" }, [
  7270. // header 条件(例如下拉框)+ 右侧搜索按钮 by xu 20260106
  7271. this.headerFilters?.length
  7272. ? Vue.h(
  7273. "div",
  7274. { class: "ss-sidebar-panel__filters" },
  7275. this.headerFilters
  7276. .map(renderHeaderFilter)
  7277. .filter(Boolean)
  7278. )
  7279. : null,
  7280. this.headerSearchButton
  7281. ? Vue.h(
  7282. "button",
  7283. {
  7284. type: "button",
  7285. class: "ss-sidebar-icon-btn",
  7286. title: "搜索",
  7287. onClick: (e) => {
  7288. e.stopPropagation();
  7289. this.$emit("search", {
  7290. // headerFilters 内也可能包含 keyword by xu 20260106
  7291. keyword: activeKeyword,
  7292. filters: { ...(this.filterValues || {}) },
  7293. });
  7294. },
  7295. },
  7296. [Vue.h(SsIcon, { name: "search", size: "14px" })]
  7297. )
  7298. : null,
  7299. // 人员块:搜索框在 header 内 by xu 20260106
  7300. this.searchable &&
  7301. this.searchInHeader &&
  7302. !this.headerSearchButton
  7303. ? Vue.h(
  7304. "div",
  7305. { class: "ss-sidebar-panel__searchInline" },
  7306. [
  7307. Vue.h(
  7308. "div",
  7309. { class: "ss-sidebar-search is-inline" },
  7310. [
  7311. Vue.h(SsIcon, {
  7312. name: "search",
  7313. size: "14px",
  7314. class: "ss-sidebar-search__prefix",
  7315. }),
  7316. Vue.h("input", {
  7317. class: "ss-sidebar-search__input",
  7318. value: this.keyword,
  7319. placeholder: this.searchPlaceholder,
  7320. onInput: (e) => {
  7321. this.keyword = e?.target?.value ?? "";
  7322. },
  7323. }),
  7324. ]
  7325. ),
  7326. ]
  7327. )
  7328. : null,
  7329. this.closable
  7330. ? Vue.h(
  7331. "button",
  7332. {
  7333. type: "button",
  7334. class: "ss-sidebar-icon-btn ss-sidebar-header-btn",
  7335. title: "清空",
  7336. onClick: (e) => {
  7337. e.stopPropagation();
  7338. this.$emit("clear");
  7339. },
  7340. },
  7341. // 清空按钮使用 icon-base 的 icon-cl by xu 20260106
  7342. [
  7343. Vue.h(SsIcon, {
  7344. class: "ss-sidebar-base-icon icon-cl",
  7345. }),
  7346. ] // 功能说明:右侧栏清空按钮图标使用 ss-sidebar-base-icon by xu 20260123
  7347. )
  7348. : null,
  7349. ]),
  7350. ]
  7351. )
  7352. : null,
  7353. // 非 header 内搜索:独立一行 by xu 20260106
  7354. // headerSearchButton/headerFilters 已覆盖搜索能力时,不再额外渲染独立搜索行 by xu 20260106
  7355. this.searchable &&
  7356. !this.searchInHeader &&
  7357. !this.headerSearchButton &&
  7358. !hasHeaderKeyword
  7359. ? Vue.h("div", { class: "ss-sidebar-panel__search" }, [
  7360. Vue.h("div", { class: "ss-sidebar-search" }, [
  7361. Vue.h(SsIcon, {
  7362. name: "search",
  7363. size: "14px",
  7364. class: "ss-sidebar-search__prefix",
  7365. }),
  7366. Vue.h("input", {
  7367. class: "ss-sidebar-search__input",
  7368. value: this.keyword,
  7369. placeholder: this.searchPlaceholder,
  7370. onInput: (e) => {
  7371. this.keyword = e?.target?.value ?? "";
  7372. },
  7373. }),
  7374. ]),
  7375. ])
  7376. : null,
  7377. Vue.h(
  7378. "div",
  7379. { class: "ss-sidebar-list" },
  7380. filteredItems.map((item, idx) => {
  7381. const title = item?.title ?? "";
  7382. const tags = item?.tags || [];
  7383. const isPersonLayout = this.itemLayout === "person";
  7384. const hasTags = !isPersonLayout && tags?.length > 0; // 列表项垂直对齐:有 tags 顶对齐 by xu 20260106
  7385. return Vue.h(
  7386. "div",
  7387. {
  7388. class: {
  7389. "ss-sidebar-list-item": true,
  7390. "is-first": idx === 0,
  7391. "is-person": isPersonLayout,
  7392. "has-tags": hasTags,
  7393. },
  7394. },
  7395. [
  7396. Vue.h("div", { class: "ss-sidebar-list-item__main" }, [
  7397. Vue.h(
  7398. "div",
  7399. { class: "ss-sidebar-list-item__title" },
  7400. Vue.h(
  7401. "span",
  7402. {
  7403. style: {
  7404. "white-space": "nowrap",
  7405. overflow: "hidden",
  7406. "text-overflow": "ellipsis",
  7407. },
  7408. },
  7409. title
  7410. )
  7411. ),
  7412. // 非人员布局才显示 tags by xu 20260106
  7413. !isPersonLayout && tags?.length
  7414. ? Vue.h(
  7415. "div",
  7416. { class: "ss-sidebar-list-item__tags" },
  7417. tags.map((tag) => {
  7418. const [k, v] = Object.entries(tag)[0] || ["", ""];
  7419. return Vue.h(
  7420. "span",
  7421. { class: "ss-sidebar-tag", title: `${k}: ${v}` },
  7422. `${k}: ${v}`
  7423. );
  7424. })
  7425. )
  7426. : null,
  7427. ]),
  7428. // 人员布局:中间保留“人员号”槽位 by xu 20260106
  7429. isPersonLayout
  7430. ? Vue.h(
  7431. "div",
  7432. {
  7433. class: "ss-sidebar-list-item__meta",
  7434. title: String(item?.meta ?? ""),
  7435. },
  7436. item?.meta ?? ""
  7437. )
  7438. : null,
  7439. this.itemAction
  7440. ? Vue.h(
  7441. "button",
  7442. {
  7443. type: "button",
  7444. class: {
  7445. // item 操作按钮:默认无背景/无边框,hover 才高亮 by xu 20260106
  7446. "ss-sidebar-item-btn": true,
  7447. },
  7448. title: isSelectedMode ? "移除" : "选择",
  7449. onClick: (e) => {
  7450. e.stopPropagation();
  7451. if (isSelectedMode) this.$emit("remove", item);
  7452. else this.$emit("select", item);
  7453. },
  7454. },
  7455. [
  7456. // item 移除图标使用 icon-base 的 icon-cl by xu 20260106
  7457. isSelectedMode
  7458. ? Vue.h(SsIcon, {
  7459. class: "ss-sidebar-base-icon icon-cl",
  7460. }) // 功能说明:右侧栏 item 移除图标使用 ss-sidebar-base-icon by xu 20260123
  7461. : Vue.h(SsIcon, { name: "check", size: "14px" }),
  7462. ]
  7463. )
  7464. : null,
  7465. ]
  7466. );
  7467. })
  7468. ),
  7469. ]);
  7470. },
  7471. };
  7472. // ss-sidebar-report-table:右侧“统计表/报表”面板(pstatList grtjlbm=51 聚拢渲染) by xu 20260115
  7473. const SsSidebarReportTable = {
  7474. name: "SsSidebarReportTable",
  7475. props: {
  7476. title: { type: String, default: "" },
  7477. iconClass: { type: String, default: "" },
  7478. icon: { type: String, default: "" },
  7479. items: { type: Array, default: () => [] }, // pstatList(grtjlbm=51) 数组
  7480. onOpen: { type: Function, default: null }, // (srv, ctx) => void
  7481. collapsible: { type: Boolean, default: true }, // 功能说明:是否允许双击 header 折叠/展开 by xu 20260116
  7482. collapsed: { type: Boolean, default: false }, // 功能说明:折叠态仅展示 header by xu 20260116
  7483. },
  7484. emits: ["open", "toggle-collapse"],
  7485. data() {
  7486. return {}; // 功能说明:折叠状态完全由 props.collapsed 驱动 by xu 20260116
  7487. },
  7488. methods: {
  7489. __toggleCollapseInternal(e, source) {
  7490. if (!this.collapsible) return;
  7491. const next = !this.collapsed;
  7492. console.log("[SsSidebarReportTable] toggle emit", {
  7493. title: this.title,
  7494. source,
  7495. to: next,
  7496. }); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  7497. this.$emit("toggle-collapse");
  7498. },
  7499. },
  7500. render() {
  7501. const SsIcon = Vue.resolveComponent("ss-icon");
  7502. const list = this.items || [];
  7503. if (!this.title && !list.length) return null;
  7504. const header = this.title
  7505. ? Vue.h(
  7506. "div",
  7507. {
  7508. class: "ss-sidebar-panel__header",
  7509. // 功能说明:折叠触发绑定到整个 header(dblclick + click.detail==2 兜底) by xu 20260116
  7510. onDblclick: (e) => {
  7511. e?.preventDefault?.();
  7512. e?.stopPropagation?.();
  7513. console.log("[SsSidebarReportTable] header dblclick", {
  7514. title: this.title,
  7515. collapsed: this.collapsed,
  7516. }); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  7517. this.__toggleCollapseInternal(e, "dblclick");
  7518. },
  7519. // 功能说明:移除 click.detail==2 兜底,避免双击同时触发 click+dblclick 导致“折叠又立刻展开” by xu 20260116
  7520. },
  7521. [
  7522. Vue.h("div", { class: "ss-sidebar-panel__title" }, [
  7523. this.iconClass
  7524. ? Vue.h(SsIcon, {
  7525. class: this.iconClass + " ss-sidebar-panel__icon",
  7526. })
  7527. : this.icon
  7528. ? Vue.h(SsIcon, {
  7529. name: this.icon,
  7530. size: "16px",
  7531. class: "ss-sidebar-panel__icon",
  7532. })
  7533. : null,
  7534. Vue.h("span", null, this.title),
  7535. ]),
  7536. Vue.h("div", { class: "ss-sidebar-panel__tools" }),
  7537. ]
  7538. )
  7539. : null;
  7540. const renderReport = (report) => {
  7541. const title = String(report?.mc ?? "");
  7542. const mx = Array.isArray(report?.grtjmxList) ? report.grtjmxList : [];
  7543. if (!title && !mx.length) return null;
  7544. // 功能说明:每个报表对象渲染为一个 table(有边框、无圆角、表间距10px;样式由 base.css 统一控制) by xu 20260115
  7545. const cols = Math.max(1, mx.length);
  7546. // 功能说明:table 外层包一层 wrap,子项过多时支持横向滚动 by xu 20260115
  7547. return Vue.h("div", { class: "ss-sidebar-report-table-wrap" }, [
  7548. Vue.h("table", { class: "ss-sidebar-report-table" }, [
  7549. Vue.h("thead", null, [
  7550. Vue.h("tr", null, [
  7551. Vue.h(
  7552. "th",
  7553. { class: "ss-sidebar-report-table__title", colspan: cols },
  7554. Vue.h(
  7555. "div",
  7556. { class: "ss-sidebar-report-table__title-content" },
  7557. [
  7558. Vue.h("span", { class: "ss-sidebar-report-table__dot" }),
  7559. Vue.h(
  7560. "span",
  7561. { class: "ss-sidebar-report-table__title-text", title },
  7562. title
  7563. ),
  7564. ]
  7565. )
  7566. ),
  7567. ]),
  7568. ]),
  7569. Vue.h("tbody", null, [
  7570. Vue.h(
  7571. "tr",
  7572. null,
  7573. mx.map((cell) => {
  7574. const text = String(cell?.mc ?? "");
  7575. const srv = {
  7576. servName: cell?.fwm ?? "",
  7577. dest: cell?.bjm ?? "",
  7578. title: text,
  7579. width: cell?.width,
  7580. height: cell?.height,
  7581. minHeight: cell?.height,
  7582. maxHeight: cell?.height,
  7583. showTitle: text,
  7584. };
  7585. return Vue.h(
  7586. "td",
  7587. {
  7588. class: "ss-sidebar-report-table__cell",
  7589. title: text,
  7590. onClick: (e) => {
  7591. e?.stopPropagation?.();
  7592. try {
  7593. this.onOpen?.(srv, { report, cell });
  7594. } catch (_) {}
  7595. this.$emit("open", { report, cell, srv });
  7596. },
  7597. },
  7598. text
  7599. );
  7600. })
  7601. ),
  7602. ]),
  7603. ]),
  7604. ]);
  7605. };
  7606. // 功能说明:报表面板增加独立 class,便于 base.css 统一控制 padding/间距 by xu 20260115
  7607. return Vue.h(
  7608. "div",
  7609. { class: "ss-sidebar-panel ss-sidebar-report-panel" },
  7610. [
  7611. header,
  7612. this.collapsed
  7613. ? null
  7614. : Vue.h(
  7615. "div",
  7616. // 功能说明:报表列表滚动/高度样式下沉到 base.css,避免写在 DOM 上 by xu 20260115
  7617. { class: "ss-sidebar-report__list" },
  7618. list.map(renderReport).filter(Boolean)
  7619. ),
  7620. ]
  7621. );
  7622. },
  7623. };
  7624. // 组件文档补全(JSDoc) by xu 20260108
  7625. /**
  7626. * SsSidebar(objList 右侧边栏容器)
  7627. *
  7628. * 用途:
  7629. * - 统一渲染顶部按钮栏(buttons)
  7630. * - 统一渲染中间业务面板(list panels,可拖拽调高度)
  7631. * - 统一渲染底部图表(chart panels,内部用 ss-sidebar-chart-hover)
  7632. *
  7633. * 调用示例:
  7634. * ```html
  7635. * <ss-sidebar :buttons="sidebarButtons" :panels="sidebarPanels" @remove="handleSidebarRemove" />
  7636. * ```
  7637. *
  7638. * Props:
  7639. * - `buttons`:顶部按钮配置数组
  7640. * - `panels`:分区配置数组(`type: 'list' | 'chart'`)
  7641. *
  7642. * Events(向外透传):
  7643. * - `remove(item)`:来自 list 面板移除
  7644. * - `select(item)`:来自 list 面板选择(如后续需要)
  7645. */
  7646. const SsSidebar = {
  7647. name: "SsSidebar",
  7648. props: {
  7649. buttons: { type: Array, default: () => [] },
  7650. charts: { type: Array, default: () => [] },
  7651. list: { type: Array, default: () => [] }, // legacy
  7652. listMode: { type: String, default: "search" }, // legacy
  7653. panels: { type: Array, default: () => [] },
  7654. },
  7655. emits: ["select", "remove"],
  7656. data() {
  7657. return {
  7658. // 业务面板高度(索引 -> px) by xu 20260106
  7659. sectionHeights: [],
  7660. sectionCollapsed: [], // 功能说明:面板折叠状态(sectionPanels 索引) by xu 20260116
  7661. sectionHeightsExpanded: [], // 功能说明:面板展开高度缓存(用于折叠后恢复) by xu 20260116
  7662. sectionLastItemCounts: [], // 功能说明:记录栏目数据量,供“无数据默认关闭/已选自动展开”规则复用 by xu 20260313
  7663. chartCollapsed: [], // 功能说明:图表面板折叠状态(chartPanels 索引) by xu 20260116
  7664. chartHeaderTitleDownAt: [], // 功能说明:双击检测绑定到 chart 标题区 by xu 20260116
  7665. reportCollapsed: [], // 功能说明:报表面板折叠状态(reportPanels 索引) by xu 20260116
  7666. resizeTimer: null,
  7667. resizing: false,
  7668. resizeIndex: -1,
  7669. resizeStartY: 0,
  7670. resizeStartPrev: 0,
  7671. resizeStartNext: 0,
  7672. __resizeMoveHandler: null, // 功能说明:显式绑定 this 的 pointermove handler,避免 addEventListener 场景 this 丢失导致拖拽无效 by xu 20260122
  7673. __resizeEndHandler: null, // 功能说明:显式绑定 this 的 pointerup handler,确保能正确结束拖拽 by xu 20260122
  7674. __resizeCancelHandler: null, // 功能说明:显式绑定 this 的 pointercancel handler,触控取消也能收尾 by xu 20260122
  7675. __resizePrevSectionEl: null, // 功能说明:拖拽时直接写 DOM 高度(修复响应式更新不生效) by xu 20260122
  7676. __resizeNextSectionEl: null, // 功能说明:拖拽时直接写 DOM 高度(修复响应式更新不生效) by xu 20260122
  7677. };
  7678. },
  7679. methods: {
  7680. // 初始化默认高度(只在第一次/面板数量变化时补齐) by xu 20260106
  7681. ensureSectionHeights(sectionCount) {
  7682. if (!Array.isArray(this.sectionHeights)) this.sectionHeights = [];
  7683. if (this.sectionHeights.length === sectionCount) return;
  7684. const next = [];
  7685. for (let i = 0; i < sectionCount; i++) {
  7686. next[i] = this.sectionHeights[i] ?? 190; // 默认高度 by xu 20260106
  7687. }
  7688. this.sectionHeights = next;
  7689. // 功能说明:面板数量变化时补齐折叠/缓存数组长度 by xu 20260116
  7690. this.sectionCollapsed = Array.from(
  7691. { length: sectionCount },
  7692. (_, i) => !!this.sectionCollapsed?.[i]
  7693. );
  7694. this.sectionHeightsExpanded = Array.from(
  7695. { length: sectionCount },
  7696. (_, i) => this.sectionHeightsExpanded?.[i] ?? null
  7697. );
  7698. this.sectionLastItemCounts = Array.from(
  7699. { length: sectionCount },
  7700. (_, i) => Number(this.sectionLastItemCounts?.[i] ?? 0) || 0
  7701. );
  7702. },
  7703. __getPanelsForSectionState(panelsInput) {
  7704. return (panelsInput || []).length
  7705. ? panelsInput
  7706. : this.list?.length
  7707. ? [
  7708. {
  7709. type: "list",
  7710. title: "已选",
  7711. icon: "",
  7712. mode: this.listMode,
  7713. items: this.list,
  7714. },
  7715. ]
  7716. : [];
  7717. },
  7718. __getSectionPanelsForState(panelsInput) {
  7719. return this.__getPanelsForSectionState(panelsInput)
  7720. .filter((p) => {
  7721. const k = String(p?._tabKey ?? "")
  7722. .trim()
  7723. .toLowerCase();
  7724. const t = String(p?.title ?? "").trim();
  7725. if (k === "rbarobj") return false;
  7726. if (t === "对象") return false;
  7727. return true;
  7728. })
  7729. .filter((p) => p?.type !== "chart" && p?.type !== "report-table");
  7730. },
  7731. __getSectionPanelCount(panel) {
  7732. const explicitCount = Number(panel?.count);
  7733. if (Number.isFinite(explicitCount)) return explicitCount;
  7734. return Array.isArray(panel?.items) ? panel.items.length : 0;
  7735. },
  7736. __setSectionCollapsedState(index, collapsed) {
  7737. const i = Number(index);
  7738. if (isNaN(i) || i < 0) return;
  7739. const nextCollapsed = !!collapsed;
  7740. const collapsedHeight = 37;
  7741. const cur = !!this.sectionCollapsed?.[i];
  7742. const currentHeight = Number(this.sectionHeights?.[i] ?? 190) || 190;
  7743. if (nextCollapsed === cur) {
  7744. if (nextCollapsed && currentHeight !== collapsedHeight) {
  7745. this.sectionHeights.splice(i, 1, collapsedHeight);
  7746. }
  7747. return;
  7748. }
  7749. if (nextCollapsed) {
  7750. this.sectionHeightsExpanded[i] =
  7751. currentHeight > collapsedHeight
  7752. ? currentHeight
  7753. : Number(this.sectionHeightsExpanded?.[i] ?? 190) || 190;
  7754. this.sectionHeights.splice(i, 1, collapsedHeight);
  7755. } else {
  7756. const restore =
  7757. Number(this.sectionHeightsExpanded?.[i] ?? 190) || 190;
  7758. this.sectionHeights.splice(i, 1, restore);
  7759. }
  7760. this.sectionCollapsed.splice(i, 1, nextCollapsed);
  7761. },
  7762. __syncSectionAutoCollapse(panelsInput) {
  7763. const sectionPanels = this.__getSectionPanelsForState(panelsInput);
  7764. const sectionCount = sectionPanels.length;
  7765. this.ensureSectionHeights(sectionCount);
  7766. const prevCounts = Array.isArray(this.sectionLastItemCounts)
  7767. ? this.sectionLastItemCounts.slice()
  7768. : [];
  7769. const nextCounts = Array.from({ length: sectionCount }, (_, i) =>
  7770. this.__getSectionPanelCount(sectionPanels[i])
  7771. );
  7772. this.sectionLastItemCounts = nextCounts;
  7773. sectionPanels.forEach((panel, index) => {
  7774. const count = Number(nextCounts[index] ?? 0) || 0;
  7775. const prevCount = Number(prevCounts[index] ?? 0) || 0;
  7776. const title = String(panel?.title ?? "").trim();
  7777. if (count <= 0) {
  7778. this.__setSectionCollapsedState(index, true);
  7779. return;
  7780. }
  7781. if (title === "已选" && count > prevCount) {
  7782. this.__setSectionCollapsedState(index, false);
  7783. }
  7784. });
  7785. },
  7786. toggleSectionCollapse(index) {
  7787. // 功能说明:双击 header 折叠/展开 section 面板(仅控制高度与内容渲染) by xu 20260116
  7788. const i = Number(index);
  7789. if (isNaN(i) || i < 0) return;
  7790. // 功能说明:加更细粒度日志,定位“多面板折叠无视觉效果”的根因(高度是否真的变、DOM 是否更新) by xu 20260116
  7791. const collapsedHeight = 37; // 功能说明:header(35) + panel 边框(2),避免 flex shrink 导致 header 变 25px by xu 20260116
  7792. const cur = !!this.sectionCollapsed?.[i];
  7793. console.log("[SsSidebar] toggleSectionCollapse", {
  7794. index: i,
  7795. to: !cur,
  7796. prevHeight: this.sectionHeights?.[i],
  7797. }); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  7798. if (!cur) {
  7799. this.sectionHeightsExpanded[i] = this.sectionHeights[i] ?? 190;
  7800. this.sectionHeights.splice(i, 1, collapsedHeight);
  7801. } else {
  7802. const restore =
  7803. Number(this.sectionHeightsExpanded?.[i] ?? 190) || 190;
  7804. this.sectionHeights.splice(i, 1, restore);
  7805. }
  7806. this.sectionCollapsed.splice(i, 1, !cur);
  7807. console.log("[SsSidebar] section state(after)", {
  7808. index: i,
  7809. height: this.sectionHeights?.[i],
  7810. collapsed: this.sectionCollapsed?.[i],
  7811. allHeights: Array.from(this.sectionHeights || []),
  7812. allCollapsed: Array.from(this.sectionCollapsed || []),
  7813. }); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  7814. Vue.nextTick(() => {
  7815. try {
  7816. const root = this.$el;
  7817. const sections = root?.querySelectorAll?.(".ss-sidebar-section");
  7818. const el = sections?.[i];
  7819. const rectH = el?.getBoundingClientRect?.().height;
  7820. console.log("[SsSidebar] section dom(beforeFix)", {
  7821. index: i,
  7822. styleHeight: el?.style?.height,
  7823. rectH,
  7824. }); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  7825. // 功能说明:若渲染未把 height patch 到 DOM,则在 nextTick 强制同步一次(并打印) by xu 20260116
  7826. const targetH =
  7827. (Number(this.sectionHeights?.[i] ?? 190) || 190) + "px";
  7828. if (el && el.style && el.style.height !== targetH) {
  7829. el.style.height = targetH;
  7830. }
  7831. if (el?.classList) {
  7832. el.classList.toggle("is-collapsed", !!this.sectionCollapsed?.[i]);
  7833. }
  7834. const rectAfter = el?.getBoundingClientRect?.().height;
  7835. console.log("[SsSidebar] section dom(afterFix)", {
  7836. index: i,
  7837. styleHeight: el?.style?.height,
  7838. rectH: rectAfter,
  7839. targetH,
  7840. }); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  7841. } catch (err) {
  7842. console.log("[SsSidebar] section dom(afterTick) error", err); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  7843. }
  7844. });
  7845. },
  7846. toggleChartCollapse(index) {
  7847. // 功能说明:双击 header 折叠/展开底部 chart 面板(隐藏/显示 chart-hover) by xu 20260116
  7848. const i = Number(index);
  7849. if (isNaN(i) || i < 0) return;
  7850. const cur = !!this.chartCollapsed?.[i];
  7851. console.log("[SsSidebar] toggleChartCollapse", { index: i, to: !cur }); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  7852. this.chartCollapsed.splice(i, 1, !cur);
  7853. console.log("[SsSidebar] chart state(after)", {
  7854. index: i,
  7855. collapsed: this.chartCollapsed?.[i],
  7856. allCollapsed: Array.from(this.chartCollapsed || []),
  7857. }); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  7858. Vue.nextTick(() => {
  7859. try {
  7860. const root = this.$el;
  7861. const el = root?.querySelector?.(
  7862. `.ss-sidebar-chart-panel[data-chart-idx="${i}"]`
  7863. );
  7864. console.log("[SsSidebar] chart dom(beforeFix)", {
  7865. index: i,
  7866. found: !!el,
  7867. }); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  7868. if (el?.classList)
  7869. el.classList.toggle("is-collapsed", !!this.chartCollapsed?.[i]);
  7870. console.log("[SsSidebar] chart dom(afterFix)", {
  7871. index: i,
  7872. collapsed: !!this.chartCollapsed?.[i],
  7873. }); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  7874. } catch (err) {
  7875. console.log("[SsSidebar] chart dom(afterTick) error", err); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  7876. }
  7877. });
  7878. },
  7879. toggleReportCollapse(index) {
  7880. // 功能说明:双击 header 折叠/展开底部 report-table 面板(隐藏/显示表格) by xu 20260116
  7881. const i = Number(index);
  7882. if (isNaN(i) || i < 0) return;
  7883. const cur = !!this.reportCollapsed?.[i];
  7884. console.log("[SsSidebar] toggleReportCollapse", { index: i, to: !cur }); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  7885. this.reportCollapsed.splice(i, 1, !cur);
  7886. console.log("[SsSidebar] report state(after)", {
  7887. index: i,
  7888. collapsed: this.reportCollapsed?.[i],
  7889. allCollapsed: Array.from(this.reportCollapsed || []),
  7890. }); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  7891. Vue.nextTick(() => {
  7892. try {
  7893. const root = this.$el;
  7894. const el = root?.querySelector?.(
  7895. `.ss-sidebar-report-panel[data-report-idx="${i}"]`
  7896. );
  7897. console.log("[SsSidebar] report dom(beforeFix)", {
  7898. index: i,
  7899. found: !!el,
  7900. }); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  7901. if (el?.classList)
  7902. el.classList.toggle("is-collapsed", !!this.reportCollapsed?.[i]);
  7903. console.log("[SsSidebar] report dom(afterFix)", {
  7904. index: i,
  7905. collapsed: !!this.reportCollapsed?.[i],
  7906. }); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  7907. } catch (err) {
  7908. console.log("[SsSidebar] report dom(afterTick) error", err); // 功能说明:直接打印用于排查多面板不生效 by xu 20260116
  7909. }
  7910. });
  7911. },
  7912. startResize(index, e) {
  7913. if (e?.preventDefault) e.preventDefault();
  7914. if (e?.stopPropagation) e.stopPropagation();
  7915. if (this.resizing) return;
  7916. // 长按 0.5s 后才进入拖拽调高度 by xu 20260106
  7917. clearTimeout(this.resizeTimer);
  7918. // 功能说明:修复“长按拖拽偶发失效/卡死”——pointerup 早于 500ms 时必须取消 timer,否则 timer 触发后进入 resizing=true 且再也收不到 pointerup,导致后续都无法拖拽 by xu 20260122
  7919. const pointerId = e?.pointerId;
  7920. const cancelPendingResize = (ev) => {
  7921. try {
  7922. if (
  7923. pointerId != null &&
  7924. ev?.pointerId != null &&
  7925. ev.pointerId !== pointerId
  7926. )
  7927. return;
  7928. } catch (_) {}
  7929. clearTimeout(this.resizeTimer);
  7930. this.resizeTimer = null;
  7931. document.removeEventListener("pointerup", cancelPendingResize, true);
  7932. document.removeEventListener(
  7933. "pointercancel",
  7934. cancelPendingResize,
  7935. true
  7936. );
  7937. };
  7938. // 功能说明:用 document+capture 监听,避免 window 监听在部分容器/iframe 场景丢事件导致拖拽无响应 by xu 20260122
  7939. document.addEventListener("pointerup", cancelPendingResize, {
  7940. passive: false,
  7941. once: true,
  7942. capture: true,
  7943. });
  7944. document.addEventListener("pointercancel", cancelPendingResize, {
  7945. passive: false,
  7946. once: true,
  7947. capture: true,
  7948. });
  7949. const startY = e?.clientY ?? 0;
  7950. const gapEl = e?.currentTarget;
  7951. // 功能说明:记录 gap 前后 section 节点,拖拽过程中直接写入 style.height,避免某些环境下 Vue render 不刷新导致“拖拽无视觉变化” by xu 20260122
  7952. this.__resizePrevSectionEl = gapEl?.previousElementSibling || null;
  7953. this.__resizeNextSectionEl = gapEl?.nextElementSibling || null;
  7954. this.resizeTimer = setTimeout(() => {
  7955. // 定时器触发后进入拖拽态,移除“取消等待”监听,避免误取消 by xu 20260122
  7956. document.removeEventListener("pointerup", cancelPendingResize, true);
  7957. document.removeEventListener(
  7958. "pointercancel",
  7959. cancelPendingResize,
  7960. true
  7961. );
  7962. this.resizing = true;
  7963. this.resizeIndex = index;
  7964. this.resizeStartY = startY;
  7965. this.resizeStartPrev = this.sectionHeights[index] ?? 190;
  7966. this.resizeStartNext = this.sectionHeights[index + 1] ?? 190;
  7967. gapEl?.classList?.add("is-active");
  7968. try {
  7969. if (gapEl?.setPointerCapture && pointerId != null)
  7970. gapEl.setPointerCapture(pointerId);
  7971. } catch (_) {} // 功能说明:捕获 pointer,避免拖拽过程中移出窗口导致 pointermove 丢失 by xu 20260122
  7972. // 功能说明:用 document+capture,确保拖拽时 pointermove/up 不会被中途 stopPropagation 影响 by xu 20260122
  7973. document.addEventListener(
  7974. "pointermove",
  7975. this.__resizeMoveHandler || this.onResizeMove,
  7976. { passive: false, capture: true }
  7977. );
  7978. document.addEventListener(
  7979. "pointerup",
  7980. this.__resizeEndHandler || this.endResize,
  7981. { passive: false, once: true, capture: true }
  7982. );
  7983. document.addEventListener(
  7984. "pointercancel",
  7985. this.__resizeCancelHandler || this.endResize,
  7986. { passive: false, once: true, capture: true }
  7987. ); // 功能说明:触控/手势取消时也要结束拖拽 by xu 20260122
  7988. }, 500);
  7989. },
  7990. onResizeMove(e) {
  7991. if (!this.resizing) return;
  7992. if (e?.preventDefault) e.preventDefault();
  7993. const dy = (e?.clientY ?? 0) - this.resizeStartY;
  7994. const minPanelHeight = 83; // header(35) + listMin(48) by xu 20260106
  7995. const prev = Math.max(minPanelHeight, this.resizeStartPrev + dy);
  7996. const next = Math.max(minPanelHeight, this.resizeStartNext - dy);
  7997. // 若其中一个达到最小值,则停止继续挤压 by xu 20260106
  7998. const adjustedDy = prev - this.resizeStartPrev;
  7999. const nextAdjusted = this.resizeStartNext - adjustedDy;
  8000. const appliedPrev = prev;
  8001. const appliedNext = Math.max(minPanelHeight, nextAdjusted);
  8002. this.sectionHeights.splice(this.resizeIndex, 1, appliedPrev);
  8003. this.sectionHeights.splice(this.resizeIndex + 1, 1, appliedNext);
  8004. // 功能说明:强制触发一次 sectionHeights 引用变化,避免某些运行时环境下 splice 未触发视图更新导致“拖拽没反应” by xu 20260122
  8005. this.sectionHeights = (this.sectionHeights || []).slice();
  8006. // 功能说明:兜底——直接写 DOM 的 height,确保视觉立即响应(用于排查/修复某些环境下 render 不更新) by xu 20260122
  8007. try {
  8008. if (this.__resizePrevSectionEl?.style)
  8009. this.__resizePrevSectionEl.style.height = appliedPrev + "px";
  8010. if (this.__resizeNextSectionEl?.style)
  8011. this.__resizeNextSectionEl.style.height = appliedNext + "px";
  8012. } catch (_) {}
  8013. },
  8014. endResize(e) {
  8015. clearTimeout(this.resizeTimer);
  8016. this.resizeTimer = null;
  8017. if (!this.resizing) return;
  8018. if (e?.preventDefault) e.preventDefault();
  8019. const activeGaps = document.querySelectorAll(
  8020. ".ss-sidebar-gap.is-active"
  8021. );
  8022. activeGaps.forEach((g) => g.classList.remove("is-active"));
  8023. this.resizing = false;
  8024. this.resizeIndex = -1;
  8025. this.__resizePrevSectionEl = null; // 功能说明:释放 DOM 引用,避免内存泄漏 by xu 20260122
  8026. this.__resizeNextSectionEl = null; // 功能说明:释放 DOM 引用,避免内存泄漏 by xu 20260122
  8027. document.removeEventListener(
  8028. "pointermove",
  8029. this.__resizeMoveHandler || this.onResizeMove,
  8030. true
  8031. );
  8032. document.removeEventListener(
  8033. "pointercancel",
  8034. this.__resizeCancelHandler || this.endResize,
  8035. true
  8036. ); // 功能说明:清理 cancel 监听,避免残留 by xu 20260122
  8037. },
  8038. },
  8039. watch: {
  8040. panels: {
  8041. handler(nextPanels) {
  8042. this.__syncSectionAutoCollapse(nextPanels);
  8043. },
  8044. deep: true,
  8045. immediate: true,
  8046. },
  8047. list: {
  8048. handler(nextList) {
  8049. if ((this.panels || []).length) return;
  8050. this.__syncSectionAutoCollapse(nextList);
  8051. },
  8052. deep: true,
  8053. immediate: true,
  8054. },
  8055. },
  8056. mounted() {
  8057. clearTimeout(this.resizeTimer);
  8058. this.resizeTimer = null;
  8059. // 功能说明:绑定拖拽事件 handler(用于 add/removeEventListener) by xu 20260122
  8060. if (!this.__resizeMoveHandler)
  8061. this.__resizeMoveHandler = (e) => this.onResizeMove?.(e);
  8062. if (!this.__resizeEndHandler)
  8063. this.__resizeEndHandler = (e) => this.endResize?.(e);
  8064. if (!this.__resizeCancelHandler)
  8065. this.__resizeCancelHandler = (e) => this.endResize?.(e);
  8066. // 功能说明:暂时回退为固定底部留白方案(CSS 控制),后续再定位遮挡根因 by xu 20260115
  8067. },
  8068. beforeUnmount() {
  8069. clearTimeout(this.resizeTimer);
  8070. this.resizeTimer = null;
  8071. document.removeEventListener(
  8072. "pointermove",
  8073. this.__resizeMoveHandler || this.onResizeMove,
  8074. true
  8075. );
  8076. document.removeEventListener(
  8077. "pointerup",
  8078. this.__resizeEndHandler || this.endResize,
  8079. true
  8080. );
  8081. document.removeEventListener(
  8082. "pointercancel",
  8083. this.__resizeCancelHandler || this.endResize,
  8084. true
  8085. );
  8086. },
  8087. render() {
  8088. const SsSidebarButtonsComp = Vue.resolveComponent("ss-sidebar-buttons");
  8089. const SsSidebarChartComp = Vue.resolveComponent("ss-sidebar-chart");
  8090. const SsSidebarListComp = Vue.resolveComponent("ss-sidebar-list");
  8091. const SsSidebarReportTableComp = Vue.resolveComponent(
  8092. "ss-sidebar-report-table"
  8093. );
  8094. const SsIcon = Vue.resolveComponent("ss-icon");
  8095. // 支持 panels(多分区),list/listMode 作为 legacy 兜底 by xu 20260106
  8096. const panels = (this.panels || []).length
  8097. ? this.panels
  8098. : this.list?.length
  8099. ? [
  8100. {
  8101. type: "list",
  8102. title: "已选",
  8103. icon: "",
  8104. mode: this.listMode,
  8105. items: this.list,
  8106. },
  8107. ]
  8108. : [];
  8109. // 功能说明:右侧栏强制移除“对象”tab(兼容后端返回 rbarObj/rbarobj 或直接返回中文“对象”标题) by xu 20260116
  8110. const panelsNoObj = (panels || []).filter((p) => {
  8111. const k = String(p?._tabKey ?? "")
  8112. .trim()
  8113. .toLowerCase();
  8114. const t = String(p?.title ?? "").trim();
  8115. if (k === "rbarobj") return false;
  8116. if (t === "对象") return false;
  8117. return true;
  8118. });
  8119. // 功能说明:report-table 作为底部报表区(放在统计图下面),不参与可拖拽 section 面板 by xu 20260115
  8120. const sectionPanels = panelsNoObj.filter(
  8121. (p) => p?.type !== "chart" && p?.type !== "report-table"
  8122. );
  8123. const chartPanels = panelsNoObj.filter((p) => p?.type === "chart");
  8124. const reportPanels = panelsNoObj.filter(
  8125. (p) => p?.type === "report-table"
  8126. );
  8127. this.ensureSectionHeights(sectionPanels.length);
  8128. // 功能说明:补齐 chart/report 折叠数组长度 by xu 20260116
  8129. this.chartCollapsed = Array.from(
  8130. { length: chartPanels.length },
  8131. (_, i) => !!this.chartCollapsed?.[i]
  8132. );
  8133. this.chartHeaderTitleDownAt = Array.from(
  8134. { length: chartPanels.length },
  8135. (_, i) => this.chartHeaderTitleDownAt?.[i] ?? 0
  8136. );
  8137. this.reportCollapsed = Array.from(
  8138. { length: reportPanels.length },
  8139. (_, i) => !!this.reportCollapsed?.[i]
  8140. );
  8141. return Vue.h("div", { class: "ss-sidebar" }, [
  8142. this.buttons?.length
  8143. ? Vue.h(SsSidebarButtonsComp, { items: this.buttons })
  8144. : null,
  8145. Vue.h(
  8146. "div",
  8147. { class: "ss-sidebar__inner" },
  8148. [
  8149. ...(this.charts || []).map((c) =>
  8150. Vue.h(SsSidebarChartComp, {
  8151. options: c?.options || {},
  8152. height: c?.height || "200px",
  8153. })
  8154. ),
  8155. // 可拖拽的业务面板容器 by xu 20260106
  8156. Vue.h(
  8157. "div",
  8158. { class: "ss-sidebar-sections", style: { flex: "0 0 auto" } },
  8159. sectionPanels.flatMap((p, idx) => {
  8160. const panelContent =
  8161. p?.type === "report-table"
  8162. ? Vue.h(SsSidebarReportTableComp, {
  8163. key: `ss-sidebar-report-in-section-${idx}-${
  8164. p?.title ?? ""
  8165. }`,
  8166. title: p?.title ?? "",
  8167. icon: p?.icon ?? "",
  8168. iconClass: p?.iconClass ?? "",
  8169. items: p?.items || [],
  8170. onOpen: (srv, ctx) => p?.onOpen?.(srv, ctx),
  8171. })
  8172. : Vue.h(SsSidebarListComp, {
  8173. key: `ss-sidebar-list-${idx}-${p?.title ?? ""}`,
  8174. title: p?.title ?? "",
  8175. icon: p?.icon ?? "",
  8176. count: p?.count ?? p?.items?.length ?? "",
  8177. closable: !!p?.closable,
  8178. searchable: !!p?.searchable,
  8179. searchInHeader: !!p?.searchInHeader,
  8180. headerFilters: p?.headerFilters || [],
  8181. headerSearchButton: !!p?.headerSearchButton,
  8182. searchPlaceholder: p?.searchPlaceholder ?? "搜索",
  8183. itemLayout: p?.itemLayout ?? "simple",
  8184. itemAction: p?.itemAction ?? true,
  8185. collapsible: true,
  8186. collapsed: !!this.sectionCollapsed?.[idx],
  8187. onToggleCollapse: () =>
  8188. this.toggleSectionCollapse?.(idx),
  8189. iconClass: p?.iconClass ?? "",
  8190. items: p?.items || [],
  8191. mode: p?.mode || "search",
  8192. onSelect: (item) => this.$emit("select", item),
  8193. onRemove: (item) => this.$emit("remove", item),
  8194. onClear: () => p?.onClear?.(),
  8195. onSearch: (payload) => p?.onSearch?.(payload),
  8196. });
  8197. const section = Vue.h(
  8198. "div",
  8199. {
  8200. class: {
  8201. "ss-sidebar-section": true,
  8202. "is-collapsed": !!this.sectionCollapsed?.[idx],
  8203. },
  8204. key: `ss-sidebar-section-${idx}-${p?.type ?? "list"}-${
  8205. p?.title ?? ""
  8206. }`,
  8207. style: {
  8208. height: (this.sectionHeights[idx] ?? 190) + "px",
  8209. flex: "0 0 auto",
  8210. },
  8211. },
  8212. [
  8213. Vue.h("div", { class: "ss-sidebar-section__content" }, [
  8214. panelContent,
  8215. ]),
  8216. ]
  8217. );
  8218. const gap =
  8219. idx < sectionPanels.length - 1
  8220. ? Vue.h("div", {
  8221. class: "ss-sidebar-gap",
  8222. onPointerdown: (e) => this.startResize(idx, e),
  8223. })
  8224. : null;
  8225. return gap ? [section, gap] : [section];
  8226. })
  8227. ),
  8228. // 图表区固定在底部(hover 弹出大图) by xu 20260106
  8229. ...chartPanels.map((p, chartIdx) =>
  8230. Vue.h(
  8231. "div",
  8232. {
  8233. class: {
  8234. "ss-sidebar-panel": true,
  8235. "ss-sidebar-chart-panel": true,
  8236. "is-collapsed": !!this.chartCollapsed?.[chartIdx],
  8237. },
  8238. style: { flex: "0 0 auto", minHeight: "37px" },
  8239. "data-chart-idx": chartIdx,
  8240. key: `ss-sidebar-chart-${chartIdx}-${p?.title ?? ""}`,
  8241. },
  8242. [
  8243. p?.title
  8244. ? Vue.h(
  8245. "div",
  8246. {
  8247. class: "ss-sidebar-panel__header",
  8248. onDblclick: (e) => {
  8249. e?.preventDefault?.();
  8250. e?.stopPropagation?.();
  8251. console.log("[SsSidebar] chart header dblclick", {
  8252. idx: chartIdx,
  8253. title: p?.title,
  8254. });
  8255. this.toggleChartCollapse?.(chartIdx);
  8256. },
  8257. },
  8258. [
  8259. Vue.h("div", { class: "ss-sidebar-panel__title" }, [
  8260. p?.iconClass
  8261. ? Vue.h(SsIcon, {
  8262. class:
  8263. p.iconClass + " ss-sidebar-panel__icon",
  8264. })
  8265. : p?.icon
  8266. ? Vue.h(SsIcon, {
  8267. name: p.icon,
  8268. size: "16px",
  8269. class: "ss-sidebar-panel__icon",
  8270. })
  8271. : null,
  8272. Vue.h("span", null, p.title),
  8273. ]),
  8274. Vue.h("div", { class: "ss-sidebar-panel__tools" }),
  8275. ]
  8276. )
  8277. : null,
  8278. this.chartCollapsed?.[chartIdx]
  8279. ? null
  8280. : Vue.h(Vue.resolveComponent("ss-sidebar-chart-hover"), {
  8281. title: p?.title ?? "",
  8282. iconClass: p?.iconClass ?? "",
  8283. icon: p?.icon ?? "",
  8284. options: p?.options || {},
  8285. height: p?.height || "240px",
  8286. }),
  8287. ]
  8288. )
  8289. ),
  8290. ...reportPanels.map((p, reportIdx) =>
  8291. Vue.h(
  8292. "div",
  8293. {
  8294. class: {
  8295. "ss-sidebar-report-panel-wrap": true,
  8296. "ss-sidebar-report-panel": true,
  8297. "is-collapsed": !!this.reportCollapsed?.[reportIdx],
  8298. },
  8299. style: { flex: "0 0 auto", minHeight: "37px" },
  8300. "data-report-idx": reportIdx,
  8301. key: `ss-sidebar-report-wrap-${reportIdx}-${p?.title ?? ""}`,
  8302. },
  8303. [
  8304. Vue.h(SsSidebarReportTableComp, {
  8305. key: `ss-sidebar-report-${reportIdx}-${p?.title ?? ""}`,
  8306. title: p?.title ?? "",
  8307. icon: p?.icon ?? "",
  8308. iconClass: p?.iconClass ?? "",
  8309. items: p?.items || [],
  8310. collapsible: true,
  8311. collapsed: !!this.reportCollapsed?.[reportIdx],
  8312. onToggleCollapse: () =>
  8313. this.toggleReportCollapse?.(reportIdx),
  8314. onOpen: (srv, ctx) => p?.onOpen?.(srv, ctx),
  8315. }),
  8316. ]
  8317. )
  8318. ),
  8319. ].filter(Boolean)
  8320. ),
  8321. ]);
  8322. },
  8323. };
  8324. // ss-folder-card 文件夹卡片
  8325. const SsFolderCard = {
  8326. name: "SsFolderCard",
  8327. props: {
  8328. item: {
  8329. type: Object,
  8330. required: true,
  8331. },
  8332. },
  8333. data() {
  8334. return {
  8335. showButtons: false,
  8336. };
  8337. },
  8338. emits: ["click", "change"],
  8339. setup(props, { emit }) {
  8340. const item = props.item;
  8341. const showChildren = ref(false);
  8342. const eventBus = window.parent.sharedEventBus;
  8343. const itemWidth = Vue.computed(() => {
  8344. // 功能说明:页面改为 grid 等分布局后,卡片宽度交给容器控制,这里固定 100% by xu 20260116
  8345. return "100%";
  8346. });
  8347. onMounted(() => {
  8348. eventBus.subscribe("folderPath", (path) => {
  8349. const currentPath = path || [];
  8350. // 如果当前文件夹不在路径中,则销毁视图
  8351. if (
  8352. !currentPath.some((item) => item.folder.title === props.item.title)
  8353. ) {
  8354. showChildren.value = false;
  8355. }
  8356. });
  8357. });
  8358. const onItemClick = (e) => {
  8359. if (e && e.stopPropagation) {
  8360. e.stopPropagation();
  8361. }
  8362. // 单击只处理 active 状态
  8363. if (e && e.currentTarget) {
  8364. const allListCards = document.querySelectorAll(
  8365. ".knowledge-item-container"
  8366. );
  8367. const allFolderCards = document.querySelectorAll(".ss-folder-list");
  8368. allListCards.forEach((card) => card.classList.remove("active"));
  8369. allFolderCards.forEach((card) => card.classList.remove("active"));
  8370. e.currentTarget.classList.add("active");
  8371. } else {
  8372. // 如果是数据对象,需要找到对应的 DOM 元素
  8373. const allListCards = document.querySelectorAll(
  8374. ".knowledge-item-container"
  8375. );
  8376. const allFolderCards = document.querySelectorAll(".ss-folder-list");
  8377. allListCards.forEach((card) => card.classList.remove("active"));
  8378. allFolderCards.forEach((card) => card.classList.remove("active"));
  8379. // 找到标题匹配的文件夹元素
  8380. const targetFolder = Array.from(allFolderCards).find((card) =>
  8381. card.textContent.includes(e.title)
  8382. );
  8383. if (targetFolder) {
  8384. targetFolder.classList.add("active");
  8385. }
  8386. }
  8387. emit("click", item);
  8388. };
  8389. // 修改双击处理函数
  8390. const handleFolderDblClick = (folder, e) => {
  8391. if (e) e.stopPropagation();
  8392. if (folder.children?.length) {
  8393. showChildren.value = true;
  8394. const pathInfo = {
  8395. title: folder.title,
  8396. folder: folder,
  8397. };
  8398. const currentPath = eventBus.getState("folderPath") || [];
  8399. if (!currentPath.some((item) => item.title === folder.title)) {
  8400. eventBus.publish("folderPath", [...currentPath, pathInfo]);
  8401. }
  8402. }
  8403. };
  8404. const onItemChange = (e, icon, index) => {
  8405. e.stopPropagation();
  8406. props.item.buttons[0].onclick();
  8407. // emit("change", { item: props.item, icon, index });
  8408. };
  8409. return {
  8410. item,
  8411. itemWidth,
  8412. showChildren,
  8413. onItemClick,
  8414. onItemChange,
  8415. handleFolderDblClick,
  8416. };
  8417. },
  8418. render() {
  8419. const SsCartListIcon = Vue.resolveComponent("ss-cart-list-icon");
  8420. if (this.showChildren) {
  8421. return h(SsFolderCartView, {
  8422. folder: this.item,
  8423. });
  8424. }
  8425. return Vue.h(
  8426. "div",
  8427. {
  8428. class: { "ss-folder-list": true, active: this.item.active },
  8429. onClick: (e) => {
  8430. e.stopPropagation();
  8431. this.onItemClick(e);
  8432. },
  8433. onDblclick: (e) => this.handleFolderDblClick(this.item, e),
  8434. style: { width: this.itemWidth },
  8435. },
  8436. [
  8437. // 文件夹特有的装饰元素
  8438. Vue.h("div", { class: "ss-folder-list-trapezoid" }),
  8439. Vue.h("div", { class: "ss-folder-list-top-transparent" }),
  8440. Vue.h("div", { class: "ss-folder-list-top" }),
  8441. Vue.h("div", { class: "ss-folder-list-right" }),
  8442. // header 部分(按钮)
  8443. this.item?.buttons?.length > 0 &&
  8444. Vue.h(
  8445. "div",
  8446. {
  8447. class: "header",
  8448. onMouseenter: () => (this.showButtons = true),
  8449. onMouseleave: () => (this.showButtons = false),
  8450. onClick: (e) => this.onItemChange(e, this.item.buttons[0], 0),
  8451. },
  8452. [
  8453. // this.item?.buttons?.length > 0 &&
  8454. Vue.h("div", {
  8455. class: "cart-list-setting cart-list-icon",
  8456. title: this.item?.buttons?.[0]?.title,
  8457. }),
  8458. // this.item?.buttons?.length > 0 &&
  8459. this.showButtons &&
  8460. this.item?.buttons?.length > 1 &&
  8461. Vue.h(
  8462. "div",
  8463. {
  8464. class: "cart-list-button-popup",
  8465. },
  8466. this.item.buttons.map((btn) =>
  8467. Vue.h(
  8468. "div",
  8469. {
  8470. onClick: (e) => {
  8471. e.stopPropagation();
  8472. btn.onclick?.();
  8473. },
  8474. },
  8475. [
  8476. btn.class &&
  8477. Vue.h(SsCartListIcon, {
  8478. class: [btn.class],
  8479. }),
  8480. Vue.h("span", null, btn.title),
  8481. ]
  8482. )
  8483. )
  8484. ),
  8485. ]
  8486. ),
  8487. // body 部分
  8488. Vue.h("div", { class: "body" }, [
  8489. Vue.h("div", { class: "box-header" }, [
  8490. Vue.h("div", null, this.item.title),
  8491. ]),
  8492. Vue.h(
  8493. "div",
  8494. {
  8495. class: !this.item.thumb ? "no-thumb box-body" : "box-body",
  8496. },
  8497. [
  8498. this.item.thumb
  8499. ? Vue.h("div", { class: "left" }, [
  8500. Vue.h("img", {
  8501. src: this.item.thumb,
  8502. alt: "Thumbnail",
  8503. class: "imgUnHandle",
  8504. style: {
  8505. "object-fit": "cover",
  8506. width: "100%",
  8507. height: "100%",
  8508. },
  8509. }),
  8510. ])
  8511. : null,
  8512. Vue.h("div", { class: "right" }, [
  8513. ...this.item.tags.map((tag) => {
  8514. const [key, value] = Object.entries(tag)[0];
  8515. return Vue.h(
  8516. "div",
  8517. {
  8518. class: "title",
  8519. title: `${key}: ${value}`,
  8520. },
  8521. `${key}: ${value}`
  8522. );
  8523. }),
  8524. ]),
  8525. ]
  8526. ),
  8527. ]),
  8528. ]
  8529. );
  8530. },
  8531. };
  8532. // SsFolderCartView 组件 - 用于显示文件夹内容
  8533. const SsFolderCartView = {
  8534. name: "SsFolderCartView",
  8535. props: {
  8536. folder: {
  8537. type: Object,
  8538. required: true,
  8539. },
  8540. },
  8541. emits: ["click"],
  8542. setup(props, { emit }) {
  8543. const eventBus = window.parent.sharedEventBus;
  8544. const currentFolder = ref(props.folder);
  8545. const showChildren = ref(false);
  8546. const onItemClick = (e) => {
  8547. if (e && e.stopPropagation) {
  8548. e.stopPropagation();
  8549. }
  8550. // 单击只处理 active 状态
  8551. if (e && e.currentTarget) {
  8552. const allListCards = document.querySelectorAll(
  8553. ".knowledge-item-container"
  8554. );
  8555. const allFolderCards = document.querySelectorAll(".ss-folder-list");
  8556. allListCards.forEach((card) => card.classList.remove("active"));
  8557. allFolderCards.forEach((card) => card.classList.remove("active"));
  8558. e.currentTarget.classList.add("active");
  8559. } else {
  8560. // 如果是数据对象,需要找到对应的 DOM 元素
  8561. const allListCards = document.querySelectorAll(
  8562. ".knowledge-item-container"
  8563. );
  8564. const allFolderCards = document.querySelectorAll(".ss-folder-list");
  8565. allListCards.forEach((card) => card.classList.remove("active"));
  8566. allFolderCards.forEach((card) => card.classList.remove("active"));
  8567. // 找到标题匹配的文件夹元素
  8568. const targetFolder = Array.from(allFolderCards).find((card) =>
  8569. card.textContent.includes(e.title)
  8570. );
  8571. if (targetFolder) {
  8572. targetFolder.classList.add("active");
  8573. }
  8574. }
  8575. emit("click", props.folder);
  8576. };
  8577. const handleFolderDblClick = (folder, e) => {
  8578. if (e) e.stopPropagation();
  8579. if (folder.children?.length) {
  8580. showChildren.value = true;
  8581. const pathInfo = {
  8582. title: folder.title,
  8583. folder: folder,
  8584. };
  8585. const currentPath = eventBus.getState("folderPath") || [];
  8586. if (!currentPath.some((item) => item.title === folder.title)) {
  8587. eventBus.publish("folderPath", [...currentPath, pathInfo]);
  8588. currentFolder.value = folder;
  8589. }
  8590. }
  8591. };
  8592. const goBack = (targetFolder) => {
  8593. if (targetFolder === null) {
  8594. // 返回根目录
  8595. eventBus.publish("folderPath", []);
  8596. } else {
  8597. currentFolder.value = targetFolder;
  8598. }
  8599. };
  8600. return {
  8601. currentFolder,
  8602. showChildren,
  8603. onItemClick,
  8604. handleFolderDblClick,
  8605. goBack,
  8606. };
  8607. },
  8608. render() {
  8609. return h(
  8610. "div",
  8611. {
  8612. class: "page-container",
  8613. style: {
  8614. position: "fixed",
  8615. top: 0,
  8616. left: 0,
  8617. width: "100%",
  8618. height: "100%",
  8619. background: "var(--lightgray)",
  8620. padding: "20px 0",
  8621. zIndex: 1000,
  8622. },
  8623. },
  8624. [
  8625. // 搜索栏
  8626. h("div", { class: "search-bar" }, [
  8627. h("div", { class: "search-bar-contaienr" }, [
  8628. h(SsBreadcrumb, {
  8629. level: {
  8630. onBack: this.goBack,
  8631. },
  8632. }),
  8633. ]),
  8634. ]),
  8635. // 内容区域
  8636. h(
  8637. "div",
  8638. {
  8639. class: "content-area item-content-area",
  8640. style: { gap: "20px" },
  8641. },
  8642. [
  8643. ...(this.currentFolder.children || []).map((child, index) =>
  8644. h(child.children ? SsFolderCard : SsListCard, {
  8645. key: index,
  8646. item: child,
  8647. onClick: (e) => this.onItemClick(e),
  8648. onDblclick: (e) => this.handleFolderDblClick(child, e),
  8649. })
  8650. ),
  8651. ]
  8652. ),
  8653. ]
  8654. );
  8655. },
  8656. };
  8657. // ss-page分页
  8658. const SsPage = {
  8659. name: "SsPage",
  8660. props: {
  8661. total: {
  8662. type: Number,
  8663. required: true,
  8664. },
  8665. size: {
  8666. type: Number,
  8667. default: 10,
  8668. },
  8669. page: {
  8670. type: Number,
  8671. default: 1,
  8672. },
  8673. onChange: {
  8674. type: Function,
  8675. default: () => {},
  8676. },
  8677. },
  8678. setup(props) {
  8679. const totalItems = ref(props.total); // 总条目数
  8680. const totalPages = ref(Math.ceil(props.total / props.size));
  8681. const currentPage = ref(props.page); // 当前页码
  8682. // 计算显示的信息
  8683. const pageInfo = ref(
  8684. `共${totalItems.value}条,第 ${currentPage.value}/${totalPages.value} 页`
  8685. );
  8686. // 上一页的逻辑
  8687. const goToPreviousPage = (e) => {
  8688. e.preventDefault(); // 阻止默认行为
  8689. if (currentPage.value > 1) {
  8690. currentPage.value -= 1;
  8691. updatePageInfo();
  8692. props.onChange?.({
  8693. pageNo: currentPage.value, // 当前页码
  8694. rowNumPer: props.size, // 每页条数
  8695. rowNum: props.total, // 总记录数
  8696. });
  8697. }
  8698. };
  8699. // 下一页的逻辑
  8700. const goToNextPage = (e) => {
  8701. e.preventDefault(); // 阻止默认行为
  8702. if (currentPage.value < totalPages.value) {
  8703. currentPage.value += 1;
  8704. updatePageInfo();
  8705. props.onChange?.({
  8706. pageNo: currentPage.value, // 当前页码
  8707. rowNumPer: props.size, // 每页条数
  8708. rowNum: props.total, // 总记录数
  8709. });
  8710. }
  8711. };
  8712. // 更新页码信息的函数
  8713. const updatePageInfo = () => {
  8714. pageInfo.value = `共${totalItems.value}条,第 ${currentPage.value}/${totalPages.value} 页`;
  8715. };
  8716. return {
  8717. pageInfo,
  8718. totalPages,
  8719. goToPreviousPage,
  8720. goToNextPage,
  8721. };
  8722. },
  8723. render(props, { slots, emit }) {
  8724. return Vue.h("div", { class: "pager-container" }, [
  8725. Vue.h("input", { type: "hidden", name: "rowNum", value: props.total }),
  8726. Vue.h("input", {
  8727. type: "hidden",
  8728. name: "rowNumPer",
  8729. value: props.size,
  8730. }),
  8731. Vue.h("input", {
  8732. type: "hidden",
  8733. name: "pageCount",
  8734. value: this.totalPages,
  8735. }),
  8736. Vue.h("input", { type: "hidden", name: "pageNo", value: props.page }),
  8737. Vue.h("div", { class: "pager-content" }, [
  8738. Vue.h("div", { class: "info" }, this.pageInfo),
  8739. Vue.h(
  8740. "div",
  8741. { class: "btn" },
  8742. Vue.h(
  8743. "button",
  8744. { onClick: (e) => this.goToPreviousPage(e) },
  8745. "上一页"
  8746. )
  8747. ),
  8748. Vue.h(
  8749. "div",
  8750. { class: "btn" },
  8751. Vue.h("button", { onClick: (e) => this.goToNextPage(e) }, "下一页")
  8752. ),
  8753. ]),
  8754. ]);
  8755. },
  8756. };
  8757. // ss-right-info 一级页面右边栏
  8758. const SSRightInfo = {
  8759. name: "SSRightInfo",
  8760. setup() {
  8761. // 初始化响应式数据
  8762. const item = ref({
  8763. thumb: "images/example/project-img.png", // 更换为适合你项目的实际路径
  8764. title: "工业和信息化产业高质量发展资金",
  8765. });
  8766. return {
  8767. item,
  8768. };
  8769. },
  8770. render() {
  8771. return Vue.h("div", { class: "info-container" }, [
  8772. Vue.h("div", { class: "header" }, [
  8773. Vue.h("div", [
  8774. Vue.h("img", {
  8775. src: this.item.thumb,
  8776. class: "imgUnHandle",
  8777. style: { "object-fit": "cover", width: "100%", height: "100%" },
  8778. }), // 将 ImageViewer 替换为 img 标签
  8779. ]),
  8780. Vue.h("div", [Vue.h("div", this.item.title)]),
  8781. ]),
  8782. Vue.h("div", { class: "section-container" }, [
  8783. Vue.h("div", { class: "section" }, [
  8784. Vue.h("div", { class: "title" }, "合同"),
  8785. Vue.h("div", { class: "text" }, "合同总金额:42,399,320"),
  8786. Vue.h(
  8787. "div",
  8788. { class: "a" },
  8789. "《工业和信息化产业高质量发展资金补助合同》"
  8790. ),
  8791. ]),
  8792. Vue.h("div", { class: "section" }, [
  8793. Vue.h("div", { class: "title" }, "发票"),
  8794. Vue.h("div", { class: "text" }, "应开发票总额:42,399,320"),
  8795. Vue.h("div", { class: "text" }, "已开发票金额:17,235,345"),
  8796. Vue.h("div", { class: "text" }, "未开发票金额:25,163,975"),
  8797. ]),
  8798. Vue.h("div", { class: "section" }, [
  8799. Vue.h("div", { class: "title" }, "项目组成员"),
  8800. Vue.h("div", { class: "text" }, "我司:3人"),
  8801. Vue.h("div", { class: "text" }, "对方:2人"),
  8802. Vue.h("div", { class: "text" }, "项目负责人:张三"),
  8803. ]),
  8804. Vue.h("div", { class: "section" }, [
  8805. Vue.h("div", { class: "title" }, "采购"),
  8806. Vue.h("div", { class: "text" }, "总额:999,320"),
  8807. Vue.h("div", { class: "text" }, "已付金额:335,345"),
  8808. Vue.h("div", { class: "text" }, "未付金额:663,975"),
  8809. ]),
  8810. ]),
  8811. ]);
  8812. },
  8813. };
  8814. //
  8815. const SsSuccessPopup = {
  8816. name: "SsSuccessPopup",
  8817. props: {
  8818. right: {
  8819. type: String,
  8820. default: "20px",
  8821. },
  8822. bottom: {
  8823. type: String,
  8824. default: "calc(100% + 5px)",
  8825. },
  8826. },
  8827. setup(props, { expose }) {
  8828. // 响应式状态:是否可见
  8829. const visible = ref(false);
  8830. // 计算样式
  8831. const style = computed(() => {
  8832. return {
  8833. "--message-dialog-right": props.right,
  8834. "--message-dialog-bottom": props.bottom,
  8835. };
  8836. });
  8837. // 显示对话框的方法
  8838. const show = () => {
  8839. visible.value = true;
  8840. };
  8841. // 隐藏对话框的方法
  8842. const hide = () => {
  8843. visible.value = false;
  8844. };
  8845. // 将方法暴露给外部使用
  8846. expose({ show, hide });
  8847. // 返回渲染函数
  8848. return () => {
  8849. if (!visible.value) return null;
  8850. const SsIcon = resolveComponent("ss-icon");
  8851. return h(
  8852. "div",
  8853. {
  8854. class: "success-popup",
  8855. style: style.value,
  8856. onClick: (e) => e.stopPropagation(),
  8857. },
  8858. [
  8859. h("div", { class: "left" }, [
  8860. h("div", { class: "icon" }, [
  8861. h(SsIcon, { name: "check", size: "36px" }),
  8862. ]),
  8863. ]),
  8864. h("div", { class: "right" }, [
  8865. h("div", { class: "title" }, "提交成功"),
  8866. h("div", { class: "desc" }, "您的信息已成功提交。"),
  8867. ]),
  8868. ]
  8869. );
  8870. };
  8871. },
  8872. };
  8873. const SsErrorDialog = {
  8874. name: "SsErrorDialog",
  8875. setup(props, { emit }) {
  8876. const visible = ref(false);
  8877. const style = computed(() => {
  8878. return {};
  8879. });
  8880. const show = () => {
  8881. visible.value = true;
  8882. };
  8883. const hide = () => {
  8884. visible.value = false;
  8885. };
  8886. const onBack = () => {
  8887. emit("back");
  8888. hide();
  8889. };
  8890. return {
  8891. visible,
  8892. style,
  8893. show,
  8894. hide,
  8895. onBack,
  8896. };
  8897. },
  8898. render() {
  8899. const SsIcon = resolveComponent("ss-icon");
  8900. return this.visible
  8901. ? h(
  8902. "div",
  8903. {
  8904. class: "errorDialog",
  8905. style: this.style,
  8906. onClick: (event) => event.stopPropagation(),
  8907. },
  8908. [
  8909. h("div", { class: "body" }, [
  8910. h("div", { class: "left" }, [
  8911. h("div", { class: "icon" }, [
  8912. h(SsIcon, { name: "close", size: "36px" }),
  8913. ]),
  8914. ]),
  8915. h("div", { class: "right" }, [
  8916. h("div", { class: "title" }, "操作失败"),
  8917. h("div", { class: "desc" }, "请点击返回以继续。"),
  8918. ]),
  8919. ]),
  8920. h("div", { class: "footer" }, [
  8921. h("div", { class: "left" }),
  8922. h("div", { class: "right" }, [
  8923. h(
  8924. "div",
  8925. {
  8926. class: "btn",
  8927. onClick: this.onBack,
  8928. },
  8929. [h(SsIcon, { name: "arrow-left-line" }), h("div", "返回")]
  8930. ),
  8931. ]),
  8932. ]),
  8933. ]
  8934. )
  8935. : null;
  8936. },
  8937. };
  8938. /**
  8939. * 审核链条
  8940. * @name ss-verify
  8941. * @param { Array } verify-list 审核节点列表
  8942. * @property { Array } verify-list 审核节点列表
  8943. * @example <ss-verify :verify-list="verifyList"></ss-verify>
  8944. * verify-list [
  8945. * {
  8946. * groupName: "", // 群组名称
  8947. * open: true, // 默认是否展开
  8948. * children:[ //群组里的人员
  8949. * {
  8950. * thumb: "images/example/user-4.png", // 头像
  8951. * name: "李丽思 ", // 姓名
  8952. * role: "人事处处长", // 角色
  8953. * description: "同意。", // 审核意见
  8954. * time: "09:38 08/11", // 审核时间
  8955. * video: false, // false不显示/true显示 视频icon
  8956. * link: false, // false不显示/true显示 链接icon 后续应该是附件
  8957. * }
  8958. * ]
  8959. * }
  8960. * ]
  8961. */
  8962. const SsVerify = {
  8963. name: "SsVerify",
  8964. props: {
  8965. verifyList: {
  8966. type: Array,
  8967. required: true,
  8968. },
  8969. },
  8970. setup(props) {
  8971. const toggleOpen = (item) => {
  8972. item.open = !item.open;
  8973. };
  8974. onMounted(() => {
  8975. setTimeout(() => {
  8976. const lastOpenGroup = document.querySelector(".group-item-last-open");
  8977. console.log("lastOpenGroup", lastOpenGroup);
  8978. if (lastOpenGroup) {
  8979. const nodes = $(lastOpenGroup).find(".verify-node-container");
  8980. if (nodes.length) {
  8981. let totalHeight = 0;
  8982. const gudingHeight = 100;
  8983. if (nodes.length === 1) {
  8984. totalHeight = gudingHeight;
  8985. } else {
  8986. // 累加除最后一个节点外的所有节点高度
  8987. for (let i = 0; i < nodes.length - 1; i++) {
  8988. totalHeight += $(nodes[i]).outerHeight();
  8989. }
  8990. totalHeight += gudingHeight;
  8991. }
  8992. console.log("节点信息:", {
  8993. 节点总数: nodes.length,
  8994. 计算后的高度: totalHeight,
  8995. });
  8996. lastOpenGroup.style.setProperty(
  8997. "--group-line-height",
  8998. `${totalHeight}px`
  8999. );
  9000. }
  9001. }
  9002. }, 0);
  9003. });
  9004. return {
  9005. toggleOpen,
  9006. };
  9007. },
  9008. render() {
  9009. const SsIcon = resolveComponent("ss-icon");
  9010. const SsCommonIcon = resolveComponent("ss-common-icon");
  9011. const SsVerifyNode = resolveComponent("ss-verify-node");
  9012. return h(
  9013. "div",
  9014. { class: "verify-nodes" },
  9015. this.verifyList.map((item, i) =>
  9016. h(
  9017. "div",
  9018. {
  9019. key: i,
  9020. class: {
  9021. "group-item": true,
  9022. "group-item-last-open":
  9023. i === this.verifyList.length - 1 && item.open,
  9024. },
  9025. },
  9026. [
  9027. h(
  9028. "div",
  9029. {
  9030. class: "group-item-title",
  9031. onClick: () => this.toggleOpen(item),
  9032. },
  9033. [
  9034. h("div", { class: "icon" }, [
  9035. item.open
  9036. ? h(SsCommonIcon, { class: "common-icon-folder-open" })
  9037. : h(SsCommonIcon, { class: "common-icon-folder-close" }),
  9038. h(
  9039. "div",
  9040. {
  9041. class: "num",
  9042. style: { top: item.open ? "60%" : "55%" },
  9043. },
  9044. item.children?.length || 0
  9045. ),
  9046. ]),
  9047. h("div", { class: "name" }, item.groupName),
  9048. ]
  9049. ),
  9050. item.open && item.children?.length > 0
  9051. ? h(
  9052. "div",
  9053. { class: "group-item-children" },
  9054. item.children.map((citem, j) =>
  9055. h(SsVerifyNode, {
  9056. key: j,
  9057. item: citem,
  9058. // isGroup: i + 1 !== this.verifyList.length,
  9059. isGroup: true,
  9060. })
  9061. )
  9062. )
  9063. : null,
  9064. ]
  9065. )
  9066. )
  9067. );
  9068. },
  9069. };
  9070. /**
  9071. * 审核页面的审核节点
  9072. * @name ss-verify-node
  9073. * @param {Object} item 审核节点信息
  9074. * @param {Boolean} isGroup 是否为分组节点
  9075. */
  9076. const SsVerifyNode = {
  9077. name: "SsVerifyNode",
  9078. props: {
  9079. item: {
  9080. type: Object,
  9081. required: true,
  9082. },
  9083. isGroup: {
  9084. type: Boolean,
  9085. default: false,
  9086. },
  9087. },
  9088. render() {
  9089. const SsIcon = resolveComponent("ss-icon");
  9090. const SsCommonIcon = resolveComponent("ss-common-icon");
  9091. return Vue.h("div", { class: "verify-node-container" }, [
  9092. Vue.h("div", { class: "info" }, [
  9093. Vue.h("div", { class: "avatar" }, [
  9094. Vue.h("img", {
  9095. src: this.item.thumb,
  9096. style: {
  9097. width: "50px",
  9098. height: "50px",
  9099. borderRadius: "50%",
  9100. },
  9101. }),
  9102. ]),
  9103. Vue.h("div", { class: "desc" }, [
  9104. Vue.h("div", this.item.name),
  9105. Vue.h("div", this.item.role),
  9106. ]),
  9107. Vue.h("div", { class: "link" }, [
  9108. Vue.h("div", [
  9109. this.item.video
  9110. ? Vue.h(SsCommonIcon, { class: "common-icon-video" })
  9111. : null,
  9112. this.item.link
  9113. ? Vue.h(SsCommonIcon, {
  9114. class: "common-icon-paper-clip",
  9115. })
  9116. : null,
  9117. ]),
  9118. ]),
  9119. ]),
  9120. Vue.h(
  9121. "div",
  9122. {
  9123. class: {
  9124. description: true,
  9125. link: this.isGroup,
  9126. },
  9127. attrs: { "data-num": "3" },
  9128. },
  9129. [Vue.h("div", this.item.description)]
  9130. ),
  9131. Vue.h("div", { class: "time" }, this.item.time),
  9132. ]);
  9133. },
  9134. };
  9135. /**
  9136. * 智能识别图片的左侧图片播放 可以放大缩小旋转图片
  9137. * @name ss-orc-img-box
  9138. * @param { Object } image-obj 包含图片的url, 和图片的名称
  9139. *
  9140. */
  9141. const SsOrcImgBox = {
  9142. name: "SsOrcImgBox",
  9143. props: {
  9144. imageObj: {
  9145. type: Object,
  9146. required: true,
  9147. },
  9148. },
  9149. setup(props) {
  9150. const zoom = ref(1);
  9151. const rotation = ref(0);
  9152. const containerWidth = ref(0);
  9153. const containerHeight = ref(0);
  9154. const container = ref(null);
  9155. const imgPosition = ref({ x: 0, y: 0 });
  9156. const isDragging = ref(false);
  9157. const lastMousePosition = ref({ x: 0, y: 0 });
  9158. const imgStyle = computed(() => ({
  9159. width: `${zoom.value * 100}%`,
  9160. height: `${zoom.value * 100}%`,
  9161. transform: `rotate(${rotation.value}deg) translate(${imgPosition.value.x}px, ${imgPosition.value.y}px)`,
  9162. transformOrigin: "center center",
  9163. cursor: isDragging.value ? "grabbing" : "grab",
  9164. }));
  9165. const resetZoom = () => {
  9166. zoom.value = 1;
  9167. rotation.value = rotation.value + 90;
  9168. imgPosition.value = { x: 0, y: 0 };
  9169. };
  9170. const handleRangeChange = (event) => {
  9171. const value = event.target.value / 50; // 0 到 100 映射到 0 到 2 的缩放
  9172. zoom.value = Math.max(value, 0.1); // 设置最小缩放值为 0.1
  9173. };
  9174. const updateImgBoxDimensions = () => {
  9175. if (container.value) {
  9176. containerWidth.value = container.value.clientWidth;
  9177. containerHeight.value = container.value.clientHeight;
  9178. }
  9179. };
  9180. const onMouseDown = (event) => {
  9181. isDragging.value = true;
  9182. lastMousePosition.value = { x: event.clientX, y: event.clientY };
  9183. };
  9184. const onMouseMove = (event) => {
  9185. if (isDragging.value) {
  9186. const dx = event.clientX - lastMousePosition.value.x;
  9187. const dy = event.clientY - lastMousePosition.value.y;
  9188. // 防止旋转后拖动的x,y反转
  9189. // 首先将当前旋转角度从度数转换为弧度,因为 JavaScript 的 Math 库使用弧度
  9190. const angle = rotation.value * (Math.PI / 180);
  9191. // 使用基本的二维旋转矩阵将原始位移 dx 和 dy 转换为旋转后的位移 rotatedDx 和 rotatedDy。
  9192. const rotatedDx = dx * Math.cos(angle) + dy * Math.sin(angle);
  9193. const rotatedDy = dy * Math.cos(angle) - dx * Math.sin(angle);
  9194. imgPosition.value = {
  9195. x: imgPosition.value.x + rotatedDx,
  9196. y: imgPosition.value.y + rotatedDy,
  9197. };
  9198. lastMousePosition.value = { x: event.clientX, y: event.clientY };
  9199. }
  9200. };
  9201. const onMouseUp = () => {
  9202. isDragging.value = false;
  9203. };
  9204. onMounted(() => {
  9205. nextTick(() => {
  9206. updateImgBoxDimensions();
  9207. window.addEventListener("resize", updateImgBoxDimensions);
  9208. window.addEventListener("mousemove", onMouseMove);
  9209. window.addEventListener("mouseup", onMouseUp);
  9210. });
  9211. });
  9212. return {
  9213. zoom,
  9214. rotation,
  9215. container,
  9216. imgStyle,
  9217. resetZoom,
  9218. handleRangeChange,
  9219. containerWidth,
  9220. containerHeight,
  9221. onMouseDown,
  9222. imgPosition,
  9223. };
  9224. },
  9225. render() {
  9226. const SsIcon = resolveComponent("ss-icon");
  9227. return h("div", { class: "ocr-img-box" }, [
  9228. h("div", { class: "img-bar" }, [
  9229. h("div", this.imageObj.name),
  9230. h("div", { class: "action-bar" }, [
  9231. h("div", { class: "ocr-img-range-box" }, [
  9232. h("input", {
  9233. type: "range",
  9234. min: 0,
  9235. max: 100,
  9236. value: this.zoom * 50, // 初始位置为50
  9237. onInput: this.handleRangeChange,
  9238. }),
  9239. h("span", { class: "line" }),
  9240. ]),
  9241. h(SsIcon, {
  9242. name: "reset",
  9243. size: "26px",
  9244. onClick: this.resetZoom,
  9245. }),
  9246. ]),
  9247. ]),
  9248. h("div", { class: "img-viewer", ref: "container" }, [
  9249. h(
  9250. "div",
  9251. {
  9252. class: "img-box",
  9253. style: {
  9254. width: `${this.containerWidth}px`,
  9255. height: `${this.containerHeight}px`,
  9256. overflow: "hidden",
  9257. position: "relative",
  9258. },
  9259. },
  9260. [
  9261. h("img", {
  9262. src: this.imageObj.thumb,
  9263. style: this.imgStyle,
  9264. class: "zoomable-img",
  9265. onMousedown: this.onMouseDown,
  9266. }),
  9267. ]
  9268. ),
  9269. ]),
  9270. ]);
  9271. },
  9272. };
  9273. // 搜索输入框组件
  9274. const SsSearchInput = {
  9275. name: "SsSearchInput",
  9276. props: {
  9277. name: String,
  9278. placeholder: String,
  9279. width: {
  9280. type: String,
  9281. default: "100px",
  9282. },
  9283. modelValue: String,
  9284. },
  9285. emits: ["update:modelValue", "search"],
  9286. setup(props, { emit }) {
  9287. const handleInput = (e) => {
  9288. emit("update:modelValue", e.target.value);
  9289. };
  9290. const handleKeyup = (e) => {
  9291. if (e.key === "Enter") {
  9292. emit("search");
  9293. }
  9294. };
  9295. return { handleInput, handleKeyup };
  9296. },
  9297. render() {
  9298. return h(
  9299. "div",
  9300. {
  9301. class: "input",
  9302. style: this.width ? { width: this.width } : undefined,
  9303. },
  9304. [
  9305. h("input", {
  9306. name: this.name,
  9307. placeholder: this.placeholder,
  9308. value: this.modelValue,
  9309. onInput: this.handleInput,
  9310. onKeyup: this.handleKeyup,
  9311. }),
  9312. ]
  9313. );
  9314. },
  9315. };
  9316. // ss-search-date-picker 日期时间选择器组件
  9317. const SsSearchDatePicker = {
  9318. name: "SsSearchDatePicker",
  9319. props: {
  9320. modelValue: {
  9321. type: [String, Number, Date],
  9322. default: "",
  9323. },
  9324. name: {
  9325. type: String,
  9326. required: true,
  9327. },
  9328. type: {
  9329. type: String,
  9330. default: "date",
  9331. validator: (value) => ["date", "datetime", "time"].includes(value),
  9332. },
  9333. fmt: {
  9334. type: String,
  9335. default: null,
  9336. },
  9337. placeholder: {
  9338. type: String,
  9339. default: "",
  9340. },
  9341. width: {
  9342. type: String,
  9343. default: "100%",
  9344. },
  9345. },
  9346. emits: ["update:modelValue"],
  9347. setup(props, { emit }) {
  9348. const errMsg = ref("");
  9349. const validate = () => {
  9350. if (window.ssVm) {
  9351. const result = window.ssVm.validateField(props.name);
  9352. console.log("validate", window.ssVm.validateField(props.name));
  9353. errMsg.value = result.valid ? "" : result.message;
  9354. }
  9355. };
  9356. // 根据type确定默认格式
  9357. const defaultFormat = computed(() => {
  9358. switch (props.type) {
  9359. case "datetime":
  9360. return "YYYY-MM-DD HH:mm:ss";
  9361. case "date":
  9362. return "YYYY-MM-DD";
  9363. case "time":
  9364. return "HH:mm:ss";
  9365. }
  9366. });
  9367. const convertJavaFormatToElement = (javaFormat) => {
  9368. if (!javaFormat) return null;
  9369. return javaFormat
  9370. .replace("yyyy", "YYYY")
  9371. .replace("MM", "MM")
  9372. .replace("dd", "DD")
  9373. .replace("HH", "HH")
  9374. .replace("mm", "mm")
  9375. .replace("ss", "ss");
  9376. };
  9377. const finalFormat = computed(() => {
  9378. if (props.fmt) {
  9379. return convertJavaFormatToElement(props.fmt);
  9380. }
  9381. return defaultFormat.value;
  9382. });
  9383. // 使用 resolveComponent 获取组件
  9384. const ElDatePicker = resolveComponent("ElDatePicker");
  9385. const ElTimePicker = resolveComponent("ElTimePicker");
  9386. const SsFormIcon = resolveComponent("SsFormIcon");
  9387. const ElIcon = resolveComponent("ElIcon");
  9388. let useTimePicker = true;
  9389. //"yyyy-MM-dd HH:mm:ss"; "日期字符串格式在java的写法",传到本组件fmt属性也是按这个格式
  9390. if (props.fmt) {
  9391. //有fmt属性,则以fmt属性优先判断类型
  9392. if (/[dMy]/.test(props.fmt)) {
  9393. //如果有传入日期格式,且含年月日
  9394. useTimePicker = false;
  9395. } else {
  9396. useTimePicker = true;
  9397. }
  9398. } else if (props.type !== "time") {
  9399. useTimePicker = false;
  9400. }
  9401. const dateType = computed(() => {
  9402. const fmt = props.fmt || "";
  9403. if (fmt.includes("HH:mm:ss")) {
  9404. return "datetime";
  9405. } else if (fmt.includes("HH:mm")) {
  9406. return "datetime";
  9407. } else if (fmt.includes("mm:ss")) {
  9408. return "time";
  9409. }
  9410. return "date";
  9411. });
  9412. const handleValueUpdate = (val) => {
  9413. emit("update:modelValue", val);
  9414. emit("change", val); // 同时触发 change 事件
  9415. setTimeout(() => {
  9416. validate();
  9417. }, 50);
  9418. };
  9419. return () =>
  9420. h(
  9421. "div",
  9422. { class: "ss-search-date-picker", style: { width: props.width } },
  9423. [
  9424. h("input", {
  9425. type: "hidden",
  9426. name: props.name,
  9427. value: props.modelValue,
  9428. }),
  9429. h(useTimePicker ? ElTimePicker : ElDatePicker, {
  9430. modelValue: props.modelValue,
  9431. "onUpdate:modelValue": handleValueUpdate,
  9432. type: dateType.value,
  9433. format: finalFormat.value,
  9434. "value-format": finalFormat.value,
  9435. clearable: true,
  9436. placeholder: props.placeholder,
  9437. class: "custom-date-picker", // 用于自定义样式
  9438. "time-arrow-control": props.type === "datetime", // 修改这里
  9439. size: "large", // 添加这一行,改为 large 尺寸
  9440. style: { width: "100%" },
  9441. "prefix-icon": h(SsFormIcon, { class: "form-icon-time" }),
  9442. }),
  9443. ]
  9444. );
  9445. },
  9446. };
  9447. // 搜索按钮组件(包含下拉按钮)
  9448. const SsSearchButton = {
  9449. name: "SsSearchButton",
  9450. props: {
  9451. text: {
  9452. type: String,
  9453. required: true,
  9454. },
  9455. iconClass: {
  9456. type: String,
  9457. required: false,
  9458. },
  9459. opt: {
  9460. type: Array,
  9461. default: () => [],
  9462. },
  9463. checkId: {
  9464. type: String,
  9465. default: "0",
  9466. },
  9467. width: {
  9468. //add by Ben(20251225)
  9469. type: String,
  9470. required: false,
  9471. },
  9472. id: {
  9473. //add by Ben(20251225)
  9474. type: String,
  9475. required: false,
  9476. },
  9477. },
  9478. emits: ["click"],
  9479. setup(props, { emit }) {
  9480. const currentId = ref(props.checkId || "0");
  9481. const showPopup = ref(false);
  9482. const handleMouseEnter = () => {
  9483. showPopup.value = true;
  9484. };
  9485. const handleMouseLeave = () => {
  9486. showPopup.value = false;
  9487. };
  9488. // 添加点击事件处理,阻止默认行为
  9489. const handleClick = (e) => {
  9490. e.preventDefault();
  9491. if (props.opt?.length > 0) {
  9492. const selectedOption =
  9493. currentId.value === "0"
  9494. ? props.opt[0]
  9495. : props.opt.find((opt) => opt.id === currentId.value);
  9496. if (selectedOption) {
  9497. selectedOption.callback?.();
  9498. }
  9499. } else {
  9500. emit("click", e);
  9501. }
  9502. };
  9503. // 获取显示文本
  9504. const getDisplayText = () => {
  9505. if (!props.opt?.length) return props.text;
  9506. const selectedOption =
  9507. currentId.value === "0"
  9508. ? props.opt[0]
  9509. : props.opt.find((opt) => opt.id === currentId.value);
  9510. return selectedOption ? selectedOption.desc : props.opt[0].desc;
  9511. };
  9512. return () =>
  9513. h(
  9514. "button",
  9515. {
  9516. class:
  9517. props.opt?.length > 0
  9518. ? "ss-drop-button ss-drop-button-more"
  9519. : "ss-drop-button",
  9520. type: "button", // 明确指定按钮类型为 button
  9521. onMouseenter: handleMouseEnter,
  9522. onMouseleave: handleMouseLeave,
  9523. onClick: handleClick, // 添加点击事件处理
  9524. style: { width: props.width }, //add by Ben(20251225)
  9525. id: props.id, //add by Ben(20251225)
  9526. },
  9527. [
  9528. props.iconClass
  9529. ? h("span", {
  9530. class: props.iconClass,
  9531. style: { fontFamily: "iconfont", marginRight: "5px" },
  9532. })
  9533. : null,
  9534. h("span", getDisplayText()),
  9535. props.opt.length > 0 &&
  9536. showPopup.value &&
  9537. h(
  9538. "div",
  9539. {
  9540. class: "popup",
  9541. },
  9542. props.opt.map((item) =>
  9543. h(
  9544. "div",
  9545. {
  9546. onClick: (e) => {
  9547. e.preventDefault(); // 选项点击也阻止默认行为
  9548. e.stopPropagation(); // 阻止事件冒泡
  9549. currentId.value = item.id; // 更新当前选中的ID
  9550. item.callback();
  9551. showPopup.value = false; // 选择后关闭弹窗
  9552. },
  9553. },
  9554. item.desc
  9555. )
  9556. )
  9557. ),
  9558. ]
  9559. );
  9560. },
  9561. };
  9562. // 下拉按钮组件
  9563. const SsDropButton = {
  9564. name: "SsDropButton",
  9565. props: {
  9566. text: {
  9567. type: String,
  9568. required: true,
  9569. },
  9570. iconClass: {
  9571. type: String,
  9572. required: true,
  9573. },
  9574. opt: {
  9575. type: Array,
  9576. default: () => [],
  9577. },
  9578. checkId: {
  9579. type: String,
  9580. default: "0",
  9581. },
  9582. onclick: {
  9583. type: Function,
  9584. default: null,
  9585. },
  9586. },
  9587. setup(props) {
  9588. const currentId = ref(props.checkId || "0");
  9589. const showPopup = ref(false);
  9590. const handleMouseEnter = () => {
  9591. showPopup.value = true;
  9592. };
  9593. const handleMouseLeave = () => {
  9594. showPopup.value = false;
  9595. };
  9596. // 添加点击事件处理,阻止默认行为
  9597. const handleClick = (e) => {
  9598. e.preventDefault();
  9599. if (props.opt?.length > 0) {
  9600. const selectedOption =
  9601. currentId.value === "0"
  9602. ? props.opt[0]
  9603. : props.opt.find((opt) => opt.id === currentId.value);
  9604. if (selectedOption) {
  9605. selectedOption.callback?.();
  9606. }
  9607. } else if (props.onclick) {
  9608. props.onclick();
  9609. }
  9610. };
  9611. // 获取显示文本
  9612. const getDisplayText = () => {
  9613. if (!props.opt?.length) return props.text;
  9614. const selectedOption =
  9615. currentId.value === "0"
  9616. ? props.opt[0]
  9617. : props.opt.find((opt) => opt.id === currentId.value);
  9618. return selectedOption ? selectedOption.desc : props.opt[0].desc;
  9619. };
  9620. return () =>
  9621. h(
  9622. "button",
  9623. {
  9624. class:
  9625. props.opt?.length > 0
  9626. ? "ss-drop-button ss-drop-button-more"
  9627. : "ss-drop-button",
  9628. type: "button", // 明确指定按钮类型为 button
  9629. onMouseenter: handleMouseEnter,
  9630. onMouseleave: handleMouseLeave,
  9631. onClick: handleClick, // 添加点击事件处理
  9632. },
  9633. [
  9634. h("span", {
  9635. class: props.iconClass,
  9636. style: { fontFamily: "iconfont" },
  9637. }),
  9638. h("span", getDisplayText()),
  9639. props.opt.length > 0 &&
  9640. showPopup.value &&
  9641. h(
  9642. "div",
  9643. {
  9644. class: "popup",
  9645. },
  9646. props.opt.map((item) =>
  9647. h(
  9648. "div",
  9649. {
  9650. onClick: (e) => {
  9651. e.preventDefault(); // 选项点击也阻止默认行为
  9652. e.stopPropagation(); // 阻止事件冒泡
  9653. currentId.value = item.id; // 更新当前选中的ID
  9654. item.callback();
  9655. showPopup.value = false; // 选择后关闭弹窗
  9656. },
  9657. },
  9658. item.desc
  9659. )
  9660. )
  9661. ),
  9662. ]
  9663. );
  9664. },
  9665. };
  9666. /**
  9667. * 二级页面标签组件
  9668. * @name ss-sub-tab
  9669. * @description 用于展示二级页面的布局组件,包含左侧垂直标签导航(支持分组)和右侧iframe内容区
  9670. * @property {String} headerImage - 左侧顶部图片地址
  9671. * @property {Array} menuList - 菜单配置列表
  9672. * @property {Object} [activeMenu] - 当前选中的菜单项,不传则自动选择第一个可选菜单
  9673. * @property {Array} footerButtons - 底部按钮配置列表
  9674. */
  9675. /**
  9676. * SsSubTab 左侧菜单+iframe内容组件
  9677. * v3.0 改造:去掉顶部图片,改为图标+悬浮模式,iframe懒加载 by xu 20251216
  9678. */
  9679. const SsSubTab = {
  9680. name: "SsSubTab",
  9681. props: {
  9682. menuList: {
  9683. type: Array,
  9684. required: true,
  9685. },
  9686. activeMenu: {
  9687. type: String,
  9688. default: "",
  9689. },
  9690. footerButtons: {
  9691. type: Array,
  9692. default: () => [],
  9693. },
  9694. leftDisplay: {
  9695. type: Boolean,
  9696. default: true,
  9697. },
  9698. // v3.0 新增:菜单模式 collapse(悬浮展开) / fixed(始终收起) by xu 20251216
  9699. initialMode: {
  9700. type: String,
  9701. default: "collapse",
  9702. },
  9703. },
  9704. emits: ["menu-change", "footer-click"],
  9705. setup(props, { emit }) {
  9706. // v3.0 新增:默认图标映射,使用icon-biz图标 by xu 20251216
  9707. const defaultIcons = [
  9708. "icon-obj-ry", // 人员
  9709. "icon-obj-dw", // 单位
  9710. "icon-obj-gw", // 岗位
  9711. "icon-biz-rc", // 人才
  9712. "icon-biz-xc", // 巡查
  9713. "icon-biz-cl", // 材料
  9714. "icon-biz-men", // 门
  9715. "icon-obj-xy", // 协议
  9716. ];
  9717. //功能: SsSubTab 支持后端下发 iconName + pobj/cobj 两级菜单 by xu 20251222
  9718. const isTrue = (v) => v === true || v === "true" || v === 1 || v === "1"; //功能 by xu 20251222
  9719. const resolveIconClass = (iconNameOrClass, fallbackIndex) => {
  9720. //功能 by xu 20251222
  9721. const fallback = `menu-icon ${
  9722. defaultIcons[fallbackIndex % defaultIcons.length]
  9723. }`;
  9724. if (!iconNameOrClass) {
  9725. return fallback;
  9726. }
  9727. // 已经是完整 class(可能包含 menu-icon / menu-base-icon / 多个 class)
  9728. if (
  9729. typeof iconNameOrClass === "string" &&
  9730. iconNameOrClass.indexOf(" ") > -1
  9731. ) {
  9732. return iconNameOrClass;
  9733. }
  9734. const iconName = iconNameOrClass;
  9735. if (iconName === "menu-icon" || iconName === "menu-base-icon") {
  9736. return fallback;
  9737. }
  9738. // 业务图标库:icon-biz / icon-obj -> menu-icon
  9739. if (
  9740. typeof iconName === "string" &&
  9741. (iconName.indexOf("icon-obj-") === 0 ||
  9742. iconName.indexOf("icon-biz-") === 0)
  9743. ) {
  9744. return `menu-icon ${iconName}`;
  9745. }
  9746. // 默认认为是 icon-base 图标 -> menu-base-icon
  9747. return `menu-base-icon ${iconName}`;
  9748. };
  9749. const getMenuIcon = (item, index) => {
  9750. //功能 by xu 20251222
  9751. if (!item) {
  9752. return resolveIconClass(null, index);
  9753. }
  9754. //功能: 变动图标后端暂不正确,前端先写死为 icon-chg by xu 20251223
  9755. if (item.title === "变动" || item.name === "sys_bd") {
  9756. return resolveIconClass("icon-chg", index);
  9757. }
  9758. // 兼容旧字段 icon(优先使用)
  9759. if (item.icon) return resolveIconClass(item.icon, index);
  9760. // v3.0 使用后端下发 iconName
  9761. if (item.iconName) return resolveIconClass(item.iconName, index);
  9762. return resolveIconClass(null, index);
  9763. };
  9764. //功能: SsSubTab 底部按钮支持 icon+文字(icon-base)by xu 20251224
  9765. const getFooterIcon = (button) => {
  9766. //功能 by xu 20251224
  9767. if (!button) return "menu-base-icon icon-subm";
  9768. const iconNameOrClass =
  9769. button.iconClass || button.iconName || button.icon;
  9770. if (!iconNameOrClass) return "menu-base-icon icon-subm";
  9771. if (
  9772. typeof iconNameOrClass === "string" &&
  9773. iconNameOrClass.indexOf(" ") > -1
  9774. ) {
  9775. return iconNameOrClass;
  9776. }
  9777. return `menu-base-icon ${iconNameOrClass}`;
  9778. };
  9779. //功能: pobj/cobj 扁平结构转换为 children 树结构,兼容原 children 结构 by xu 20251222
  9780. const normalizeMenuList = (rawList) => {
  9781. if (!Array.isArray(rawList) || rawList.length === 0) {
  9782. return [];
  9783. }
  9784. const hasTree = rawList.some(
  9785. (it) => Array.isArray(it?.children) && it.children.length > 0
  9786. );
  9787. if (hasTree) {
  9788. return rawList.map((it) => ({
  9789. ...it,
  9790. __level: 1,
  9791. children: Array.isArray(it.children)
  9792. ? it.children.map((c) => ({ ...c, __level: 2 }))
  9793. : it.children,
  9794. }));
  9795. }
  9796. const hasMarker = rawList.some(
  9797. (it) => it && ("pobj" in it || "cobj" in it)
  9798. );
  9799. if (!hasMarker) {
  9800. return rawList.map((it) => ({ ...it, __level: 1 }));
  9801. }
  9802. const result = [];
  9803. let currentGroup = null;
  9804. for (const item of rawList) {
  9805. //功能: “变动”始终按一级处理(即使后端误传 pobj/cobj)by xu 20251223
  9806. const isChgItem =
  9807. item && (item.title === "变动" || item.name === "sys_bd");
  9808. if (isChgItem) {
  9809. result.push({ ...item, __level: 1 });
  9810. continue;
  9811. }
  9812. const isParent = isTrue(item?.pobj);
  9813. const isChild = isTrue(item?.cobj);
  9814. if (isParent) {
  9815. currentGroup = {
  9816. ...item,
  9817. __level: 1,
  9818. children: [],
  9819. };
  9820. result.push(currentGroup);
  9821. continue;
  9822. }
  9823. if (isChild && currentGroup) {
  9824. currentGroup.children.push({ ...item, __level: 2 });
  9825. continue;
  9826. }
  9827. //功能: 变动等无 pobj/cobj 的选项按一级展示(不挂到 children,也不打断当前分组)by xu 20251223
  9828. result.push({ ...item, __level: 1 });
  9829. }
  9830. return result;
  9831. };
  9832. const menuListComputed = computed(() =>
  9833. normalizeMenuList(props.menuList)
  9834. ); //功能 by xu 20251222
  9835. //功能: 分组展开状态(默认展开),避免 computed 生成对象导致 open 状态丢失 by xu 20251222
  9836. const groupOpenState = reactive({}); // { [key]: boolean }
  9837. const getGroupKey = (item) => item?.name || item?.title || ""; //功能 by xu 20251222
  9838. const isGroupOpen = (item) => {
  9839. //功能 by xu 20251222
  9840. const key = getGroupKey(item);
  9841. if (!key) return true;
  9842. return groupOpenState[key] !== false;
  9843. };
  9844. const toggleGroupOpen = (item) => {
  9845. //功能 by xu 20251222
  9846. const key = getGroupKey(item);
  9847. if (!key) return;
  9848. groupOpenState[key] = !isGroupOpen(item);
  9849. };
  9850. const getLevelClass = (item, fallbackLevel) => {
  9851. //功能 by xu 20251222
  9852. //功能: “变动”始终按一级样式处理 by xu 20251223
  9853. if (item && (item.title === "变动" || item.name === "sys_bd")) {
  9854. return "level-1";
  9855. }
  9856. const level = item?.__level || fallbackLevel || 1;
  9857. return level === 2 ? "level-2" : "level-1";
  9858. };
  9859. // v3.0 新增:菜单模式管理 by xu 20251216
  9860. const menuMode = ref(props.initialMode);
  9861. const isHovering = ref(false);
  9862. const toggleMenuMode = () => {
  9863. menuMode.value = menuMode.value === "collapse" ? "fixed" : "collapse";
  9864. };
  9865. //功能: 提供给旧UI弹窗顶部按钮调用的 API(替代点击 .menu-mode-toggle DOM)by xu 20251224
  9866. const registerSsSubTabApi = () => {
  9867. //功能 by xu 20251224
  9868. try {
  9869. window.SS = window.SS || {};
  9870. window.SS.dom = window.SS.dom || {};
  9871. //功能: 兼容小写 ss 命名空间(部分页面只引用 window.ss)by xu 20251224
  9872. window.ss = window.ss || window.SS;
  9873. window.ss.dom = window.ss.dom || window.SS.dom;
  9874. const api = {
  9875. toggleMenuMode,
  9876. getMenuMode: () => menuMode.value,
  9877. };
  9878. window.SS.dom.ssSubTabApi = api;
  9879. window.ss.dom.ssSubTabApi = api;
  9880. //功能: 多层弹窗(如 objPlay -> objInfo) 场景,将 API 注册到 topWindow 供按钮跨层调用 by xu 20251224
  9881. try {
  9882. const wdDialogId =
  9883. window.wd &&
  9884. wd.display &&
  9885. wd.display.getwdDialogId &&
  9886. wd.display.getwdDialogId();
  9887. if (wdDialogId && window.top) {
  9888. window.top.__ssSubTabApiMap = window.top.__ssSubTabApiMap || {};
  9889. window.top.__ssSubTabApiMap[wdDialogId] = api;
  9890. }
  9891. } catch (e) {}
  9892. try {
  9893. console.log(
  9894. "[SsSubTabApi] registered",
  9895. window.location && window.location.pathname
  9896. );
  9897. } catch (e) {}
  9898. } catch (e) {}
  9899. };
  9900. const unregisterSsSubTabApi = () => {
  9901. //功能 by xu 20251224
  9902. try {
  9903. //功能: 从 topWindow 解绑(避免弹窗关闭后残留)by xu 20251224
  9904. try {
  9905. const wdDialogId =
  9906. window.wd &&
  9907. wd.display &&
  9908. wd.display.getwdDialogId &&
  9909. wd.display.getwdDialogId();
  9910. if (
  9911. wdDialogId &&
  9912. window.top &&
  9913. window.top.__ssSubTabApiMap &&
  9914. window.top.__ssSubTabApiMap[wdDialogId]
  9915. ) {
  9916. delete window.top.__ssSubTabApiMap[wdDialogId];
  9917. }
  9918. } catch (e) {}
  9919. if (window.SS?.dom?.ssSubTabApi?.toggleMenuMode === toggleMenuMode) {
  9920. delete window.SS.dom.ssSubTabApi;
  9921. }
  9922. if (window.ss?.dom?.ssSubTabApi?.toggleMenuMode === toggleMenuMode) {
  9923. delete window.ss.dom.ssSubTabApi;
  9924. }
  9925. } catch (e) {}
  9926. };
  9927. //功能: 立即注册,避免 enable 早于 onMounted 导致“api not ready”by xu 20251224
  9928. registerSsSubTabApi(); //功能 by xu 20251224
  9929. onBeforeUnmount(unregisterSsSubTabApi); //功能 by xu 20251224
  9930. const onMouseEnter = () => {
  9931. if (menuMode.value === "collapse") {
  9932. isHovering.value = true;
  9933. }
  9934. };
  9935. const onMouseLeave = () => {
  9936. isHovering.value = false;
  9937. };
  9938. const isExpanded = computed(() => {
  9939. return menuMode.value === "collapse" && isHovering.value;
  9940. });
  9941. // v3.0 新增:iframe 懒加载,点击才加载 by xu 20251216
  9942. const loadedMenus = ref(new Set());
  9943. const isMenuLoaded = (menuName) => {
  9944. return loadedMenus.value.has(menuName);
  9945. };
  9946. // 根据标题找到对应的菜单项
  9947. const findMenuByTitle = (title) => {
  9948. for (const item of menuListComputed.value) {
  9949. //功能 by xu 20251222
  9950. if (item.children?.length > 0) {
  9951. const child = item.children.find((c) => c.title === title);
  9952. if (child) return child;
  9953. } else if (item.title === title) {
  9954. return item;
  9955. }
  9956. }
  9957. return null;
  9958. };
  9959. // 计算默认选中的菜单项
  9960. const defaultActiveMenu = computed(() => {
  9961. if (props.activeMenu) {
  9962. const menu = findMenuByTitle(props.activeMenu);
  9963. if (menu) return menu;
  9964. }
  9965. const firstItem = menuListComputed.value[0]; //功能 by xu 20251222
  9966. if (!firstItem) return null;
  9967. //功能: 默认选中第一个一级菜单(不默认跳到第一个二级)by xu 20251224
  9968. return firstItem;
  9969. });
  9970. const currentMenu = ref(defaultActiveMenu.value);
  9971. // 监听外部activeMenu变化
  9972. watch(
  9973. () => props.activeMenu,
  9974. (newTitle) => {
  9975. if (newTitle) {
  9976. const menu = findMenuByTitle(newTitle);
  9977. if (menu) {
  9978. currentMenu.value = menu;
  9979. }
  9980. }
  9981. }
  9982. );
  9983. // 初始化:默认选中项加入已加载集合
  9984. watch(
  9985. currentMenu,
  9986. (menu) => {
  9987. if (menu?.name) {
  9988. loadedMenus.value.add(menu.name);
  9989. }
  9990. },
  9991. { immediate: true }
  9992. );
  9993. // 选择菜单项时触发 menu-change 钩子
  9994. const selectItem = (item) => {
  9995. currentMenu.value = item;
  9996. // 标记为已加载
  9997. if (item.name) {
  9998. loadedMenus.value.add(item.name);
  9999. }
  10000. emit("menu-change", item);
  10001. };
  10002. // 处理底部按钮点击
  10003. const handleFooterClick = (button, index) => {
  10004. emit("footer-click", { button, index });
  10005. };
  10006. return {
  10007. menuListComputed, //功能 by xu 20251222
  10008. currentMenu,
  10009. selectItem,
  10010. handleFooterClick,
  10011. getFooterIcon, //功能: SsSubTab 底部按钮支持 icon+文字(icon-base)by xu 20251224
  10012. menuMode,
  10013. isHovering,
  10014. isExpanded,
  10015. toggleMenuMode,
  10016. onMouseEnter,
  10017. onMouseLeave,
  10018. isMenuLoaded,
  10019. getMenuIcon,
  10020. isGroupOpen, //功能 by xu 20251222
  10021. toggleGroupOpen, //功能 by xu 20251222
  10022. getLevelClass, //功能 by xu 20251222
  10023. };
  10024. },
  10025. template: `
  10026. <div class="project-edit-container">
  10027. <div class="left-side"
  10028. v-if="leftDisplay"
  10029. :data-mode="menuMode"
  10030. :class="{ 'is-expanded': isExpanded }"
  10031. @mouseenter="onMouseEnter"
  10032. @mouseleave="onMouseLeave">
  10033. <!-- 菜单内容 -->
  10034. <div class="menu-content">
  10035. <div class="scroll-view">
  10036. <template v-for="(menuItem, i) in menuListComputed" :key="i">
  10037. <!-- 分组菜单 -->
  10038. <div v-if="menuItem.children?.length > 0" class="group">
  10039. <!-- 功能: 一级(pobj)可点击进入,箭头仅控制展开/收起;二级点击不影响一级选中状态 by xu 20251223 -->
  10040. <div class="menu-item"
  10041. :class="[getLevelClass(menuItem, 1), { active: menuItem.name === currentMenu?.name }]"
  10042. @click="selectItem(menuItem)">
  10043. <ss-icon :class="getMenuIcon(menuItem, i)" />
  10044. <span class="menu-label">{{ menuItem.title }}</span>
  10045. <!-- 功能: 一级菜单有子项时显示 dot(参考全局左侧菜单)by xu 20251224 -->
  10046. <div class="has-children-dot"></div>
  10047. <div class="menu-tooltip">{{ menuItem.title }}</div>
  10048. </div>
  10049. <!-- 功能: 二级菜单始终展示,不做收缩展开 by xu 20251223 -->
  10050. <div class="group-detail">
  10051. <div v-for="(item, j) in menuItem.children"
  10052. :key="j"
  10053. class="menu-item"
  10054. :class="[getLevelClass(item, 2), { active: item.name === currentMenu?.name }]"
  10055. @click.stop="selectItem(item)">
  10056. <ss-icon :class="getMenuIcon(item, j)" />
  10057. <span class="menu-label">{{ item.title }}</span>
  10058. </div>
  10059. </div>
  10060. </div>
  10061. <!-- 普通菜单项 -->
  10062. <div v-else
  10063. class="menu-item"
  10064. :class="[getLevelClass(menuItem, 1), { active: menuItem.name === currentMenu?.name }]"
  10065. @click="selectItem(menuItem)">
  10066. <ss-icon :class="getMenuIcon(menuItem, i)" />
  10067. <span class="menu-label">{{ menuItem.title }}</span>
  10068. <div class="menu-tooltip">{{ menuItem.title }}</div>
  10069. </div>
  10070. </template>
  10071. </div>
  10072. </div>
  10073. <!-- 底部按钮 -->
  10074. <div v-if="footerButtons.length > 0"
  10075. class="sub-tab-menu-footer"
  10076. :class="{ 'has-text': !!footerButtons[0].text }"
  10077. @click="footerButtons[0].onclick">
  10078. <ss-icon :class="getFooterIcon(footerButtons[0])" />
  10079. <div class="footer-label" v-if="footerButtons[0].text">{{ footerButtons[0].text }}</div>
  10080. <ss-icon v-if="footerButtons.length > 1" class="footer-arrow" name="arrow-up" size="24px" />
  10081. <div v-if="footerButtons.length > 1" class="sub-tab-menu-popup">
  10082. <div v-for="(button, index) in footerButtons.slice(1)"
  10083. :key="index"
  10084. @click.stop="button.onclick">
  10085. {{ button.text }}
  10086. </div>
  10087. </div>
  10088. </div>
  10089. </div>
  10090. <!-- 右侧内容区域 - 懒加载 iframe -->
  10091. <div class="content-area fit-height-content" style="overflow: hidden;" :style="!leftDisplay ? { width: '100%' } : {}">
  10092. <template v-for="(menuItem, i) in menuList" :key="i">
  10093. <iframe
  10094. v-if="isMenuLoaded(menuItem.name)"
  10095. :src="menuItem.url"
  10096. style="height: 100%;width: 100%;"
  10097. frameborder="0"
  10098. class="sub-tab-iframe"
  10099. :id="i === 0 ? 'sub-tab-iframe' : ''"
  10100. v-show="currentMenu?.name === menuItem.name"
  10101. />
  10102. </template>
  10103. </div>
  10104. </div>
  10105. `,
  10106. };
  10107. // <iframe
  10108. // v-if="currentMenu?.url"
  10109. // :src="currentMenu.url"
  10110. // style="height: 100%;width: 100%;"
  10111. // frameborder="0"
  10112. // id="sub-tab-iframe"
  10113. // />
  10114. // ss-photo-upload 通用图片上传组件
  10115. const SsImgUpload = {
  10116. name: "SsImgUpload",
  10117. props: {
  10118. name: {
  10119. type: String,
  10120. required: true,
  10121. },
  10122. // 图片URL,用于回显
  10123. // url: {
  10124. // type: String,
  10125. // default: "",
  10126. // },
  10127. // 样式类名
  10128. class: {
  10129. type: String,
  10130. required: true,
  10131. },
  10132. // 裁剪配置
  10133. cropperOpt: {
  10134. type: Object,
  10135. default: () => ({
  10136. width: 360,
  10137. height: 360,
  10138. aspectRatio: 1,
  10139. }),
  10140. },
  10141. //上传图片url(未加图片名参数之前的部分)
  10142. ulUrl: {
  10143. type: String,
  10144. required: true,
  10145. },
  10146. //下载图片url(未加图片名参数之前的部分)
  10147. dlUrl: {
  10148. type: String,
  10149. required: true,
  10150. },
  10151. modelValue: [String, Number],
  10152. },
  10153. emits: ["update:modelValue"],
  10154. setup(props, { emit }) {
  10155. const inputId = Vue.computed(
  10156. () => `file_${Vue.getCurrentInstance().uid}`
  10157. );
  10158. //修改图片初始显示路径
  10159. let pathVal = ref(props.modelValue);
  10160. let picUrl = ref("");
  10161. if (props.modelValue) {
  10162. picUrl.value = props.dlUrl + "&path=" + props.modelValue;
  10163. }
  10164. Vue.onMounted(() => {
  10165. window.SS.cropper.init({
  10166. el: $(`#${inputId.value}`),
  10167. photoSize: {
  10168. width: props.cropperOpt.width,
  10169. height: props.cropperOpt.height,
  10170. },
  10171. aspectRatio: props.cropperOpt.aspectRatio,
  10172. uploadUrl: props.ulUrl,
  10173. success: (path) => {
  10174. pathVal.value = path;
  10175. picUrl.value = props.dlUrl + "&path=" + path;
  10176. emit("update:modelValue", path);
  10177. },
  10178. });
  10179. });
  10180. return () =>
  10181. h("div", { class: [props.class] }, [
  10182. h("input", {
  10183. type: "file",
  10184. accept: "image/*",
  10185. id: inputId.value,
  10186. style: { display: "none" },
  10187. }),
  10188. h("input", {
  10189. type: "hidden",
  10190. name: props.name,
  10191. value: pathVal.value,
  10192. }),
  10193. h(
  10194. "div",
  10195. {
  10196. style: {
  10197. width: "100%",
  10198. height: "100%",
  10199. },
  10200. onClick: () => $(`#${inputId.value}`).click(),
  10201. },
  10202. [
  10203. picUrl.value &&
  10204. h("img", {
  10205. src: picUrl.value,
  10206. style:
  10207. "width: 100%; height: 100%;object-fit: inherit;position: relative;z-index: 11;",
  10208. }),
  10209. ]
  10210. ),
  10211. ]);
  10212. },
  10213. };
  10214. // 初始化函数,负责创建和挂载 Vue 应用
  10215. // window.SS = { dom: {} };
  10216. /**
  10217. * 获取当前窗口的父窗口
  10218. * @returns {Window} 父窗口对象
  10219. */
  10220. window.SS.topWin = (function (p, c) {
  10221. while (p != c) {
  10222. c = p;
  10223. p = p.parent;
  10224. }
  10225. return c;
  10226. })(window.parent, window);
  10227. window.SS.createSsDialogInstance = createSsDialogInstance;
  10228. /**
  10229. * 创建弹窗
  10230. * @param {Object} setting
  10231. * @param {Function} callbackEvent
  10232. */
  10233. window.SS.openDialog = function (setting, callbackEvent) {
  10234. if (setting.params) {
  10235. const encodedParams = encodeURIComponent(JSON.stringify(setting.params));
  10236. setting.src +=
  10237. (setting.src.includes("?") ? "&" : "?") + "params=" + encodedParams;
  10238. }
  10239. if (window.parent && window.parent !== window) {
  10240. window.parent.SS.createSsDialogInstance(setting, callbackEvent);
  10241. } else {
  10242. createSsDialogInstance(setting, callbackEvent);
  10243. }
  10244. };
  10245. //关闭弹窗
  10246. window.SS.closeDialog = function () {
  10247. console.log("关闭弹窗");
  10248. if (topWindow.dialogInstances.length > 0) {
  10249. const instance = topWindow.dialogInstances.pop();
  10250. console.log("instance", instance);
  10251. console.log("instance.callbackEvent", instance.callbackEvent);
  10252. console.log(
  10253. "instance.callbackEvent.end",
  10254. typeof instance.callbackEvent === "function"
  10255. );
  10256. if (instance.callbackEvent) {
  10257. // 判断是否有end回调并执行
  10258. if (typeof instance.callbackEvent === "function") {
  10259. instance.callbackEvent();
  10260. }
  10261. if (typeof instance.callbackEvent.end === "function") {
  10262. instance.callbackEvent.end();
  10263. }
  10264. }
  10265. instance.app.unmount(); // 卸载最后一个实例
  10266. if (instance.container && instance.container.parentNode) {
  10267. instance.container.parentNode.removeChild(instance.container); // 移除容器
  10268. }
  10269. }
  10270. };
  10271. /**
  10272. * 裁剪插件
  10273. */
  10274. window.SS.cropper = {
  10275. init: function (setting) {
  10276. if (!window.top.SS) window.top.SS = {};
  10277. // 重要:确保 cropper 对象的完整初始化
  10278. if (!window.top.SS.cropper) {
  10279. window.top.SS.cropper = {
  10280. settings: new Map(),
  10281. _backupSettings: {},
  10282. getSetting: this.getSetting,
  10283. clearSetting: this.clearSetting,
  10284. debug: this.debug,
  10285. };
  10286. } else if (!window.top.SS.cropper.settings) {
  10287. // 如果 cropper 存在但 settings 不存在,重新初始化 settings
  10288. window.top.SS.cropper.settings = new Map();
  10289. window.top.SS.cropper._backupSettings = {};
  10290. }
  10291. const uploaderId = `uploader_${Date.now()}_${Math.random()
  10292. .toString(36)
  10293. .substr(2, 9)}`;
  10294. window.top.SS.cropper.settings.set(uploaderId, setting);
  10295. window.top.SS.cropper._backupSettings[uploaderId] = setting;
  10296. setting.box = setting.box || "1";
  10297. var winSetting = {
  10298. headerTitle: "图片裁剪",
  10299. src: "/js/cropper/cropper.jsp", //原来在"/newUI/page/cropper.jsp" Ben(20251205)
  10300. width: "900",
  10301. height: "500",
  10302. };
  10303. $(setting.el).change(function () {
  10304. if (!window.SS.cropper.verify(setting)) {
  10305. $(setting.el).val(""); // 清空文件选择
  10306. return false;
  10307. }
  10308. var files = this.files;
  10309. if (files && files.length) {
  10310. if (!window.SS.cropper.verifySize($(setting.el)[0], 5)) {
  10311. $(setting.el).val(""); // 清空文件选择
  10312. alert("文件大小不能超过5M,请重新选择");
  10313. return false;
  10314. }
  10315. var URL = window.URL || window.webkitURL;
  10316. var file = files[0];
  10317. setting.file = file;
  10318. if (
  10319. /^image\/\w+$/.test(file.type) &&
  10320. /\.(jpg|jpeg|png|)$/i.test(file.name)
  10321. ) {
  10322. var uploadedImageURL = URL.createObjectURL(file);
  10323. setting.data = uploadedImageURL;
  10324. setting.fileName = file.name;
  10325. // console.log()
  10326. winSetting.params = {
  10327. ...setting,
  10328. uploaderId,
  10329. };
  10330. console.log("ss-componets中change之后的winSetting", winSetting);
  10331. SS.openDialog(winSetting, {
  10332. success: function (win) {
  10333. console.log("裁剪插件成功");
  10334. // win.cropperSetting = setting;
  10335. },
  10336. end: function () {
  10337. console.log("裁剪插件结束");
  10338. $(setting.el).val(""); // 清空文件选择
  10339. },
  10340. });
  10341. } else {
  10342. alert("请选择图片文件,支持jpg、jpeg、png格式");
  10343. }
  10344. }
  10345. });
  10346. return uploaderId;
  10347. },
  10348. verify: function (setting) {
  10349. if (!setting) {
  10350. console.error(" cropper setting is not undefined! ");
  10351. return false;
  10352. }
  10353. if (!setting.el) {
  10354. console.error(" cropper setting.el is not undefined! ");
  10355. return false;
  10356. }
  10357. if (setting.photoSize) {
  10358. if (
  10359. (!setting.photoSize.width && setting.photoSize.height) ||
  10360. (!setting.photoSize.height && setting.photoSize.width)
  10361. ) {
  10362. console.error(
  10363. " cropper setting.photoSize { width, height } is not undefined! "
  10364. );
  10365. return false;
  10366. }
  10367. }
  10368. if (!setting.box) {
  10369. setting.box = "1";
  10370. }
  10371. if (!setting.aspectRatio) {
  10372. setting.aspectRatio = 1 / 1;
  10373. }
  10374. return true;
  10375. },
  10376. verifySize: function (fileEl, maxSize) {
  10377. // 判断是否为IE浏览器: /msie/i.test(navigator.userAgent) 为一个简单正则
  10378. var isIE = /msie/i.test(navigator.userAgent) && !window.opera;
  10379. var fileSize = 0;
  10380. if (isIE && !fileEl.files) {
  10381. // IE浏览器
  10382. var filePath = fileEl.value; // 获得上传文件的绝对路径
  10383. var fileSystem = new ActiveXObject("Scripting.FileSystemObject");
  10384. var file = fileSystem.GetFile(filePath);
  10385. fileSize = file.Size; // 文件大小,单位:b
  10386. } else {
  10387. // 非IE浏览器
  10388. fileSize = fileEl.files[0].size;
  10389. }
  10390. var size = fileSize / 1024 / 1024;
  10391. return !(size > maxSize);
  10392. },
  10393. // 获取特定上传组件的setting
  10394. getSetting: function (uploaderId) {
  10395. if (!window.top.SS?.cropper) {
  10396. console.warn("顶层窗口中未找到 SS.cropper");
  10397. return null;
  10398. }
  10399. // 优先从 Map 中获取
  10400. let setting = window.top.SS.cropper.settings.get(uploaderId);
  10401. // 如果 Map 中没有,尝试从备份中获取
  10402. if (!setting && window.top.SS.cropper._backupSettings[uploaderId]) {
  10403. console.log("从备份中恢复 setting");
  10404. setting = window.top.SS.cropper._backupSettings[uploaderId];
  10405. // 恢复到 Map 中
  10406. window.top.SS.cropper.settings.set(uploaderId, setting);
  10407. }
  10408. return setting;
  10409. },
  10410. // 清理特定上传组件的setting
  10411. clearSetting: function (uploaderId) {
  10412. if (!window.top.SS?.cropper) return;
  10413. window.top.SS.cropper.settings.delete(uploaderId);
  10414. delete window.top.SS.cropper._backupSettings[uploaderId];
  10415. console.log(
  10416. "清理设置后的 Map size:",
  10417. window.top.SS.cropper.settings.size
  10418. );
  10419. },
  10420. };
  10421. /**
  10422. * 获取url中的参数
  10423. * @returns {Object}
  10424. */
  10425. window.SS.getQueryParams = function () {
  10426. const params = {};
  10427. const queryString = window.location.search.substring(1);
  10428. const pairs = queryString.split("&");
  10429. for (let i = 0; i < pairs.length; i++) {
  10430. const pair = pairs[i].split("=");
  10431. params[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1]);
  10432. }
  10433. if (params.params) {
  10434. try {
  10435. params.params = JSON.parse(params.params);
  10436. } catch (e) {
  10437. console.error("Failed to parse params:", e);
  10438. }
  10439. }
  10440. return params;
  10441. };
  10442. /**
  10443. * 创建vue应用
  10444. * @param {Object} config 配置项
  10445. * @values {String} config.el 挂载的元素
  10446. * @values {Boolean} config.isDialogPage 是否是弹窗页面 决定了是否可以使用顶天立地
  10447. * @values {Object} config.vueOptions vue配置项
  10448. * @returns {Object} vue实例
  10449. */
  10450. window.ss = window.ss || window.SS;
  10451. window.ss.dom = window.ss.dom || window.SS.dom;
  10452. window.SS.dom._vueAppSeq =
  10453. window.SS.dom._vueAppSeq || window.ss.dom._vueAppSeq || 0;
  10454. window.SS.dom.vueApps = window.SS.dom.vueApps || window.ss.dom.vueApps || [];
  10455. window.ss.dom._vueAppSeq = window.SS.dom._vueAppSeq;
  10456. window.ss.dom.vueApps = window.SS.dom.vueApps;
  10457. window.SS.dom._registerVueApp = function ({ vm, el, appKey, scope, href }) {
  10458. if (!vm) return null;
  10459. const registry = window.SS.dom.vueApps || (window.SS.dom.vueApps = []);
  10460. const id = `vue-app-${++window.SS.dom._vueAppSeq}`;
  10461. const record = {
  10462. id,
  10463. el: el || "",
  10464. appKey: appKey || "",
  10465. scope: scope || "current",
  10466. href: href || window.location.href,
  10467. createdAt: Date.now(),
  10468. vm,
  10469. win: window,
  10470. };
  10471. registry.push(record);
  10472. window.SS.dom.currentApp = vm;
  10473. window.SS.dom.currentAppRecord = record;
  10474. if (window.ss && window.ss.dom) {
  10475. window.ss.dom.vueApps = registry;
  10476. window.ss.dom._vueAppSeq = window.SS.dom._vueAppSeq;
  10477. window.ss.dom.currentApp = vm;
  10478. window.ss.dom.currentAppRecord = record;
  10479. }
  10480. return record;
  10481. };
  10482. window.SS.dom._getVmData = function (vm) {
  10483. if (!vm) return null;
  10484. return vm.$data || vm;
  10485. };
  10486. window.SS.dom._hasVmKey = function (vm, key) {
  10487. if (!vm || !key) return false;
  10488. const data = window.SS.dom._getVmData(vm);
  10489. return key in vm || (!!data && key in data);
  10490. };
  10491. window.SS.dom._hasVmMethod = function (vm, methodName) {
  10492. return !!(vm && methodName && typeof vm[methodName] === "function");
  10493. };
  10494. window.SS.dom._normalizeBridgeOptions = function (
  10495. options = {},
  10496. defaults = {}
  10497. ) {
  10498. return {
  10499. scope: "chain",
  10500. ...defaults,
  10501. ...options,
  10502. };
  10503. };
  10504. window.SS.dom._matchVueRecord = function (record, options = {}) {
  10505. if (!record || !record.vm) return false;
  10506. if (options.appKey && record.appKey !== options.appKey) return false;
  10507. if (options.el && record.el !== options.el) return false;
  10508. if (options.id && record.id !== options.id) return false;
  10509. if (
  10510. options.dataKey &&
  10511. !window.SS.dom._hasVmKey(record.vm, options.dataKey)
  10512. ) {
  10513. return false;
  10514. }
  10515. if (
  10516. options.methodName &&
  10517. !window.SS.dom._hasVmMethod(record.vm, options.methodName)
  10518. ) {
  10519. return false;
  10520. }
  10521. if (typeof options.predicate === "function") {
  10522. try {
  10523. if (!options.predicate(record.vm, record)) {
  10524. return false;
  10525. }
  10526. } catch (e) {
  10527. return false;
  10528. }
  10529. }
  10530. return true;
  10531. };
  10532. window.SS.dom._getWindowVueRecord = function (targetWindow, options = {}) {
  10533. if (!targetWindow || !targetWindow.SS || !targetWindow.SS.dom) return null;
  10534. const registry = targetWindow.SS.dom.vueApps || [];
  10535. for (let i = registry.length - 1; i >= 0; i--) {
  10536. if (targetWindow.SS.dom._matchVueRecord(registry[i], options)) {
  10537. return registry[i];
  10538. }
  10539. }
  10540. const currentRecord = targetWindow.SS.dom.currentAppRecord;
  10541. if (targetWindow.SS.dom._matchVueRecord(currentRecord, options)) {
  10542. return currentRecord;
  10543. }
  10544. const currentVm = targetWindow.SS.dom.currentApp;
  10545. const fallbackRecord = currentVm
  10546. ? {
  10547. vm: currentVm,
  10548. win: targetWindow,
  10549. el: "",
  10550. appKey: "",
  10551. id: "",
  10552. }
  10553. : null;
  10554. if (targetWindow.SS.dom._matchVueRecord(fallbackRecord, options)) {
  10555. return fallbackRecord;
  10556. }
  10557. return null;
  10558. };
  10559. window.SS.dom.getVueAppRecord = function (options = {}) {
  10560. const scope = options.scope || "current";
  10561. if (scope === "current") {
  10562. return window.SS.dom._getWindowVueRecord(window, options);
  10563. }
  10564. if (scope === "top") {
  10565. try {
  10566. return window.SS.dom._getWindowVueRecord(window.top, options);
  10567. } catch (e) {
  10568. return null;
  10569. }
  10570. }
  10571. if (scope === "parent") {
  10572. try {
  10573. if (window.parent && window.parent !== window) {
  10574. return window.SS.dom._getWindowVueRecord(window.parent, options);
  10575. }
  10576. } catch (e) {
  10577. return null;
  10578. }
  10579. return null;
  10580. }
  10581. if (scope === "chain") {
  10582. let currentWindow = window;
  10583. while (currentWindow) {
  10584. try {
  10585. const record = window.SS.dom._getWindowVueRecord(
  10586. currentWindow,
  10587. options
  10588. );
  10589. if (record) {
  10590. return record;
  10591. }
  10592. } catch (e) {
  10593. return null;
  10594. }
  10595. if (currentWindow === currentWindow.parent) {
  10596. break;
  10597. }
  10598. currentWindow = currentWindow.parent;
  10599. }
  10600. return null;
  10601. }
  10602. return window.SS.dom._getWindowVueRecord(window, options);
  10603. };
  10604. window.SS.dom.getVueApp = function (options = {}) {
  10605. const record = window.SS.dom.getVueAppRecord(options);
  10606. return record ? record.vm : null;
  10607. };
  10608. window.SS.dom.getVmValue = function (key, options = {}) {
  10609. const vm = window.SS.dom.getVueApp(
  10610. window.SS.dom._normalizeBridgeOptions(options, { dataKey: key })
  10611. );
  10612. if (!vm) return undefined;
  10613. return vm[key];
  10614. };
  10615. window.SS.dom.setVmValue = function (key, value, options = {}) {
  10616. const vm = window.SS.dom.getVueApp(
  10617. window.SS.dom._normalizeBridgeOptions(options, { dataKey: key })
  10618. );
  10619. if (!vm) return false;
  10620. vm[key] = value;
  10621. return true;
  10622. };
  10623. window.SS.dom.callVmMethod = function (methodName, args = [], options = {}) {
  10624. const vm = window.SS.dom.getVueApp(
  10625. window.SS.dom._normalizeBridgeOptions(options, { methodName })
  10626. );
  10627. if (!vm || typeof vm[methodName] !== "function") {
  10628. return undefined;
  10629. }
  10630. return vm[methodName].apply(vm, args);
  10631. };
  10632. window.SS.dom.get = function (key, options = {}) {
  10633. return window.SS.dom.getVmValue(key, options);
  10634. };
  10635. window.SS.dom.set = function (key, value, options = {}) {
  10636. return window.SS.dom.setVmValue(key, value, options);
  10637. };
  10638. window.SS.dom.call = function (methodName, args = [], options = {}) {
  10639. return window.SS.dom.callVmMethod(methodName, args, options);
  10640. };
  10641. [
  10642. "_registerVueApp",
  10643. "_getVmData",
  10644. "_hasVmKey",
  10645. "_hasVmMethod",
  10646. "_normalizeBridgeOptions",
  10647. "_matchVueRecord",
  10648. "_getWindowVueRecord",
  10649. "getVueAppRecord",
  10650. "getVueApp",
  10651. "getVmValue",
  10652. "setVmValue",
  10653. "callVmMethod",
  10654. "get",
  10655. "set",
  10656. "call",
  10657. ].forEach((name) => {
  10658. window.ss.dom[name] = window.SS.dom[name];
  10659. });
  10660. window.SS.dom.initializeFormApp = function (config) {
  10661. const {
  10662. el,
  10663. isDialogPage = false,
  10664. appKey = "",
  10665. scope = "current",
  10666. ...vueOptions
  10667. } = config;
  10668. const app = createApp({
  10669. ...vueOptions,
  10670. });
  10671. if (isDialogPage) {
  10672. function checkScroll() {
  10673. const elements = document.querySelectorAll(".fit-height-content");
  10674. let hasScrollBar = false;
  10675. elements.forEach((el) => {
  10676. if (el.scrollHeight > el.clientHeight) {
  10677. hasScrollBar = true;
  10678. }
  10679. });
  10680. window.parent.postMessage({ hasScrollBar }, "*");
  10681. }
  10682. function addScrollListeners() {
  10683. const elements = document.querySelectorAll("div");
  10684. elements.forEach((el) => {
  10685. el.addEventListener("scroll", checkScroll);
  10686. });
  10687. }
  10688. const observer = new MutationObserver(() => {
  10689. addScrollListeners();
  10690. checkScroll();
  10691. });
  10692. observer.observe(document.body, {
  10693. childList: true,
  10694. subtree: true,
  10695. });
  10696. window.addEventListener("resize", checkScroll);
  10697. }
  10698. app.component("SsLoginIcon", SsLoginIcon);
  10699. app.component("SsMark", SsMark);
  10700. app.component("SsFullStyleHeader", SsFullStyleHeader);
  10701. app.component("SsDialog", SsDialog);
  10702. app.component("SsInp", SsInput);
  10703. app.component("SsObjp", SsObjp);
  10704. app.component("SsHidden", SsHidden);
  10705. app.component("SsCcp", SsCcp);
  10706. app.component("SsDatePicker", SsDatePicker);
  10707. app.component("SsIcon", SsIcon);
  10708. app.component("SsCommonIcon", SsCommonIcon);
  10709. app.component("SsBreadcrumb", SsBreadcrumb);
  10710. app.component("SsEditor", SsEditor);
  10711. app.component("SsDialogIcon", SsDialogIcon);
  10712. app.component("SsBottomButton", SsBottomButton);
  10713. app.component("ss-btn", SsBottomButton);
  10714. app.component("SsNavIcon", SsNavIcon);
  10715. app.component("SsHeaderIcon", SsHeaderIcon);
  10716. app.component("SsGolbalMenuIcon", SsGolbalMenuIcon);
  10717. app.component("SsCartListIcon", SsCartListIcon);
  10718. app.component("SsQuickIcon", SsQuickIcon);
  10719. app.component("SsFormIcon", SsFormIcon);
  10720. app.component("SsBottomDivIcon", SsBottomDivIcon);
  10721. app.component("SsEditorIcon", SsEditorIcon);
  10722. app.component("SsValidate", SsValidate);
  10723. app.component("SsOnoff", Ssonoff);
  10724. app.component("SsonoffArray", SsonoffArray);
  10725. app.component("SsTextarea", SsTextarea);
  10726. app.component("SsLoginInput", SsLoginInput);
  10727. app.component("SsLoginButton", SsLoginButton);
  10728. app.component("SsSearch", SsSearch);
  10729. app.component("SsCartItem", SsCartItem);
  10730. app.component("SsCartItem2", SsCartItem2);
  10731. app.component("SsListCard", SsListCard);
  10732. app.component("ss-cobj-card-list", SsCObjCardList);
  10733. app.component("SsFolderCard", SsFolderCard);
  10734. app.component("ss-sidebar", SsSidebar);
  10735. app.component("ss-sidebar-buttons", SsSidebarButtons);
  10736. app.component("ss-sidebar-chart", SsSidebarChart);
  10737. app.component("ss-sidebar-chart-hover", SsSidebarChartHover);
  10738. app.component("ss-sidebar-list", SsSidebarList);
  10739. app.component("ss-sidebar-report-table", SsSidebarReportTable);
  10740. app.component("SsFolderCartView", SsFolderCartView);
  10741. app.component("SsPage", SsPage);
  10742. app.component("SsRightInfo", SSRightInfo);
  10743. app.component("SsSuccessPopup", SsSuccessPopup);
  10744. app.component("SsErrorDialog", SsErrorDialog);
  10745. app.component("SsVerify", SsVerify);
  10746. app.component("SsVerifyNode", SsVerifyNode);
  10747. app.component("SsOrcImgBox", SsOrcImgBox);
  10748. app.component("ss-search-input", SsSearchInput);
  10749. app.component("ss-search-date-picker", SsSearchDatePicker);
  10750. app.component("ss-search-button", SsSearchButton);
  10751. app.component("ss-drop-button", SsDropButton);
  10752. app.component("ss-sub-tab", SsSubTab);
  10753. app.component("ss-img", SsImgUpload);
  10754. app.use(ElementPlus, {
  10755. locale: ElementPlusLocaleZhCn,
  10756. });
  10757. for (const componentName in IndexComponents) {
  10758. app.component(componentName, IndexComponents[componentName]);
  10759. }
  10760. for (const componentName in EchartComponents) {
  10761. app.component(componentName, EchartComponents[componentName]);
  10762. }
  10763. let vm;
  10764. try {
  10765. vm = app.mount(el);
  10766. vm.data = vueOptions.data();
  10767. window.SS.dom._registerVueApp({
  10768. vm,
  10769. el,
  10770. appKey,
  10771. scope,
  10772. href: window.location.href,
  10773. });
  10774. console.log("vm:", vm);
  10775. console.log("vueOptions:", vueOptions);
  10776. } catch (error) {
  10777. console.log("Mount failed:" + error);
  10778. }
  10779. return vm;
  10780. };
  10781. })();