ss-components.js 292 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275
  1. import { ssIcon, commonIcon } from "./icon-config.js";
  2. import * as IndexComponents from "./ss-index-components.js";
  3. import * as EchartComponents from "./ss-echarts-compnents.js";
  4. import { isNum, toStyleStr } from "./tools.js";
  5. import { EVEN_VAR } from "./EventBus.js";
  6. // import * as elements from "../lib/element-plus.js";
  7. (function () {
  8. const {
  9. createApp,
  10. ref,
  11. reactive,
  12. watch,
  13. onMounted,
  14. onBeforeUnmount,
  15. h,
  16. computed,
  17. resolveComponent,
  18. watchEffect,
  19. nextTick,
  20. onVnodeMounted,
  21. Teleport,
  22. inject,
  23. provide,
  24. } = Vue;
  25. // 弹窗默认遮罩z-index
  26. let currentZIndex = 100;
  27. // 目前已存在的弹窗
  28. const topWindow = window.top;
  29. topWindow.dialogInstances = topWindow.dialogInstances || [];
  30. // 新建弹窗
  31. function createSsDialogInstance(setting, callbackEvent) {
  32. currentZIndex += 10; // 动态提升 z-index
  33. const container = document.createElement("div");
  34. document.body.appendChild(container);
  35. const app = Vue.createApp({
  36. render() {
  37. return h(SsDialog, {
  38. ...setting,
  39. zIndex: currentZIndex,
  40. onClose() {
  41. document.body.removeChild(container); // 仅移除弹窗容器
  42. const index = topWindow.dialogInstances.indexOf(app);
  43. if (index > -1) {
  44. topWindow.dialogInstances.splice(index, 1); // 移除实例
  45. }
  46. // 关闭后的回调
  47. if (callbackEvent && typeof callbackEvent === "function") {
  48. callbackEvent();
  49. }
  50. app.unmount(); // 仅卸载弹窗实例
  51. if (container.parentNode) {
  52. container.parentNode.removeChild(container); // 确保移除容器
  53. }
  54. },
  55. });
  56. },
  57. });
  58. topWindow.dialogInstances.push({ app, callbackEvent, container });
  59. app.component("ss-mark", SsMark); // 注册 ss-mark 组件
  60. app.component("ss-icon", SsIcon);
  61. app.component("ss-full-style-header", SsFullStyleHeader); // 注册 ss-full-style-header 组件
  62. app.mount(container);
  63. }
  64. // ss-breadcrumb 一级菜单页面面包屑
  65. const SsBreadcrumb = {
  66. name: "SsBreadcrumb",
  67. props: {
  68. level: {
  69. type: Object,
  70. default: null,
  71. },
  72. },
  73. setup(props) {
  74. const currentMenu = ref(null);
  75. const folderPath = ref([]);
  76. const eventBus = window.parent.sharedEventBus;
  77. // 监听页面变化
  78. onMounted(() => {
  79. // 获取初始页面
  80. currentMenu.value = eventBus.getState(EVEN_VAR.currentPage);
  81. folderPath.value = eventBus.getState("folderPath") || [];
  82. // 订阅页面变化
  83. eventBus.subscribe(EVEN_VAR.currentPage, (page) => {
  84. currentMenu.value = page;
  85. });
  86. eventBus.subscribe("folderPath", (path) => {
  87. folderPath.value = path || [];
  88. });
  89. });
  90. // 修改点击处理函数
  91. const handlePathClick = (index) => {
  92. if (props.level?.onBack) {
  93. // 截取到点击的位置,后面的路径会被销毁
  94. const newPath = folderPath.value.slice(0, index + 1);
  95. eventBus.publish("folderPath", newPath);
  96. // 返回到对应层级
  97. const targetFolder = newPath[newPath.length - 1]?.folder || null;
  98. props.level.onBack(targetFolder);
  99. }
  100. };
  101. const SsCommonIcon = resolveComponent("SsCommonIcon");
  102. return () =>
  103. h("div", { class: "bread-crumb" }, [
  104. currentMenu.value &&
  105. h(
  106. "div",
  107. {
  108. onClick: () => {
  109. if (props.level?.onBack) {
  110. eventBus.publish("folderPath", []);
  111. props.level.onBack(null); // 返回到根目录
  112. } else {
  113. eventBus.publish(EVEN_VAR.currentPage, currentMenu.value);
  114. }
  115. },
  116. },
  117. currentMenu.value.label || currentMenu.value.name
  118. ),
  119. ...(folderPath.value || [])
  120. .map((folder, index) => [
  121. h(SsCommonIcon, { class: "common-icon-arrow-right" }),
  122. h(
  123. "div",
  124. {
  125. class: "bread-crumb-item",
  126. onClick: () => handlePathClick(index),
  127. style: { cursor: "pointer" },
  128. },
  129. folder.title
  130. ),
  131. ])
  132. .flat(),
  133. ]);
  134. },
  135. };
  136. // ss-input form表单的输入
  137. const SsInput = {
  138. name: "SsInp",//把SsInput改为SsInp Ben(20251225)
  139. inheritAttrs: false, // 不直接继承属性到组件根元素
  140. props: {
  141. name: {
  142. type: String,
  143. required: true,
  144. default: "",
  145. },
  146. // 接收 v-model 绑定的值
  147. errTip: {
  148. type: String,
  149. },
  150. required: {
  151. type: Boolean,
  152. default: false,
  153. },
  154. placeholder: {
  155. type: String,
  156. default: "请输入",
  157. },
  158. defaultValue: [String, Number],
  159. modelValue: [String, Number],
  160. // 新增:附件配置
  161. fj: {
  162. type: Object,
  163. default: null,
  164. },
  165. // 新增:param 配置(用于附件功能)
  166. param: {
  167. type: Object,
  168. default: null,
  169. },
  170. // 新增:高度配置
  171. height: {
  172. type: String,
  173. default: "",
  174. },
  175. // 新增:是否允许回车换行,默认false禁止换行 by xu 20251212
  176. multiline: {
  177. type: Boolean,
  178. default: false,
  179. },
  180. },
  181. emits: ["update:modelValue", "input", "blur", "change"], // 允许更新 v-model 绑定的值
  182. setup(props, { emit }) {
  183. const errMsg = ref("");
  184. const inputRef = ref(null);
  185. const textareaRef = ref(null);
  186. const inputValue = ref(props.modelValue || props.defaultValue || "");
  187. const contentFloatingDiv = ref(false); // 控制浮动 DIV 的显示
  188. const floatingDivPosition = ref("bottom"); // 'bottom' 或 'top'
  189. const isFocused = ref(false); // 跟踪焦点状态
  190. // 附件相关变量(仅在传入 param 时初始化)
  191. let fjid = ref(null);
  192. let fjName = null;
  193. let mode = null;
  194. if (props.param && props.param.button) {
  195. fjid = ref(props.param.button.val);
  196. fjName = props.param.button.desc;
  197. mode = props.param.mode;
  198. }
  199. const showRequired = computed(() => {
  200. // 检查是否有验证规则(通过 window.ssVm 判断)
  201. const hasValidationRule = window.ssVm?.validations?.has(props.name);
  202. if (!hasValidationRule) return false;
  203. if (errMsg.value) return true;
  204. if (!inputValue.value) return true;
  205. return false;
  206. });
  207. // 计算floatdiv应该向上还是向下展开
  208. const calculateFloatingDivPosition = () => {
  209. nextTick(() => {
  210. const textarea = inputRef.value;
  211. if (!textarea) return;
  212. const rect = textarea.getBoundingClientRect();
  213. const viewportHeight = window.innerHeight;
  214. // 预估floatdiv的高度(最多5行 * 20px + 上下padding + border)
  215. const estimatedFloatDivHeight = 20 * 5 + 10 + 2; // 5行 + padding + border = 112px
  216. // 检查下方空间
  217. const spaceBelow = viewportHeight - rect.bottom;
  218. // 如果下方空间不足,且上方空间足够,则向上展开
  219. if (spaceBelow < estimatedFloatDivHeight && rect.top > estimatedFloatDivHeight) {
  220. floatingDivPosition.value = "top";
  221. } else {
  222. floatingDivPosition.value = "bottom";
  223. }
  224. });
  225. };
  226. // 计算floatdiv的top偏移量
  227. const getFloatingDivTop = computed(() => {
  228. if (props.height) {
  229. // 有height时,padding是5px
  230. return '5px';
  231. } else {
  232. // 没有height时是单行居中,需要计算居中位置
  233. // 假设input-container高度是32px(或者从CSS读取),单行20px
  234. // 居中偏移 = (容器高度 - 行高) / 2 = (32 - 20) / 2 = 6px
  235. return '6px';
  236. }
  237. });
  238. const validate = () => {
  239. if (window.ssVm) {
  240. const result = window.ssVm.validateField(props.name);
  241. console.log(result);
  242. errMsg.value = result.valid ? "" : result.message;
  243. }
  244. };
  245. // 使用 watch 监听 props.errTip 和 props.modelValue 的变化
  246. watch(
  247. () => props.errTip,
  248. (newVal) => {
  249. errMsg.value = newVal;
  250. },
  251. { immediate: true }
  252. );
  253. watch(
  254. () => props.modelValue,
  255. (newVal) => {
  256. inputValue.value = newVal;
  257. }
  258. );
  259. // 挂载时的逻辑
  260. onMounted(() => {
  261. errMsg.value = props.errTip;
  262. inputValue.value = props.modelValue || props.defaultValue || "";
  263. });
  264. // 计算并调整textarea的高度
  265. const adjustHeight = () => {
  266. nextTick(() => {
  267. const textarea = textareaRef.value;
  268. if (!textarea) return;
  269. // floatDiv的textarea始终自动计算高度,不受props.height影响
  270. // 重置高度以获得正确的scrollHeight
  271. textarea.style.height = "auto";
  272. // 计算新高度 - 统一限制为5行
  273. const lineHeight = parseInt(getComputedStyle(textarea).lineHeight, 10);
  274. const maxHeight = lineHeight * 5; // 统一为5行
  275. const newHeight = Math.min(textarea.scrollHeight, maxHeight);
  276. textarea.style.height = `${newHeight}px`;
  277. });
  278. };
  279. // 检查是否应该显示浮动窗口(需要同时满足:有焦点 + 内容超出)
  280. // 修复新增页面点击就出现floatdiv的问题 by xu 20251212
  281. const checkShouldShowFloatingDiv = () => {
  282. const textarea = inputRef.value;
  283. if (!textarea) return false;
  284. // 首先检查是否有内容,没有内容时不显示floatdiv by xu 20251212
  285. if (!inputValue.value || inputValue.value.toString().trim() === '') {
  286. console.log('[floatdiv] 内容为空,不显示floatdiv');
  287. return false;
  288. }
  289. // 判断内容是否超出 by xu 20251212
  290. // 同时检查横向和纵向溢出,任一方向溢出都应显示floatdiv
  291. // 纵向溢出需要加容差值,避免padding/border导致的误判 by xu 20251212
  292. const verticalTolerance = 5; // 容差值5px
  293. const isHorizontalOverflow = textarea.scrollWidth > textarea.clientWidth;
  294. const isVerticalOverflow = textarea.scrollHeight > textarea.clientHeight + verticalTolerance;
  295. const isOverflow = isHorizontalOverflow || isVerticalOverflow;
  296. console.log('[floatdiv] 溢出检测 - scrollWidth:', textarea.scrollWidth, 'clientWidth:', textarea.clientWidth, 'horizontalOverflow:', isHorizontalOverflow);
  297. console.log('[floatdiv] 溢出检测 - scrollHeight:', textarea.scrollHeight, 'clientHeight:', textarea.clientHeight, 'tolerance:', verticalTolerance, 'verticalOverflow:', isVerticalOverflow);
  298. const shouldShow = isFocused.value && isOverflow;
  299. console.log('[floatdiv] 最终判断 - isFocused:', isFocused.value, 'isOverflow:', isOverflow, 'shouldShow:', shouldShow);
  300. // 需要同时满足:有焦点 + 内容超出
  301. return shouldShow;
  302. };
  303. // 定义事件处理函数
  304. const onInput = (event) => {
  305. const newValue = event.target.value;
  306. inputValue.value = newValue;
  307. emit("update:modelValue", newValue);
  308. validate(); // 输入时验证
  309. nextTick(() => {
  310. // 检查是否需要显示浮动div
  311. contentFloatingDiv.value = checkShouldShowFloatingDiv();
  312. // 如果需要显示floatdiv,计算其位置
  313. if (contentFloatingDiv.value) {
  314. calculateFloatingDivPosition();
  315. }
  316. });
  317. adjustHeight();
  318. };
  319. const onFocus = (event) => {
  320. // 设置焦点状态为true
  321. isFocused.value = true;
  322. adjustHeight();
  323. // 检查是否应该显示浮动窗口
  324. nextTick(() => {
  325. contentFloatingDiv.value = checkShouldShowFloatingDiv();
  326. if (contentFloatingDiv.value) {
  327. calculateFloatingDivPosition();
  328. }
  329. });
  330. };
  331. // 失去焦点时进行验证
  332. const onBlur = (event) => {
  333. emit("blur", event.target);
  334. validate(); // 失焦时验证
  335. nextTick(() => {
  336. // 如果焦点不在 textarea 上,则隐藏浮动 div
  337. if (!document.activeElement.classList.contains("input-control")) {
  338. isFocused.value = false;
  339. contentFloatingDiv.value = false;
  340. }
  341. });
  342. };
  343. const onChange = (event) => {
  344. inputValue.value = event.target.value || "";
  345. emit("change", inputValue.value);
  346. };
  347. const onMouseover = (event) => {
  348. nextTick(() => {
  349. // setTimeout(contentFloatingDiv.value = true, 500)
  350. });
  351. };
  352. const onMouseleave = (event) => {
  353. // contentFloatingDiv.value = false
  354. };
  355. // 处理键盘按下事件,禁止回车换行 by xu 20251212
  356. const onKeydown = (event) => {
  357. // 如果不允许多行且按下的是回车键,阻止默认行为
  358. if (!props.multiline && event.key === 'Enter') {
  359. event.preventDefault();
  360. }
  361. };
  362. // 附件按钮点击处理(从 SsEditor 搬运)
  363. const onAttachmentClick = (e) => {
  364. e.preventDefault();
  365. if (!props.param || !props.param.button) {
  366. console.warn("未配置 param 参数");
  367. return;
  368. }
  369. console.log("附件点击了");
  370. console.log("param", props.param);
  371. console.log("cmsAddUrl", props.param.button.cmsAddUrl);
  372. // 如果 fjid 为空,先调用 cmsAddUrl 创建
  373. if (fjid.value == null || fjid.value == "") {
  374. $.ajax({
  375. type: "post",
  376. url: props.param.button.cmsAddUrl,
  377. async: false,
  378. data: {
  379. name: "fjid",
  380. ssNrObjName: "sh",
  381. ssNrObjId: "",
  382. },
  383. success: function (_fjid) {
  384. console.log("cmsAddUrl success", _fjid);
  385. fjid.value = _fjid;
  386. },
  387. });
  388. }
  389. // 构建参数字符串
  390. var str =
  391. "&nrid=T-" +
  392. fjid.value +
  393. "&objectId=" +
  394. fjid.value +
  395. "&objectName=" +
  396. fjName +
  397. "&callback=" +
  398. (window["fjidCallbackName"] || "");
  399. console.log("str", str);
  400. // 打开附件编辑对话框
  401. SS.openDialog({
  402. src: props.param.button.cmsUpdUrl + str,
  403. headerTitle: "编辑",
  404. width: 900,
  405. high: 664,
  406. zIndex: 51,
  407. });
  408. };
  409. return {
  410. errMsg,
  411. inputValue,
  412. showRequired,
  413. onInput,
  414. onBlur,
  415. onChange,
  416. onMouseover,
  417. onMouseleave,
  418. onKeydown, // 新增:键盘事件处理 by xu 20251212
  419. contentFloatingDiv,
  420. floatingDivPosition,
  421. getFloatingDivTop,
  422. inputRef,
  423. textareaRef,
  424. onFocus,
  425. onAttachmentClick,
  426. fjid, // 附件 ID,用于隐藏字段
  427. };
  428. },
  429. render() {
  430. const { resolveComponent, h } = Vue;
  431. const SsIcon = resolveComponent("ss-icon");
  432. const SsEditorIcon = resolveComponent("SsEditorIcon");
  433. // 构建主textarea的样式
  434. const mainTextareaStyle = {};
  435. if (this.height) {
  436. mainTextareaStyle.height = "auto"
  437. // mainTextareaStyle.paddingTop = '5px'; // 有高度时加上padding-top
  438. // mainTextareaStyle.paddingBottom = '5px'; // 有高度时加上padding-bottom
  439. } else {
  440. // 没有指定height时,固定为单行高度
  441. mainTextareaStyle.height = '20px'; // 行高20px
  442. mainTextareaStyle.lineHeight = '20px'; // 确保单行垂直居中
  443. mainTextareaStyle.display = 'flex';
  444. mainTextareaStyle.marginBottom = '5px';
  445. }
  446. // 如果有附件按钮,为按钮留出空间
  447. if (this.fj || (this.param&&this.param.button)) {//加上&&this.param.button条件 Ben(20251221)
  448. mainTextareaStyle.paddingRight = '75px';
  449. }
  450. const mainTextareaRows = this.height ? Math.floor(parseFloat('80px') / 20) : 1
  451. return h("div", { class: "input" }, [
  452. h("div", { class: "input-container", }, [
  453. h("div", { class: "input",style:"padding:5px 0" }, [
  454. h("textarea", {
  455. ref: "inputRef",
  456. class: "input-control",
  457. name: this.name,
  458. value: this.inputValue,
  459. onInput: this.onInput,
  460. onFocus: this.onFocus,
  461. onBlur: this.onBlur,
  462. onChange: this.onChange,
  463. onKeydown: this.onKeydown, // 新增:禁止回车换行 by xu 20251212
  464. placeholder: this.placeholder,
  465. onMouseover: this.onMouseover, // 监听鼠标悬停
  466. onMouseleave: this.onMouseleave, // 监听鼠标离开
  467. rows:mainTextareaRows,
  468. ...this.$attrs,
  469. style: mainTextareaStyle,
  470. autocomplete: "off",
  471. }),
  472. // 附件按钮(优先使用 param,兼容旧的 fj)
  473. this.fj||(this.param&&this.param.button)//加上&&this.param.button条件 Ben(20251221)
  474. ? h(
  475. "button",
  476. {
  477. type: "button",
  478. class: "fj-button",
  479. onClick: this.param ? this.onAttachmentClick : (e) => {
  480. e.preventDefault();
  481. console.log("附件配置:", this.fj);
  482. },
  483. },
  484. [
  485. h(SsEditorIcon, {
  486. class: "editor-icon-link",
  487. }),
  488. h("span", { class: "fj-button-text" }, "附件")
  489. ]
  490. )
  491. : null,
  492. // this.showRequired ? h("div", { class: "required" }) : null,
  493. ]),
  494. this.contentFloatingDiv || ""
  495. ? h("div", {
  496. class: "floating-div",
  497. style: this.floatingDivPosition === "bottom"
  498. ? {
  499. // 向下展开: 覆盖原输入框,top对齐首行
  500. top: this.getFloatingDivTop,
  501. bottom: 'auto',
  502. }
  503. : {
  504. // 向上展开: 同样覆盖原输入框,但从底部开始计算
  505. top: 'auto',
  506. bottom: this.height ? '5px' : '6px', // 对齐到原textarea的底部padding位置
  507. }
  508. }, [
  509. h("textarea", {
  510. ref: "textareaRef",
  511. class: "input-control",
  512. value: this.inputValue,
  513. onInput: this.onInput,
  514. onBlur: this.onBlur,
  515. onFocus: this.onFocus,
  516. onKeydown: this.onKeydown, // 新增:禁止回车换行 by xu 20251212
  517. onMouseover: this.onMouseover, // 监听鼠标悬停
  518. onMouseleave: this.onMouseleave, // 监听鼠标离开
  519. autocomplete: "off",
  520. onVnodeMounted: (vnode) => {
  521. vnode.el.focus();
  522. },
  523. }),
  524. ])
  525. : null,
  526. // this.errMsg ? h(SsValidate, { errMsg: this.errMsg }) : null,
  527. ]),
  528. // 附件相关的隐藏字段(仅在有 param 时才渲染)
  529. this.param && [
  530. // fjid 隐藏字段(只有当 fjid 有值时才渲染)
  531. this.fjid && this.fjid.value &&
  532. h("input", {
  533. type: "hidden",
  534. name: "fjid",
  535. value: this.fjid.value,
  536. }),
  537. // 其他隐藏字段根据 name 生成
  538. /* 去掉。文本框不需要(这是富文本才有的) Ben 20251205
  539. h("input", {
  540. type: "hidden",
  541. name: this.name.replace(/wj$/, "") + "Edit",
  542. value: this.inputValue
  543. }),
  544. */
  545. // h("input", {
  546. // type: "hidden",
  547. // name: this.name.replace(/wj$/, "") + "wj",
  548. // value: this.inputValue
  549. // }),
  550. /* 去掉。文本框不需要(这是富文本才有的) Ben 20251205
  551. h("input", {
  552. type: "hidden",
  553. name: "ueditorpath",
  554. value: this.name
  555. }),
  556. */
  557. ],
  558. ]);
  559. },
  560. };
  561. // ss-normal-input 登录输入
  562. const SsLoginInput = {
  563. name: "SsLoginInput",
  564. inheritAttrs: false,
  565. props: {
  566. errTip: {
  567. type: String,
  568. },
  569. type: {
  570. type: String,
  571. default: "text",
  572. },
  573. required: {
  574. type: Boolean,
  575. default: false,
  576. },
  577. placeholder: {
  578. type: String,
  579. default: "请输入",
  580. },
  581. name: {
  582. type: String,
  583. default: "",
  584. },
  585. defaultValue: [String, Number],
  586. modelValue: [String, Number],
  587. },
  588. emits: ["update:modelValue", "input", "blur", "change"], // 允许更新 v-model 绑定的值
  589. setup(props, { emit }) {
  590. const errMsg = ref("");
  591. const inputRef = ref(null);
  592. const textareaRef = ref(null);
  593. const inputValue = ref(props.modelValue || props.defaultValue || "");
  594. // 使用 watch 监听 props.errTip 和 props.modelValue 的变化
  595. watch(
  596. () => props.errTip,
  597. (newVal) => {
  598. errMsg.value = newVal;
  599. },
  600. { immediate: true }
  601. );
  602. watch(
  603. () => props.modelValue,
  604. (newVal) => {
  605. inputValue.value = newVal;
  606. }
  607. );
  608. // 挂载时的逻辑
  609. onMounted(() => {
  610. errMsg.value = props.errTip;
  611. inputValue.value = props.modelValue || props.defaultValue || "";
  612. });
  613. // 定义事件处理函数
  614. const onInput = (event) => {
  615. const newValue = event.target.value;
  616. inputValue.value = newValue;
  617. emit("update:modelValue", newValue);
  618. };
  619. return { inputValue, onInput, inputRef, textareaRef };
  620. },
  621. render() {
  622. return h("div", { class: "input" }, [
  623. h("div", { class: "input-container" }, [
  624. h("div", { class: "input" }, [
  625. h("input", {
  626. ref: "inputRef",
  627. class: "input-control",
  628. name: this.name,
  629. value: this.inputValue,
  630. onInput: this.onInput,
  631. type: this.type,
  632. placeholder: this.placeholder,
  633. required: this.required,
  634. ...this.$attrs,
  635. autocomplete: "off",
  636. }),
  637. this.required ? h("div", { class: "required" }) : null,
  638. ]),
  639. ]),
  640. ]);
  641. },
  642. };
  643. // ss-login-button
  644. const SsLoginButton = {
  645. name: "SsLoginButton",
  646. inheritAttrs: false,
  647. props: {
  648. class: {
  649. type: String,
  650. default: "",
  651. },
  652. text: {
  653. type: String,
  654. default: "",
  655. },
  656. type: {
  657. type: String,
  658. default: "button",
  659. },
  660. },
  661. emits: ["click"],
  662. setup(props, { emit }) {
  663. // 定义事件处理函数
  664. const onClick = (event) => {
  665. // 发射一个 'click' 事件,你可以传递所需的参数
  666. emit("click", event);
  667. };
  668. return { props, onClick };
  669. },
  670. render() {
  671. const SsIcon = resolveComponent("ss-icon");
  672. const SsLoginIcon = resolveComponent("ss-login-icon");
  673. return h(
  674. "button",
  675. { class: "login-button", type: this.type, onClick: this.onClick },
  676. [
  677. h("span", [h(SsLoginIcon, { class: this.class })]),
  678. h("span", {}, this.text),
  679. ]
  680. );
  681. },
  682. };
  683. // ss-objp 下拉选择
  684. const SsObjp = {
  685. name: "SsObjp",
  686. inheritAttrs: false,
  687. props: {
  688. onchange: { //在此属性传入onChange的window全局回调函数,函数唯一参数是当前选中值 Ben(20251217)
  689. type: String,
  690. required: false,
  691. },
  692. filter: {
  693. type: String,
  694. required: false,
  695. },
  696. cb: {
  697. type: String,
  698. required: true,
  699. },
  700. url: {
  701. type: String,
  702. required: true,
  703. },
  704. name: {
  705. type: String,
  706. required: true,
  707. },
  708. width: {
  709. type: String,
  710. default: "100%",
  711. },
  712. placeholder: {
  713. type: String,
  714. default: "请选择",
  715. },
  716. inp: {
  717. type: Boolean,
  718. default: false,
  719. },
  720. opt: {
  721. type: Array,
  722. default: () => [],
  723. },
  724. errTip: String,
  725. defaultValue: [String, Number],
  726. modelValue: [String, Number],
  727. direction: {
  728. type: String,
  729. default: "bottom",
  730. },
  731. },
  732. emits: ["update:modelValue", "input", "blur", "change"],
  733. setup(props, { emit }) {
  734. const canInput = props.inp;
  735. const errMsg = Vue.ref(props.errTip);
  736. const selectItem = Vue.ref({});
  737. let inputText = Vue.ref(""); // 用于存储输入框的文本
  738. const popupWinVisible = Vue.ref(false);
  739. const filteredOptions = Vue.ref(props.opt);
  740. const popupDirection = Vue.ref("bottom");
  741. const popupMaxHeight = Vue.ref("none"); // popup最大高度,用于空间不足时限制高度并出滚动条 by xu 20251212
  742. // const showRequired = Vue.computed(() => {
  743. // const hasValidationRule = window.ssVm?.validations?.has(props.name);
  744. // if (!hasValidationRule) return false;
  745. // if (errMsg.value) return true;
  746. // if (!selectItem.value?.value) return true;
  747. // return false;
  748. // });
  749. const validate = () => {
  750. if (window.ssVm) {
  751. const result = window.ssVm.validateField(props.name);
  752. // console.log("validate", window.ssVm.validateField(props.name));
  753. errMsg.value = result.valid ? "" : result.message;
  754. }
  755. };
  756. //在objPicker界面,选中value对应的项
  757. const updateSelectItem = () => {
  758. // console.log(props.opt);
  759. const item = props.opt.find((it) => it.value === props.modelValue);
  760. if (item) {
  761. selectItem.value = item;
  762. inputText.value = item.label;
  763. } else {
  764. selectItem.value = { label: "", value: "" };
  765. inputText.value = "";
  766. }
  767. // validate();
  768. };
  769. Vue.watch(
  770. () => props.errTip,
  771. (newVal) => {
  772. errMsg.value = newVal;
  773. }
  774. );
  775. Vue.watch(() => props.modelValue, updateSelectItem, { immediate: true });
  776. Vue.watch(
  777. () => props.opt,
  778. (newVal) => {
  779. updateSelectItem();
  780. filteredOptions.value = [...newVal];
  781. // console.log("filteredOptions", filteredOptions.value);
  782. }
  783. );
  784. //初始化objPicker在页面刚打开时的默认值
  785. async function initDefaultValue() {
  786. try {
  787. if (props.url && props.cb && props.modelValue) {
  788. let objectPickerParam;
  789. let url = props.url;
  790. //如果有定义过滤器
  791. if (props.filter) {
  792. //包含HTML实体的JSON字符串转为JSON对象,如原字符串是{&quot;dwid&quot;:&quot;88&quot;},注意key也必需用单引号包着
  793. // const decodedString = props.filter.replace(/&quot;/g, '"'); // 转换为: {"dwid":"88"}
  794. // objectPickerParam = JSON.parse(decodedString); // 转为json对象
  795. const filterObj = props.filter; // 转为json对象
  796. for (let k in filterObj) {
  797. let v = filterObj[k];
  798. url += "&" + k + "=" + v;
  799. }
  800. objectPickerParam = props.filter; // 转为json对象
  801. objectPickerParam["input"] = props.inp;
  802. objectPickerParam["codebook"] = props.cb;
  803. // alert(url);
  804. } else {
  805. objectPickerParam = { input: props.inp, codebook: props.cb };
  806. }
  807. const objectPickerParamStr = JSON.stringify(objectPickerParam);
  808. const params = new URLSearchParams();
  809. params.append("objectpickerparam", objectPickerParamStr);
  810. params.append("objectpickertype", "2");
  811. params.append("objectpickervalue", props.modelValue); //需回显的值
  812. // alert("1params:"+JSON.stringify(params));
  813. axios
  814. .post(props.url, params, {
  815. headers: {
  816. "Content-Type": "application/x-www-form-urlencoded", // 必须手动设置!
  817. },
  818. })
  819. .then((response) => {
  820. // alert(JSON.stringify(response.data));
  821. if ("timeout" == response.data.statusText) {
  822. alert("网络超时!");
  823. return;
  824. }
  825. if (response.data.result) {
  826. const keys = Object.keys(response.data.result);
  827. if (keys.length === 1) {
  828. let code = keys[0];
  829. let desc = response.data.result[keys[0]];
  830. if (props.opt)
  831. props.opt.length = 0; //通过修改数组的length属性,直接清空数组元素,内存会被自动释放。这是性能最优的方式
  832. else {
  833. props.opt = [];
  834. }
  835. props.opt.push({ label: desc, value: code });
  836. updateSelectItem();
  837. // alert('props.opt:'+JSON.stringify(props.opt));
  838. }
  839. }
  840. });
  841. }
  842. } catch (error) {
  843. // callback(null, error.message); // 失败回调,传递错误
  844. }
  845. }
  846. // Vue.onMounted(updateSelectItem);
  847. const doSelectItem = (item) => {
  848. emit("update:modelValue", item.value);
  849. selectItem.value = item;
  850. inputText.value = item.label;
  851. hidePopup();
  852. nextTick(() => {
  853. console.log(item.value + "@@@props.modelValue:" + props.modelValue);
  854. validate();
  855. if (window.ssVm) {
  856. // 遍历所有验证规则,找到依赖当前字段的规则
  857. for (const [field, rules] of window.ssVm.validations.entries()) {
  858. for (const rule of rules) {
  859. if (rule.opt?.relField === props.name) {
  860. // console.log("Found dependent field:", field); // 调试日志
  861. window.ssVm.validateField(field);
  862. }
  863. }
  864. }
  865. }
  866. });
  867. callGlobalOnchg(item.value,item.label); // 值变化时尝试调用全局onchange回调函数 Ben(20251217)
  868. };
  869. // 用于调用全局onchange回调函数 Ben(20251217)
  870. const callGlobalOnchg = (value,desc) => {
  871. // 检查 onchange 属性是否提供了有效的函数名
  872. if (props.onchange && typeof props.onchange === 'string') {
  873. // 检查 window 对象上是否存在该函数
  874. if (typeof window !== 'undefined' && window[props.onchange] && typeof window[props.onchange] === 'function') {
  875. try {
  876. window[props.onchange](value,desc) // 调用全局函数,并传入当前选中值
  877. } catch (error) {
  878. console.error(`调用全局函数 ${props.onchange} 时出错:`, error)
  879. }
  880. } else {
  881. console.warn(`全局函数 ${props.onchange} 未定义或不是一个函数。`)
  882. }
  883. }
  884. }
  885. //可录入的objPicker,更新下拉菜单选项
  886. async function updateOptionBYInputText(inpTxt) {
  887. try {
  888. let objectPickerParam;
  889. let url = props.url;
  890. if (props.url && props.cb) {
  891. //如果有定义过滤器
  892. if (props.filter) {
  893. const filterObj = props.filter; // 转为json对象
  894. for (let k in filterObj) {
  895. let v = filterObj[k];
  896. url += "&" + k + "=" + v;
  897. }
  898. //包含HTML实体的JSON字符串转为JSON对象,如原字符串是{&quot;dwid&quot;:&quot;88&quot;},注意key也必需用单引号包着
  899. // const decodedString = props.filter.replace(/&quot;/g, '"'); // 转换为: {"dwid":"88"}
  900. // objectPickerParam = JSON.parse(decodedString); // 转为json对象
  901. objectPickerParam = props.filter;
  902. objectPickerParam["input"] = props.inp;
  903. objectPickerParam["codebook"] = props.cb;
  904. // alert(url);
  905. } else {
  906. objectPickerParam = { input: props.inp, codebook: props.cb };
  907. }
  908. const objectPickerParamStr = JSON.stringify(objectPickerParam);
  909. const params = new URLSearchParams();
  910. params.append("objectpickerparam", objectPickerParamStr);
  911. params.append("objectpickertype", "1");
  912. if (props.inp && props.inp === true) {//把"true"改为true Ben(20251209)
  913. params.append("objectpickersearchAll", 0); //只查录入的值
  914. params.append("objectpickerinput", inpTxt); //录入的值
  915. } else {
  916. params.append("objectpickersearchAll", 1);
  917. }
  918. axios
  919. .post(url, params, {
  920. headers: {
  921. "Content-Type": "application/x-www-form-urlencoded", // 必须手动设置!
  922. },
  923. })
  924. .then((response) => {
  925. if ("timeout" == response.data.statusText) {
  926. alert("网络超时!");
  927. return;
  928. }
  929. // 先清空选项 by xu 20251212
  930. if (props.opt) {
  931. props.opt.length = 0;
  932. } else {
  933. props.opt = [];
  934. }
  935. if (response.data.result) {
  936. const keys = Object.keys(response.data.result);
  937. // console.log("params:"+params+"@@response.data:"+JSON.stringify(response.data));
  938. if (keys.length > 0) {
  939. for (let k in response.data.result) {
  940. props.opt.push({
  941. label: response.data.result[k],
  942. value: k,
  943. });
  944. }
  945. // console.log('###inpTxt:'+inpTxt+';');
  946. if (
  947. props.inp &&
  948. props.inp === true && //把"true"改为true Ben(20251209)
  949. inpTxt.length > 0
  950. ) {
  951. //对于可录入的,用已录入的值作过滤
  952. filteredOptions.value = props.opt.filter((option) =>
  953. option.label
  954. .toLowerCase()
  955. .includes(inputText.value.toLowerCase())
  956. );
  957. // 可录入的objPicker,当搜索结果只有一项时,自动选中这一项 by xu 20251212
  958. if (filteredOptions.value.length === 1) {
  959. const autoSelectItem = filteredOptions.value[0];
  960. console.log("[objp] 搜索结果只有一项,自动选中:", autoSelectItem);
  961. doSelectItem(autoSelectItem);
  962. return; // 自动选中后直接返回,不需要显示popup
  963. }
  964. filteredOptions.value.unshift({ label: "", value: "" });
  965. // console.log('###做了过滤:'+inputText.value.toLowerCase()+';');
  966. } else {
  967. filteredOptions.value = props.opt;
  968. filteredOptions.value.unshift({ label: "", value: "" });
  969. }
  970. console.log("props.opt11:" + JSON.stringify(props.opt));
  971. } else {
  972. // 没有数据时,清空过滤选项 by xu 20251212
  973. filteredOptions.value = [];
  974. console.log("[objp] 接口返回空数据");
  975. }
  976. } else {
  977. // result不存在时,清空过滤选项 by xu 20251212
  978. filteredOptions.value = [];
  979. console.log("[objp] 接口返回无result");
  980. }
  981. // 无论是否有数据,都显示popup by xu 20251212
  982. if (!popupWinVisible.value) {
  983. popupWinVisible.value = true;
  984. }
  985. });
  986. }
  987. } catch (error) {
  988. // callback(null, error.message); // 失败回调,传递错误
  989. }
  990. }
  991. // 计算弹出方向和最大高度的方法 by xu 20251212
  992. // 当空间不足时限制popup高度并显示滚动条
  993. const calculatePopupDirection = () => {
  994. // 1. 获取select容器元素
  995. const selectEl = document
  996. .querySelector(`[name="${props.name}"]`)
  997. ?.closest(".select-container");
  998. if (!selectEl) return;
  999. // 2. 获取位置信息
  1000. const selectRect = selectEl.getBoundingClientRect();
  1001. const viewportHeight = window.innerHeight;
  1002. // 3. 计算上下可用空间
  1003. const spaceBelow = viewportHeight - selectRect.bottom - 10; // 减10px留边距
  1004. const spaceAbove = selectRect.top - 10; // 减10px留边距
  1005. // 4. popup预估高度(假设每项36px,最多显示8项 + padding)
  1006. const estimatedPopupHeight = 300;
  1007. const minPopupHeight = 100; // 最小高度
  1008. console.log('[popup] 空间计算 - spaceAbove:', spaceAbove, 'spaceBelow:', spaceBelow, 'estimatedHeight:', estimatedPopupHeight);
  1009. // 5. 判断方向和最大高度 by xu 20251212
  1010. if (spaceBelow >= estimatedPopupHeight) {
  1011. // 下方空间足够,向下展开,不限制高度
  1012. popupDirection.value = "bottom";
  1013. popupMaxHeight.value = "none";
  1014. console.log('[popup] 向下展开,空间充足');
  1015. } else if (spaceAbove >= estimatedPopupHeight) {
  1016. // 上方空间足够,向上展开,不限制高度
  1017. popupDirection.value = "top";
  1018. popupMaxHeight.value = "none";
  1019. console.log('[popup] 向上展开,空间充足');
  1020. } else {
  1021. // 上下空间都不足,选择空间大的方向,并限制高度出滚动条
  1022. if (spaceBelow >= spaceAbove) {
  1023. popupDirection.value = "bottom";
  1024. popupMaxHeight.value = Math.max(spaceBelow, minPopupHeight) + "px";
  1025. console.log('[popup] 向下展开,空间不足,限制高度:', popupMaxHeight.value);
  1026. } else {
  1027. popupDirection.value = "top";
  1028. popupMaxHeight.value = Math.max(spaceAbove, minPopupHeight) + "px";
  1029. console.log('[popup] 向上展开,空间不足,限制高度:', popupMaxHeight.value);
  1030. }
  1031. }
  1032. };
  1033. //点击下拉菜单的文本区域时,会触发的方法
  1034. function togglePopup() {
  1035. // 可录入的 objPicker,更新下拉菜单选项
  1036. updateOptionBYInputText(inputText.value);
  1037. // popupWinVisible.value = !popupWinVisible.value;
  1038. Vue.nextTick(() => {
  1039. calculatePopupDirection();
  1040. });
  1041. }
  1042. const hidePopup = () => {
  1043. popupWinVisible.value = false;
  1044. };
  1045. //点击下拉菜单的三角形时,会触发的方法
  1046. // 添加toggle逻辑,点击时切换显示/隐藏 by xu 20251212
  1047. const suffixClick = () => {
  1048. // 如果popup已显示,则关闭 by xu 20251212
  1049. if (popupWinVisible.value) {
  1050. hidePopup();
  1051. console.log("[objp] 点三角关闭popup");
  1052. return;
  1053. }
  1054. //可录入的objPicker,更新下拉菜单选项
  1055. updateOptionBYInputText("");
  1056. Vue.nextTick(() => {
  1057. calculatePopupDirection();
  1058. });
  1059. console.log("[objp] 点三角打开popup");
  1060. };
  1061. //可录入的objPicker,录入项变化时,会触发
  1062. async function handleInputChange(event) {
  1063. inputText.value = event.target.value;
  1064. if (!inputText.value) {
  1065. inputText.value = "";
  1066. }
  1067. //可录入的objPicker,更新下拉菜单选项
  1068. updateOptionBYInputText(inputText.value);
  1069. // filteredOptions.value = props.opt.filter((option) =>
  1070. // option.label.toLowerCase().includes(inputText.value.toLowerCase())
  1071. // );
  1072. // if (!popupWinVisible.value) {
  1073. // popupWinVisible.value = true; // 确保下拉框在输入时打开
  1074. // }
  1075. }
  1076. Vue.onMounted(() => {
  1077. initDefaultValue();
  1078. window.addEventListener("resize", calculatePopupDirection);
  1079. });
  1080. Vue.onUnmounted(() => {
  1081. window.removeEventListener("resize", calculatePopupDirection);
  1082. });
  1083. return {
  1084. errMsg,
  1085. selectItem,
  1086. inputText,
  1087. canInput,
  1088. filteredOptions,
  1089. popupWinVisible,
  1090. popupDirection,
  1091. popupMaxHeight, // 添加popup最大高度 by xu 20251212
  1092. suffixClick,
  1093. togglePopup,
  1094. hidePopup,
  1095. doSelectItem,
  1096. handleInputChange,
  1097. };
  1098. },
  1099. template: `
  1100. <div class="input" style="position: relative" :style="{width: width}">
  1101. <div class="select-container" @mouseleave="hidePopup">
  1102. <div class="input" @click="togglePopup">
  1103. <input
  1104. type="hidden"
  1105. :name="name"
  1106. :value="selectItem.value"
  1107. .value="selectItem.value"
  1108. />
  1109. <input
  1110. v-model="inputText"
  1111. @input="handleInputChange"
  1112. v-if="canInput"
  1113. :placeholder="placeholder"
  1114. />
  1115. <input
  1116. v-else
  1117. :placeholder="placeholder"
  1118. :value="selectItem.label"
  1119. disabled
  1120. style="pointer-events: none;"
  1121. />
  1122. <div class="suffix" @click.stop="suffixClick">
  1123. <ss-form-icon :class="popupWinVisible ? 'form-icon-transform-select select' : 'form-icon-select'" />
  1124. </div>
  1125. </div>
  1126. <!-- popup弹出层,添加maxHeight和overflowY支持空间不足时滚动 by xu 20251212 -->
  1127. <div v-show="popupWinVisible" class="popup-win" :class="popupDirection" :style="{ maxHeight: popupMaxHeight, overflowY: popupMaxHeight !== 'none' ? 'auto' : 'visible' }">
  1128. <div v-if="opt && opt.length && filteredOptions.length > 0" class="popup-content">
  1129. <div class="content-area">
  1130. <div v-for="(item, index) in filteredOptions" :key="index" @click="doSelectItem(item)" :class="{ active: item.value === selectItem.value }">
  1131. <span class="check-icon">
  1132. <ss-form-icon class="form-icon-select-checked" />
  1133. </span>
  1134. <span>{{ item.label }}</span>
  1135. </div>
  1136. </div>
  1137. </div>
  1138. <div v-else class="popup-content"><div class="content-area"><div class="content-area"> <span>无选项</span></div></div></div>
  1139. </div>
  1140. </div>
  1141. </div>
  1142. `,
  1143. };
  1144. // ss-hidden 隐藏字段组件
  1145. const SsHidden = {
  1146. name: "SsHidden",
  1147. props: {
  1148. modelValue: String,
  1149. name: {
  1150. type: String,
  1151. required: true,
  1152. },
  1153. rule: {
  1154. type: String,
  1155. required: true,
  1156. },
  1157. param: {
  1158. type: String,
  1159. required: true,
  1160. },
  1161. url: {
  1162. type: String,
  1163. required: true,
  1164. },
  1165. },
  1166. emits: ["update:modelValue"],
  1167. setup(props, { emit }) {
  1168. const errMsg = Vue.ref("");
  1169. const validate = () => {
  1170. if (window.ssVm) {
  1171. const result = window.ssVm.validateField(props.name);
  1172. console.log("validate", window.ssVm.validateField(props.name));
  1173. errMsg.value = result.valid ? "" : result.message;
  1174. }
  1175. };
  1176. Vue.onMounted(() => {
  1177. /**
  1178. * 初始化级联菜单值初始值思路:
  1179. * 1. 带隐藏字段(即带编码规则)的级联菜单
  1180. * 在隐藏字段这,可以取到要回显的值和编码规则,从而计算出各级下拉菜单要回显的值。
  1181. * 然后通过ajax取各级级联菜单的值回显。
  1182. * 2. 不带隐藏字段的级联,只能在各个下拉菜单的setup事件中通过ajax取回显值回显
  1183. */
  1184. // 当同组级联下拉菜单选中值变化时,会调用本隐藏字段下面这方法设置隐藏字段值
  1185. window.addEventListener(
  1186. "cascader-setHiddenVal-" + props.name,
  1187. (event) => {
  1188. const { value } = event.detail;
  1189. emit("update:modelValue", value);
  1190. console.log(value);
  1191. setTimeout(() => {
  1192. validate();
  1193. }, 50);
  1194. }
  1195. );
  1196. // 如果有初始值,触发回显过程
  1197. if (props.modelValue) {
  1198. console.log("级联隐藏字段,开始回显,初始值:", props.modelValue);
  1199. triggerCascaderEcho(props.modelValue);
  1200. validate();
  1201. }
  1202. });
  1203. // 触发级联回显
  1204. const triggerCascaderEcho = (code) => {
  1205. /**
  1206. * 开始回显,初始值: 440304
  1207. * 解析后的所有值: Array(3)0: "440000"1: "440300"2: "440304"length: 3[[Prototype]]: Array(0)
  1208. */
  1209. const values = parseHiddenCodeForAll(code, props.rule);
  1210. console.log("解析后的所有值:", values);
  1211. // 转换为 JSON 对象
  1212. // const paramObj = JSON.parse(props.param);
  1213. const paramObj = props.param;
  1214. let selectArr = paramObj.fieldOrd; //保存本组级联菜单项的数组,如:['hksheng','hkshi','hkxian']
  1215. if (selectArr.length != values.length) {
  1216. // alert('属性'+props.name+'的值'+code+'与级联菜单中下拉菜单的数目不匹配!');
  1217. return;
  1218. }
  1219. // 按顺序触发回显,并增加延迟确保数据加载
  1220. /**
  1221. * 通过隐藏字段的setup事件,
  1222. * 循环遍历各级下拉菜单,并触发定义在下拉菜单中的'cascader-echo'事件,
  1223. * 在此事件中完成每个下拉菜单回显值操作(只取当前要回显的键值对显示,
  1224. * 下拉菜单所有的值,在点击下拉菜单时,才通过ajax取)。
  1225. */
  1226. values.forEach((value, index) => {
  1227. if (value) {
  1228. setTimeout(() => {
  1229. let upperVal = undefined;
  1230. if (index != 0) {
  1231. upperVal = values[index - 1];
  1232. }
  1233. const echoEvent = new CustomEvent(
  1234. "cascader-echo-" + selectArr[index],
  1235. {
  1236. detail: {
  1237. name: props.name,
  1238. value: value,
  1239. // level: index + 1,
  1240. isAuto: true, // 标记为自动回显
  1241. upperVal: upperVal,
  1242. },
  1243. }
  1244. );
  1245. console.log(props.name + "--upperValue:" + upperVal);
  1246. window.dispatchEvent(echoEvent);
  1247. }, index * 500); // 每级增加500ms延迟
  1248. }
  1249. });
  1250. };
  1251. // 解析所有级别的代码
  1252. const parseHiddenCodeForAll = (code, rule) => {
  1253. if (!code || !rule) return [];
  1254. // 获取规则中每段的长度
  1255. const segments = [];
  1256. let currentChar = rule[0];
  1257. let currentLength = 1;
  1258. for (let i = 1; i < rule.length; i++) {
  1259. if (rule[i] === currentChar) {
  1260. currentLength++;
  1261. } else {
  1262. segments.push(currentLength);
  1263. currentChar = rule[i];
  1264. currentLength = 1;
  1265. }
  1266. }
  1267. segments.push(currentLength);
  1268. // 解析每一级的值
  1269. const values = [];
  1270. let position = 0;
  1271. segments.forEach((length, index) => {
  1272. const value = code
  1273. .substring(0, position + length)
  1274. .padEnd(rule.length, "0");
  1275. values.push(value);
  1276. position += length;
  1277. });
  1278. return values;
  1279. };
  1280. watchEffect(() => {});
  1281. return {};
  1282. },
  1283. template: `<input type="hidden" :name="name" :value="modelValue">`,
  1284. };
  1285. // ss-cascader 级联选择器
  1286. const SsCcp = {
  1287. name: "SsCcp",
  1288. inheritAttrs: false,
  1289. props: {
  1290. modelValue: String,
  1291. name: {
  1292. type: String,
  1293. required: true,
  1294. },
  1295. level: {
  1296. type: Number,
  1297. required: true,
  1298. },
  1299. opt: {
  1300. type: Array,
  1301. default: () => [],
  1302. },
  1303. placeholder: {
  1304. type: String,
  1305. default: "请选择",
  1306. },
  1307. width: {
  1308. type: String,
  1309. default: "150px",
  1310. },
  1311. direction: {
  1312. type: String,
  1313. default: "bottom",
  1314. },
  1315. mode: {
  1316. type: String,
  1317. default: "1",
  1318. },
  1319. //级联菜单配置参数,如果是数组,则代表本下拉菜单是多套级联菜单共用的第一级菜单。如果是对象,则只有一套级联菜单用此下拉菜单。
  1320. param: {
  1321. type: String,
  1322. required: true,
  1323. },
  1324. //向后台拿数据的url
  1325. url: {
  1326. type: String,
  1327. required: true,
  1328. },
  1329. },
  1330. emits: ["update:modelValue", "change"],
  1331. setup(props, { emit }) {
  1332. // alert('级联菜单初始化:'+props.name+':--:'+props.modelValue);
  1333. const selectItem = Vue.ref({ label: props.placeholder, value: "" });
  1334. const popupWinVisible = Vue.ref(false);
  1335. const isAutoEcho = Vue.ref(false); // 用于标记是否是自动回显
  1336. const upperValue = Vue.ref(""); //上级下拉菜单当前值,在初始化下拉菜单默认值时,和上级下拉菜单的值变化时,修改此upperValue变量
  1337. const popupDirection = Vue.ref("bottom");
  1338. const popupMaxHeight = Vue.ref("none"); // popup最大高度,用于空间不足时限制高度并出滚动条 by xu 20251212
  1339. //有隐藏字段的下拉菜单,加载菜单项并展开事件
  1340. // 被上级下拉菜单选中值后,触发本下拉菜单刷新菜单项并弹出显示
  1341. window.addEventListener("cascader-open-" + props.name, async (event) => {
  1342. const { upperVal } = event.detail;
  1343. upperValue.value = upperVal;
  1344. console.log(
  1345. "22props.name:" +
  1346. props.name +
  1347. ",22props.upperValue:" +
  1348. upperValue.value
  1349. );
  1350. selectItem.value = ""; //清除本下拉菜单当前选中的值
  1351. emit("update:modelValue", ""); //通知父级
  1352. //清空下拉菜单,并设置第一项的值为placeholder
  1353. clearAndInit1stOpt();
  1354. //下个下拉菜单名
  1355. let nextSelName = getNextSel(props.name, props.param.fieldOrd);
  1356. if (nextSelName) {
  1357. //清下个下拉菜单选中值和选项
  1358. event = new CustomEvent("cascader-cleanOpt-" + nextSelName, {
  1359. detail: {},
  1360. });
  1361. window.dispatchEvent(event);
  1362. }
  1363. showPopup();
  1364. });
  1365. //设置mode2的下级下拉菜单的上级菜单当前值
  1366. function setNextSelectUpperValue() {
  1367. //设置下级菜单的上级菜单当前值upperValue
  1368. let paramArr = undefined;
  1369. if (Array.isArray(props.param)) {
  1370. paramArr = props.param;
  1371. } else {
  1372. paramArr = [];
  1373. paramArr.push(props.param);
  1374. }
  1375. for (const oneParam of paramArr) {
  1376. //下个下拉菜单名
  1377. const nextSelName = getNextSel(props.name, oneParam.fieldOrd);
  1378. if (nextSelName) {
  1379. setTimeout(() => {
  1380. const openNextEvent = new CustomEvent(
  1381. "cascade-setUpperVal-" + nextSelName,
  1382. {
  1383. detail: {
  1384. upperVal: props.modelValue,
  1385. },
  1386. }
  1387. );
  1388. window.dispatchEvent(openNextEvent);
  1389. }, 100);
  1390. }
  1391. } // end for
  1392. }
  1393. // 把上级 级联下拉菜单的值,设置进本组件的事件
  1394. window.addEventListener("cascade-setUpperVal-" + props.name, (event) => {
  1395. // alert('props.name:'+props.name+',props.upperValue:'+event.detail.upperVal);
  1396. const { upperVal } = event.detail;
  1397. upperValue.value = upperVal;
  1398. // console.log('props.name:'+props.name+',props.upperValue:'+upperValue.value);
  1399. });
  1400. //清空下拉菜单,并设置第一项的值为空
  1401. function clearAndInit1stOpt() {
  1402. if (props.opt)
  1403. props.opt.length = 0; //通过修改数组的length属性,直接清空数组元素,内存会被自动释放。这是性能最优的方式
  1404. else {
  1405. props.opt = [];
  1406. }
  1407. props.opt.push({ label: "", value: "" });
  1408. }
  1409. //获取下一级下拉菜单,如果下一级下拉菜单不存在,则返回undefined
  1410. function getNextSel(selName, selNameArr) {
  1411. // 检查参数有效性
  1412. if (!Array.isArray(selNameArr) || selNameArr.length === 0) {
  1413. return undefined;
  1414. }
  1415. // 查找当前元素的索引
  1416. const currentIndex = selNameArr.indexOf(selName);
  1417. // 如果元素不存在或已经是最后一个元素,返回undefined
  1418. if (currentIndex === -1 || currentIndex === selNameArr.length - 1) {
  1419. return undefined;
  1420. }
  1421. // 返回下一个元素
  1422. return selNameArr[currentIndex + 1];
  1423. }
  1424. // 处理选择事件
  1425. const doSelectItem = (item) => {
  1426. selectItem.value = item;
  1427. emit("update:modelValue", item.value); //修改本下拉菜单在vue中保存的值
  1428. // alert('item.value:'+item.value);
  1429. if (props.mode === "1") {
  1430. // mode 1 模式:修改隐藏字段值
  1431. let event = new CustomEvent(
  1432. "cascader-setHiddenVal-" + props.param.combField,
  1433. {
  1434. detail: {
  1435. value: item.value,
  1436. },
  1437. }
  1438. );
  1439. window.dispatchEvent(event);
  1440. }
  1441. emit("change", item.value); //触发配置的change方法
  1442. //设置下级菜单的上级菜单当前值upperValue
  1443. let paramArr = undefined;
  1444. if (Array.isArray(props.param)) {
  1445. paramArr = props.param;
  1446. } else {
  1447. paramArr = [];
  1448. paramArr.push(props.param);
  1449. }
  1450. for (const oneParam of paramArr) {
  1451. //下个下拉菜单名
  1452. const nextSelName = getNextSel(props.name, oneParam.fieldOrd);
  1453. if (nextSelName) {
  1454. setTimeout(() => {
  1455. const openNextEvent = new CustomEvent(
  1456. "cascader-open-" + nextSelName,
  1457. {
  1458. detail: {
  1459. upperVal: item.value,
  1460. },
  1461. }
  1462. );
  1463. window.dispatchEvent(openNextEvent);
  1464. }, 100);
  1465. }
  1466. } // end for
  1467. hidePopup();
  1468. //下个下拉菜单名
  1469. // let nextSelName = getNextSel(props.name, props.param.fieldOrd);
  1470. // if(nextSelName){
  1471. // // //设置下一级下拉菜单中保存的本下拉菜单值(upperValue)
  1472. // // event = new CustomEvent('cascade-setUpperVal-'+nextSelName, {
  1473. // // detail: {
  1474. // // value: item.value
  1475. // // }
  1476. // // });
  1477. // // window.dispatchEvent(event);
  1478. //
  1479. // //触发下一级下拉菜单,重新初始化下拉菜单项并弹出显示
  1480. // event = new CustomEvent('cascader-open-' +nextSelName, {
  1481. // detail: {
  1482. // upperVal: item.value
  1483. // }
  1484. // });
  1485. // window.dispatchEvent(event);
  1486. // }
  1487. // 只在手动选择时自动展开下一级
  1488. // if (!isAutoEcho.value) {
  1489. // const nextLevel = props.level + 1;
  1490. // setTimeout(() => {
  1491. // const openNextEvent = new CustomEvent('open-next-cascader', {
  1492. // detail: {
  1493. // name: props.name,
  1494. // level: nextLevel
  1495. // }
  1496. // });
  1497. // window.dispatchEvent(openNextEvent);
  1498. // }, 100);
  1499. // }
  1500. };
  1501. // 监听下一级展开事件 (仅 mode 2)
  1502. window.addEventListener("cascade-open", (event) => {
  1503. if (props.mode === "2") {
  1504. const { level } = event.detail;
  1505. if (level === props.level) {
  1506. popupWinVisible.value = true;
  1507. }
  1508. }
  1509. });
  1510. if (props.mode === "1") {
  1511. //如果是有隐藏字段的下拉菜单
  1512. // 监听回显事件
  1513. window.addEventListener(
  1514. "cascader-echo-" + props.name,
  1515. async (event) => {
  1516. const { name, value, isAuto, upperVal } = event.detail;
  1517. // level,
  1518. if (upperVal) {
  1519. upperValue.value = upperVal;
  1520. console.log(
  1521. "value:" +
  1522. value +
  1523. ",upperValue:" +
  1524. upperValue +
  1525. ",初始化级联组件时props.name:" +
  1526. props.name
  1527. );
  1528. }
  1529. // if (name === props.name && level === props.level) {
  1530. // 设置自动回显标记
  1531. isAutoEcho.value = true;
  1532. // if (props.opt.length === 0) {
  1533. // const loadDataEvent = new CustomEvent('cascader-load-data', {
  1534. // detail: {
  1535. // name: props.name,
  1536. // level: props.level,
  1537. // value: value
  1538. // }
  1539. // });
  1540. // window.dispatchEvent(loadDataEvent);
  1541. //下面的代码只用于页面刚打开时,初始化级联菜单的回显值。
  1542. //Vue.watch用于监听数据的变化,并在数据变化时执行特定的回调函数。
  1543. //这段代码使用了 Vue.js 的 watch API 来监听 props.opt 的变化,如果props.opt有变化,则自动
  1544. // const unwatch = Vue.watch(
  1545. // () => props.opt, // 监听的数据源(props.opt)
  1546. // (newOptions) => { // 回调函数
  1547. // if (newOptions.length > 0) { // 条件判断
  1548. // matchAndSelect(value); // 执行逻辑
  1549. // unwatch(); // 停止监听
  1550. // }
  1551. // },
  1552. // { immediate: true } // 配置:立即触发一次
  1553. // );
  1554. // } else {
  1555. // matchAndSelect(value);
  1556. // }
  1557. // 初始化级联菜单在页面刚打开时的默认值
  1558. async function initDefaultValue(value) {
  1559. try {
  1560. // alert(1);
  1561. if (props.url && props.param
  1562. // && props.modelValue 对于有rule编码规则的级联菜单(即mode=1),modelValue一定是空的,所以注释掉,修复mode=1的级联菜单无法回显问题。Ben(20251124)
  1563. ) {
  1564. // alert(2);
  1565. /**
  1566. * let objectPickerParam=
  1567. * {"objectpickerparam":"{\"input\":\"false\",\"cascadingLevel\":\"hksheng,hkshi,hkxian\"," +
  1568. * "\"name\":\"hksheng\"," +
  1569. * "\"cascadingName\":\"dq\",\"cascadingInputsName\":\"hkdqm\"," +
  1570. * "\"codebook\":\"sheng\"}",
  1571. * "objectpickertype":2,
  1572. * "objectpickervalue":"440000"
  1573. * };
  1574. */
  1575. const objectPickerParam = {
  1576. input: "false",
  1577. cascadingLevel: props.param.fieldOrd.join(","), //如:"hksheng,hkshi,hkxian"
  1578. name: props.name, //本下拉菜单名
  1579. cascadingName: props.param.name, //级联菜单名
  1580. cascadingInputsName: props.param.combField, //对象属性,即隐藏字段名,如:hkdqm
  1581. codebook: props.param.codebook,
  1582. };
  1583. const objectPickerParamStr =
  1584. JSON.stringify(objectPickerParam);
  1585. const params = new URLSearchParams();
  1586. params.append("objectpickerparam", objectPickerParamStr);
  1587. params.append("objectpickertype", "2");
  1588. params.append("objectpickervalue", value); //需回显的值
  1589. axios
  1590. .post(props.url, params, {
  1591. headers: {
  1592. "Content-Type": "application/x-www-form-urlencoded", // 必须手动设置!
  1593. },
  1594. })
  1595. .then((response) => {
  1596. // alert(JSON.stringify(response.data));
  1597. if ("timeout" == response.data.statusText) {
  1598. alert("网络超时!");
  1599. return;
  1600. }
  1601. if (response.data.result) {
  1602. const keys = Object.keys(response.data.result);
  1603. if (keys.length === 1) {
  1604. let code = keys[0];
  1605. let desc = response.data.result[keys[0]];
  1606. clearAndInit1stOpt();
  1607. props.opt.push({ label: desc, value: code });
  1608. if (value) matchAndSelect(value);
  1609. // updateSelectItem();
  1610. // alert('props.opt:'+JSON.stringify(props.opt));
  1611. }
  1612. }
  1613. });
  1614. }
  1615. } catch (error) {
  1616. alert(error);
  1617. // callback(null, error.message); // 失败回调,传递错误
  1618. }
  1619. }
  1620. //下面的代码只用于页面刚打开时,初始化级联菜单的回显值。
  1621. initDefaultValue(value);
  1622. // 延迟重置自动回显标记
  1623. setTimeout(() => {
  1624. isAutoEcho.value = false;
  1625. }, 500);
  1626. }
  1627. );
  1628. // 被上级下拉菜单触发的,清除选中值和下拉菜单选项
  1629. window.addEventListener(
  1630. "cascader-cleanOpt-" + props.name,
  1631. async (event) => {
  1632. upperValue.value = "";
  1633. selectItem.value = ""; //清除本下拉菜单当前选中的值
  1634. emit("update:modelValue", ""); //通知父级
  1635. //清空所有下拉菜单项
  1636. if (props.opt) {
  1637. props.opt.length = 0;
  1638. } else {
  1639. props.opt = [];
  1640. }
  1641. //下个下拉菜单名
  1642. let nextSelName = getNextSel(props.name, props.param.fieldOrd);
  1643. // alert('nextSelName:'+nextSelName+'--,props.name:'+props.name);
  1644. if (nextSelName) {
  1645. //清下个下拉菜单选中值和选项
  1646. event = new CustomEvent("cascader-cleanOpt-" + nextSelName, {
  1647. detail: {},
  1648. });
  1649. window.dispatchEvent(event);
  1650. }
  1651. }
  1652. );
  1653. } else if (props.mode === "2") {
  1654. //没隐藏字段的下拉菜单,在这初始化默认值
  1655. let needInitParam = undefined;
  1656. if (Array.isArray(props.param)) {
  1657. needInitParam = props.param[props.param.length - 1]; //只初始化数组最后一项
  1658. console.log("needInitParam最后一项:" + JSON.stringify(needInitParam));
  1659. } else {
  1660. needInitParam = props.param;
  1661. }
  1662. // 初始化级联菜单在页面刚打开时的默认值
  1663. async function initDefaultValue(value, param) {
  1664. try {
  1665. // alert(1);
  1666. if (props.url && param && props.modelValue) {
  1667. // alert(2);
  1668. /**
  1669. * let param=
  1670. * {"objectpickerparam":"{\"input\":\"false\",\"cascadingLevel\":\"rylbm,gwid\"," +
  1671. * "\"name\":\"gwid\",\"cascadingName\":\"rylb_gw\"," +
  1672. * "\"codebook\":\"gwByRylb\"}",
  1673. * "objectpickertype":2,
  1674. * "objectpickervalue":"102121"};
  1675. */
  1676. // alert('props.name:'+props.name+',props.param.fieldOrd:'+props.param.fieldOrd);
  1677. const objectPickerParam = {
  1678. input: "false",
  1679. cascadingLevel: param.fieldOrd.join(","), //如:"hksheng,hkshi,hkxian"
  1680. name: props.name, //本下拉菜单名
  1681. cascadingName: param.name, //级联菜单名
  1682. codebook: param.codebook,
  1683. };
  1684. const objectPickerParamStr = JSON.stringify(objectPickerParam);
  1685. const sendParams = new URLSearchParams();
  1686. sendParams.append("objectpickerparam", objectPickerParamStr);
  1687. sendParams.append("objectpickertype", "2");
  1688. sendParams.append("objectpickervalue", value); //需回显的值
  1689. axios
  1690. .post(props.url, sendParams, {
  1691. headers: {
  1692. "Content-Type": "application/x-www-form-urlencoded", // 必须手动设置!
  1693. },
  1694. })
  1695. .then((response) => {
  1696. // alert(JSON.stringify(response.data));
  1697. if ("timeout" == response.data.statusText) {
  1698. alert("网络超时!");
  1699. return;
  1700. }
  1701. if (response.data.result) {
  1702. const keys = Object.keys(response.data.result);
  1703. console.log(
  1704. "name:" +
  1705. props.name +
  1706. ",@@级联初始化默认值value:" +
  1707. value +
  1708. "--param:" +
  1709. JSON.stringify(param) +
  1710. "--objectPickerParamStr:" +
  1711. objectPickerParamStr +
  1712. "--response.data:" +
  1713. JSON.stringify(response.data)
  1714. );
  1715. if (keys.length === 1) {
  1716. let code = keys[0];
  1717. let desc = response.data.result[keys[0]];
  1718. if (props.opt)
  1719. props.opt.length = 0; //通过修改数组的length属性,直接清空数组元素,内存会被自动释放。这是性能最优的方式
  1720. else {
  1721. props.opt = [];
  1722. }
  1723. props.opt.push({ label: desc, value: code });
  1724. if (value) matchAndSelect(value);
  1725. console.log(
  1726. "GOOD mode2回显的默认值:" +
  1727. JSON.stringify({ label: desc, value: code }) +
  1728. "--props.param:" +
  1729. JSON.stringify(param)
  1730. );
  1731. // updateSelectItem();
  1732. // alert('props.opt:'+JSON.stringify(props.opt));
  1733. }
  1734. }
  1735. });
  1736. }
  1737. } catch (error) {
  1738. alert(error);
  1739. // callback(null, error.message); // 失败回调,传递错误
  1740. }
  1741. // 重置自动回显标记
  1742. isAutoEcho.value = false;
  1743. }
  1744. // 初始化级联菜单在页面刚打开时的默认值
  1745. initDefaultValue(props.modelValue, needInitParam);
  1746. //设置mode2的下级下拉菜单的上级菜单当前值
  1747. setNextSelectUpperValue();
  1748. }
  1749. //选中要回显的默认值
  1750. const matchAndSelect = (value) => {
  1751. const matchedOption = props.opt.find((opt) => opt.value === value);
  1752. if (matchedOption) {
  1753. selectItem.value = matchedOption;
  1754. emit("update:modelValue", value);
  1755. emit("change", value);
  1756. }
  1757. };
  1758. // 计算弹出方向和最大高度的方法 by xu 20251212
  1759. // 当空间不足时限制popup高度并显示滚动条
  1760. const calculatePopupDirection = () => {
  1761. // 1. 获取select容器元素
  1762. const selectEl = document.querySelector(
  1763. `[name="${props.name}"]`
  1764. )?.nextElementSibling;
  1765. console.log("selectEl:" + selectEl, props.name);
  1766. if (!selectEl) return;
  1767. // 2. 获取位置信息
  1768. const selectRect = selectEl.getBoundingClientRect();
  1769. const viewportHeight = window.innerHeight;
  1770. // 3. 计算上下可用空间 by xu 20251212
  1771. const spaceBelow = viewportHeight - selectRect.bottom - 10; // 减10px留边距
  1772. const spaceAbove = selectRect.top - 10; // 减10px留边距
  1773. // 4. popup预估高度(假设每项36px,最多显示8项 + padding)
  1774. const estimatedPopupHeight = 300;
  1775. const minPopupHeight = 100; // 最小高度
  1776. console.log('[popup] 空间计算 - spaceAbove:', spaceAbove, 'spaceBelow:', spaceBelow, 'estimatedHeight:', estimatedPopupHeight);
  1777. // 5. 判断方向和最大高度 by xu 20251212
  1778. if (spaceBelow >= estimatedPopupHeight) {
  1779. // 下方空间足够,向下展开,不限制高度
  1780. popupDirection.value = "bottom";
  1781. popupMaxHeight.value = "none";
  1782. console.log('[popup] 向下展开,空间充足');
  1783. } else if (spaceAbove >= estimatedPopupHeight) {
  1784. // 上方空间足够,向上展开,不限制高度
  1785. popupDirection.value = "top";
  1786. popupMaxHeight.value = "none";
  1787. console.log('[popup] 向上展开,空间充足');
  1788. } else {
  1789. // 上下空间都不足,选择空间大的方向,并限制高度出滚动条
  1790. if (spaceBelow >= spaceAbove) {
  1791. popupDirection.value = "bottom";
  1792. popupMaxHeight.value = Math.max(spaceBelow, minPopupHeight) + "px";
  1793. console.log('[popup] 向下展开,空间不足,限制高度:', popupMaxHeight.value);
  1794. } else {
  1795. popupDirection.value = "top";
  1796. popupMaxHeight.value = Math.max(spaceAbove, minPopupHeight) + "px";
  1797. console.log('[popup] 向上展开,空间不足,限制高度:', popupMaxHeight.value);
  1798. }
  1799. }
  1800. };
  1801. //级联菜单点击事件
  1802. const togglePopup = () => {
  1803. if (!popupWinVisible.value) {
  1804. //如果当前下拉菜单是隐藏的,先ajax重新加载下拉菜单项,再显示。
  1805. showPopup();
  1806. } else {
  1807. hidePopup();
  1808. }
  1809. };
  1810. //显示下拉菜单,在此之前先清除下拉菜单项
  1811. const showPopup = () => {
  1812. //清空下拉菜单,并设置第一项的值为空
  1813. clearAndInit1stOpt();
  1814. Vue.nextTick(() => {
  1815. calculatePopupDirection();
  1816. });
  1817. let url = props.url;
  1818. let filterObj = props.param.filter;
  1819. if (filterObj) {
  1820. for (let k in filterObj) {
  1821. let v = filterObj[k];
  1822. url += "&" + k + "=" + v;
  1823. }
  1824. }
  1825. if (props.mode === "1") {
  1826. //如果是有隐藏字段的下拉菜单
  1827. console.log("666url:" + url);
  1828. // alert('url:'+url);
  1829. // 获取级联菜单所有下拉菜单项
  1830. async function getSelectItems(value) {
  1831. try {
  1832. // alert(1);
  1833. if (props.url && props.param) {
  1834. // alert(2);
  1835. /**
  1836. * param={"objectpickerparam":"{\"input\":\"false\",\"cascadingLevel\":\"hksheng,hkshi,hkxian\"," +
  1837. * "\"name\":\"hksheng\",\"cascadingName\":\"dq\"," +
  1838. * "\"cascadingInputsName\":\"hkdqm\",\"codebook\":\"sheng\"}",
  1839. * "objectpickertype":1,//2表示获取要回显的一项,1表示获取所有下拉菜单项
  1840. * "upperValue":"440000"
  1841. * };
  1842. */
  1843. const objectPickerParam = {
  1844. input: "false",
  1845. cascadingLevel: props.param.fieldOrd.join(","), //如:"hksheng,hkshi,hkxian"
  1846. name: props.name, //本下拉菜单名
  1847. cascadingName: props.param.name, //级联菜单名
  1848. cascadingInputsName: props.param.combField, //对象属性,即隐藏字段名,如:hkdqm
  1849. codebook: props.param.codebook,
  1850. };
  1851. console.log("mode1 upperValue.value:" + upperValue.value);
  1852. const objectPickerParamStr = JSON.stringify(objectPickerParam);
  1853. const params = new URLSearchParams();
  1854. params.append("objectpickerparam", objectPickerParamStr);
  1855. params.append("objectpickertype", "1");
  1856. if (upperValue.value) {
  1857. params.append("upperValue", upperValue.value);
  1858. }
  1859. // params.append('objectpickervalue', value); //需回显的值
  1860. axios
  1861. .post(url, params, {
  1862. headers: {
  1863. "Content-Type": "application/x-www-form-urlencoded", // 必须手动设置!
  1864. },
  1865. })
  1866. .then((response) => {
  1867. if ("timeout" == response.data.statusText) {
  1868. alert("网络超时!");
  1869. return;
  1870. }
  1871. if (response.data.result) {
  1872. const keys = Object.keys(response.data.result);
  1873. console.log(
  1874. "params:" +
  1875. params +
  1876. "@@response.data:" +
  1877. JSON.stringify(response.data)
  1878. );
  1879. if (keys.length > 0) {
  1880. for (let k in response.data.result) {
  1881. props.opt.push({
  1882. label: response.data.result[k],
  1883. value: k,
  1884. });
  1885. }
  1886. console.log("props.opt11:" + JSON.stringify(props.opt));
  1887. } else {
  1888. // 没有数据时打印日志 by xu 20251212
  1889. console.log("[ccp mode1] 接口返回空数据");
  1890. }
  1891. } else {
  1892. // result不存在时打印日志 by xu 20251212
  1893. console.log("[ccp mode1] 接口返回无result");
  1894. }
  1895. // 无论是否有数据,都显示popup by xu 20251212
  1896. if (!popupWinVisible.value) {
  1897. popupWinVisible.value = true;
  1898. }
  1899. });
  1900. }
  1901. } catch (error) {
  1902. alert(error);
  1903. // callback(null, error.message); // 失败回调,传递错误
  1904. }
  1905. }
  1906. getSelectItems(props.modelValue);
  1907. } else if (props.mode === "2") {
  1908. //没隐藏字段的下拉菜单
  1909. let needInitParam = undefined;
  1910. if (Array.isArray(props.param)) {
  1911. needInitParam = props.param[props.param.length - 1]; //只初始化数组最后一项
  1912. console.log(
  1913. "needInitParam最后一项:" + JSON.stringify(needInitParam)
  1914. );
  1915. } else {
  1916. needInitParam = props.param;
  1917. }
  1918. // 获取级联菜单所有下拉菜单项
  1919. async function getSelectItems(value, sendParam) {
  1920. try {
  1921. // alert(1);
  1922. if (props.url && sendParam) {
  1923. // alert(2);
  1924. /**
  1925. * param="{\"input\":\"false\",\"cascadingLevel\":\"dwid,sjryid\",
  1926. * \"ryid\":\"111121\",\"name\":\"sjryid\",
  1927. * \"cascadingName\":\"dw_sjry\",\"codebook\":\"sjryByDw\"}"
  1928. */
  1929. const objectPickerParam = {
  1930. input: "false",
  1931. cascadingLevel: sendParam.fieldOrd.join(","), //如:"hksheng,hkshi,hkxian"
  1932. name: props.name, //本下拉菜单名
  1933. cascadingName: sendParam.name, //级联菜单名
  1934. codebook: sendParam.codebook,
  1935. };
  1936. console.log("mode2 upperValue.value:" + upperValue.value);
  1937. const objectPickerParamStr = JSON.stringify(objectPickerParam);
  1938. const params = new URLSearchParams();
  1939. params.append("objectpickerparam", objectPickerParamStr);
  1940. params.append("objectpickertype", "1");
  1941. if (upperValue.value) {
  1942. params.append("upperValue", upperValue.value);
  1943. }
  1944. // params.append('objectpickervalue', value); //需回显的值
  1945. axios
  1946. .post(url, params, {
  1947. headers: {
  1948. "Content-Type": "application/x-www-form-urlencoded", // 必须手动设置!
  1949. },
  1950. })
  1951. .then((response) => {
  1952. if ("timeout" == response.data.statusText) {
  1953. alert("网络超时!");
  1954. return;
  1955. }
  1956. if (response.data.result) {
  1957. const keys = Object.keys(response.data.result);
  1958. console.log(
  1959. "params:" +
  1960. params +
  1961. "@@response.data:" +
  1962. JSON.stringify(response.data)
  1963. );
  1964. if (keys.length > 0) {
  1965. for (let k in response.data.result) {
  1966. props.opt.push({
  1967. label: response.data.result[k],
  1968. value: k,
  1969. });
  1970. }
  1971. console.log("props.opt11:" + JSON.stringify(props.opt));
  1972. } else {
  1973. // 没有数据时打印日志 by xu 20251212
  1974. console.log("[ccp mode2] 接口返回空数据");
  1975. }
  1976. } else {
  1977. // result不存在时打印日志 by xu 20251212
  1978. console.log("[ccp mode2] 接口返回无result");
  1979. }
  1980. // 无论是否有数据,都显示popup by xu 20251212
  1981. if (!popupWinVisible.value) {
  1982. popupWinVisible.value = true;
  1983. }
  1984. });
  1985. }
  1986. } catch (error) {
  1987. alert(error);
  1988. // callback(null, error.message); // 失败回调,传递错误
  1989. }
  1990. }
  1991. getSelectItems(props.modelValue, needInitParam);
  1992. // popupWinVisible.value = !popupWinVisible.value;
  1993. }
  1994. };
  1995. const hidePopup = () => {
  1996. popupWinVisible.value = false;
  1997. };
  1998. // 合并所有的 onMounted 逻辑
  1999. Vue.onMounted(() => {
  2000. window.addEventListener("resize", calculatePopupDirection);
  2001. // 1. 监听展开下一级事件
  2002. window.addEventListener("open-next-cascader", (event) => {
  2003. const { name, level } = event.detail;
  2004. if (name === props.name && level === props.level) {
  2005. popupWinVisible.value = true;
  2006. }
  2007. });
  2008. // 2. 监听级联事件
  2009. window.addEventListener("cascader-change", (event) => {
  2010. const { name, level, value } = event.detail;
  2011. if (name === props.name && level < props.level) {
  2012. selectItem.value = { label: "", value: "" };
  2013. emit("update:modelValue", "");
  2014. if (ssHidden) {
  2015. ssHidden.updateValue(value);
  2016. }
  2017. }
  2018. });
  2019. });
  2020. Vue.onUnmounted(() => {
  2021. window.removeEventListener("resize", calculatePopupDirection);
  2022. });
  2023. // 监听值变化,处理回显 (mode 2)
  2024. Vue.watch(
  2025. () => props.modelValue,
  2026. (newVal) => {
  2027. if (props.mode === "2" && newVal) {
  2028. // 使用 watchEffect 替代嵌套的 watch
  2029. Vue.watchEffect(() => {
  2030. if (props.opt.length > 0) {
  2031. const matchedOption = props.opt.find(
  2032. (opt) => opt.value === newVal
  2033. );
  2034. if (matchedOption) {
  2035. selectItem.value = matchedOption;
  2036. }
  2037. }
  2038. });
  2039. } else {
  2040. // 原有的值变化处理
  2041. const item = props.opt.find((it) => it.value === newVal);
  2042. if (item) {
  2043. selectItem.value = item;
  2044. } else {
  2045. selectItem.value = { label: "", value: "" };
  2046. }
  2047. }
  2048. },
  2049. { immediate: true }
  2050. );
  2051. // 监听选项变化,当数据加载完成时进行匹配
  2052. Vue.watch(
  2053. () => props.opt,
  2054. (newOptions) => {
  2055. if (newOptions.length > 0) {
  2056. const matchedOption = newOptions.find(
  2057. (opt) => opt.value === selectItem.value.value
  2058. );
  2059. if (matchedOption) {
  2060. selectItem.value = matchedOption;
  2061. emit("update:modelValue", matchedOption.value);
  2062. emit("change", matchedOption.value);
  2063. }
  2064. }
  2065. }
  2066. );
  2067. return {
  2068. selectItem,
  2069. popupWinVisible,
  2070. popupDirection,
  2071. popupMaxHeight, // 添加popup最大高度 by xu 20251212
  2072. togglePopup,
  2073. hidePopup,
  2074. doSelectItem,
  2075. };
  2076. },
  2077. template: `
  2078. <div class="input ss-ccp-container" style="position: relative" :style="{width: width}">
  2079. <input type="hidden" :name="name" :value="modelValue">
  2080. <div class="select-container" @mouseleave="hidePopup">
  2081. <div class="input" @click="togglePopup">
  2082. <input
  2083. type="hidden"
  2084. :name="name"
  2085. :value="selectItem.value"
  2086. />
  2087. <input
  2088. :placeholder="placeholder"
  2089. :value="selectItem.label"
  2090. disabled
  2091. style="pointer-events: none;"
  2092. />
  2093. <div class="suffix">
  2094. <ss-form-icon :class="popupWinVisible ? 'form-icon-transform-select select' : 'form-icon-select'" />
  2095. </div>
  2096. </div>
  2097. <!-- popup弹出层,添加maxHeight和overflowY支持空间不足时滚动 by xu 20251212 -->
  2098. <div v-show="popupWinVisible" class="popup-win " :class="popupDirection" :style="{ maxHeight: popupMaxHeight, overflowY: popupMaxHeight !== 'none' ? 'auto' : 'visible' }">
  2099. <div v-if="opt && opt.length > 0" class="popup-content">
  2100. <div class="content-area">
  2101. <div
  2102. v-for="(item, index) in opt"
  2103. :key="index"
  2104. @click="doSelectItem(item)"
  2105. :class="{ active: item.value === selectItem.value }"
  2106. >
  2107. <span class="check-icon">
  2108. <ss-form-icon class="form-icon-select-checked" />
  2109. </span>
  2110. <span>{{ item.label }}</span>
  2111. </div>
  2112. </div>
  2113. </div>
  2114. <div v-else class="popup-content">
  2115. <div class="content-area">
  2116. <div class="content-area">
  2117. <span>无选项</span>
  2118. </div>
  2119. </div>
  2120. </div>
  2121. </div>
  2122. </div>
  2123. </div>
  2124. `,
  2125. };
  2126. // ss-date-picker 日期时间选择器组件
  2127. const SsDatePicker = {
  2128. name: "SsDatePicker",
  2129. props: {
  2130. modelValue: {
  2131. type: [String, Number, Date],
  2132. default: "",
  2133. },
  2134. name: {
  2135. type: String,
  2136. required: true,
  2137. },
  2138. type: {
  2139. type: String,
  2140. default: "date",
  2141. validator: (value) => ["date", "datetime", "time"].includes(value),
  2142. },
  2143. fmt: {
  2144. type: String,
  2145. default: null,
  2146. },
  2147. placeholder: {
  2148. type: String,
  2149. default: "",
  2150. },
  2151. width: {
  2152. type: String,
  2153. default: "100%",
  2154. },
  2155. },
  2156. emits: ["update:modelValue"],
  2157. setup(props, { emit }) {
  2158. const errMsg = ref("");
  2159. const validate = () => {
  2160. if (window.ssVm) {
  2161. const result = window.ssVm.validateField(props.name);
  2162. console.log("validate", window.ssVm.validateField(props.name));
  2163. errMsg.value = result.valid ? "" : result.message;
  2164. }
  2165. };
  2166. // 根据type确定默认格式
  2167. const defaultFormat = computed(() => {
  2168. switch (props.type) {
  2169. case "datetime":
  2170. return "YYYY-MM-DD HH:mm:ss";
  2171. case "date":
  2172. return "YYYY-MM-DD";
  2173. case "time":
  2174. return "HH:mm:ss";
  2175. }
  2176. });
  2177. const convertJavaFormatToElement = (javaFormat) => {
  2178. if (!javaFormat) return null;
  2179. return javaFormat
  2180. .replace("yyyy", "YYYY")
  2181. .replace("MM", "MM")
  2182. .replace("dd", "DD")
  2183. .replace("HH", "HH")
  2184. .replace("mm", "mm")
  2185. .replace("ss", "ss");
  2186. };
  2187. const finalFormat = computed(() => {
  2188. if (props.fmt) {
  2189. return convertJavaFormatToElement(props.fmt);
  2190. }
  2191. return defaultFormat.value;
  2192. });
  2193. // 使用 resolveComponent 获取组件
  2194. const ElDatePicker = resolveComponent("ElDatePicker");
  2195. const ElTimePicker = resolveComponent("ElTimePicker");
  2196. const SsFormIcon = resolveComponent("SsFormIcon");
  2197. const ElIcon = resolveComponent("ElIcon");
  2198. const handleValueUpdate = (val) => {
  2199. emit("update:modelValue", val);
  2200. emit("change", val); // 同时触发 change 事件
  2201. setTimeout(() => {
  2202. validate();
  2203. }, 50);
  2204. };
  2205. const dateType = computed(() => {
  2206. const fmt = props.fmt || "";
  2207. if (fmt.includes("HH:mm:ss")) {
  2208. return "datetime";
  2209. } else if (fmt.includes("HH:mm")) {
  2210. return "datetime";
  2211. } else if (fmt.includes("mm:ss")) {
  2212. return "time";
  2213. }
  2214. return "date";
  2215. });
  2216. let useTimePicker = true;
  2217. //"yyyy-MM-dd HH:mm:ss"; "日期字符串格式在java的写法",传到本组件fmt属性也是按这个格式
  2218. if (props.fmt) {
  2219. //有fmt属性,则以fmt属性优先判断类型
  2220. if (/[dMy]/.test(props.fmt)) {
  2221. //如果有传入日期格式,且含年月日
  2222. useTimePicker = false;
  2223. } else {
  2224. useTimePicker = true;
  2225. }
  2226. } else if (props.type !== "time") {
  2227. useTimePicker = false;
  2228. }
  2229. return () =>
  2230. h("div", { class: "ss-date-picker", style: { width: props.width } }, [
  2231. h("input", {
  2232. type: "hidden",
  2233. name: props.name,
  2234. value: props.modelValue,
  2235. }),
  2236. // 选择组件
  2237. h(useTimePicker ? ElTimePicker : ElDatePicker, {
  2238. modelValue: props.modelValue,
  2239. "onUpdate:modelValue": handleValueUpdate,
  2240. type: dateType.value,
  2241. format: finalFormat.value,
  2242. "value-format": finalFormat.value,
  2243. clearable: true,
  2244. placeholder: props.placeholder,
  2245. class: "custom-date-picker", // 用于自定义样式
  2246. "time-arrow-control": props.type === "datetime", // 修改这里
  2247. size: "large", // 添加这一行,改为 large 尺寸
  2248. style: { width: "100%" },
  2249. "prefix-icon": h(SsFormIcon, { class: "form-icon-time" }),
  2250. }),
  2251. ]);
  2252. },
  2253. };
  2254. // ss-icon 图标
  2255. // v3.0 增加 class 属性分支:有 class 走新逻辑,否则走 v1.0 逻辑 by xu 20251212
  2256. // v3.0 用法: <ss-icon class="icon-obj-ry menu-icon" />
  2257. // v1.0 用法: <ss-icon name="setting" size="20px" />
  2258. const SsIcon = {
  2259. name: "SsIcon",
  2260. // v3.0 禁用 class 透传,手动处理 by xu 20251215
  2261. inheritAttrs: false,
  2262. props: {
  2263. // v1.0: 以下为旧属性
  2264. name: { type: String },
  2265. size: { type: [Number, String], default: 16 },
  2266. unit: { type: String, default: "px" },
  2267. color: String,
  2268. type: {
  2269. type: String,
  2270. default: ssIcon.name,
  2271. validator: function (value) {
  2272. return [ssIcon, commonIcon].some((icon) => icon.name === value);
  2273. },
  2274. },
  2275. },
  2276. emits: ["update:modelValue", "input", "blur", "change"],
  2277. setup(props, { emit, attrs }) {
  2278. // v3.0 分支:有 class 属性时直接渲染(从 attrs 获取) by xu 20251215
  2279. if (attrs.class) {
  2280. return () => h("i", { ...attrs, class: attrs.class + ' icon-container' });
  2281. }
  2282. // v1.0 分支:原有逻辑
  2283. const useIconType = computed(() => {
  2284. return [ssIcon, commonIcon].find(
  2285. (iconConfig) => iconConfig.name === props.type
  2286. );
  2287. });
  2288. const iconName = computed(() => {
  2289. const iconConfig = useIconType.value; // 注意:使用 .value 来访问响应式引用的值
  2290. if (!iconConfig) {
  2291. console.error(`Icon type "${props.type}" not found.`);
  2292. return "";
  2293. }
  2294. const iconType = iconConfig.types[props.name];
  2295. if (!iconType) {
  2296. console.error(
  2297. `Icon name "${props.name}" not found in type "${props.type}".`
  2298. );
  2299. return "";
  2300. }
  2301. return `${iconConfig.prefix}${iconType}`;
  2302. });
  2303. // 类似地,你可以计算 fontFamily 和 style
  2304. const fontFamily = computed(() => {
  2305. return useIconType.value ? useIconType.value.family : "";
  2306. });
  2307. // console.log(iconName.value,fontFamily.value)
  2308. const style = computed(() => {
  2309. const sizeStyle = isNum(props.size)
  2310. ? `${props.size}${props.unit}`
  2311. : props.size;
  2312. const styleObj = {
  2313. fontSize: sizeStyle,
  2314. color: props.color || "",
  2315. };
  2316. return toStyleStr(styleObj);
  2317. });
  2318. // 使用渲染函数定义模板逻辑
  2319. return () =>
  2320. h("i", {
  2321. class: ["icon-container", iconName.value, fontFamily.value],
  2322. style: style.value,
  2323. });
  2324. },
  2325. };
  2326. // 通用icon
  2327. const SsCommonIcon = {
  2328. name: "SsCommonIcon",
  2329. props: {
  2330. class: {
  2331. type: String,
  2332. required: true,
  2333. },
  2334. },
  2335. setup(props) {
  2336. return () =>
  2337. h("i", {
  2338. class: props.class + " common-icon",
  2339. });
  2340. },
  2341. };
  2342. // 登录页icon
  2343. const SsLoginIcon = {
  2344. name: "SsLoginIcon",
  2345. props: {
  2346. class: {
  2347. type: String,
  2348. required: true,
  2349. },
  2350. },
  2351. setup(props) {
  2352. return () =>
  2353. h("div", {
  2354. class: props.class + " login-icon",
  2355. });
  2356. },
  2357. };
  2358. // 弹窗icon
  2359. const SsDialogIcon = {
  2360. name: "SsDialogIcon",
  2361. props: {
  2362. class: {
  2363. type: String,
  2364. required: true,
  2365. },
  2366. },
  2367. setup(props) {
  2368. return () =>
  2369. h("i", {
  2370. class: props.class + " dialog-icon",
  2371. });
  2372. },
  2373. };
  2374. // 全局左侧导航图标组件
  2375. const SsNavIcon = {
  2376. name: "SsNavIcon",
  2377. props: {
  2378. class: {
  2379. type: String,
  2380. required: true,
  2381. },
  2382. },
  2383. setup(props) {
  2384. return () =>
  2385. h("div", {
  2386. class: props.class + " nav-icon",
  2387. });
  2388. },
  2389. };
  2390. // 顶部工具栏图标组件
  2391. const SsHeaderIcon = {
  2392. name: "SsHeaderIcon",
  2393. props: {
  2394. class: {
  2395. type: String,
  2396. required: true,
  2397. },
  2398. },
  2399. setup(props) {
  2400. return () =>
  2401. h("div", {
  2402. class: props.class + " header-icon",
  2403. });
  2404. },
  2405. };
  2406. // 全局菜单图标组件
  2407. const SsGolbalMenuIcon = {
  2408. name: "SsGolbalMenuIcon",
  2409. props: {
  2410. class: {
  2411. type: String,
  2412. required: true,
  2413. },
  2414. },
  2415. setup(props) {
  2416. return () =>
  2417. h("div", {
  2418. class: props.class + " global-menu-icon",
  2419. });
  2420. },
  2421. };
  2422. // 全局查询列表卡片图标
  2423. const SsCartListIcon = {
  2424. name: "SsCartListIcon",
  2425. props: {
  2426. class: {
  2427. type: String,
  2428. required: true,
  2429. },
  2430. },
  2431. setup(props) {
  2432. return () =>
  2433. h("div", {
  2434. class: props.class + " cart-list-icon",
  2435. });
  2436. },
  2437. };
  2438. // 全局底部工具栏图标组件
  2439. const SsQuickIcon = {
  2440. name: "SsQuickIcon",
  2441. props: {
  2442. class: {
  2443. type: String,
  2444. required: true,
  2445. },
  2446. },
  2447. setup(props) {
  2448. return () =>
  2449. h("div", {
  2450. class: props.class + " quick-icon",
  2451. });
  2452. },
  2453. };
  2454. // 表单组件icon
  2455. const SsFormIcon = {
  2456. name: "SsFormIcon",
  2457. props: {
  2458. class: {
  2459. type: String,
  2460. required: true,
  2461. },
  2462. },
  2463. setup(props) {
  2464. return () =>
  2465. h("div", {
  2466. class: props.class + " form-icon",
  2467. });
  2468. },
  2469. };
  2470. // 弹窗底部按钮icon
  2471. const SsBottomDivIcon = {
  2472. name: "SsBottomDivIcon",
  2473. props: {
  2474. class: {
  2475. type: String,
  2476. required: true,
  2477. },
  2478. },
  2479. setup(props) {
  2480. return () =>
  2481. h("div", {
  2482. class: props.class + " bottom-div-icon",
  2483. });
  2484. },
  2485. };
  2486. // editor组件icon
  2487. const SsEditorIcon = {
  2488. name: "SsEditorIcon",
  2489. props: {
  2490. class: {
  2491. type: String,
  2492. required: true,
  2493. },
  2494. },
  2495. setup(props) {
  2496. return () =>
  2497. h("i", {
  2498. class: props.class + " editor-icon",
  2499. });
  2500. },
  2501. };
  2502. // ss-validate校验器
  2503. const SsValidate = {
  2504. name: "SsValidate",
  2505. props: {
  2506. errMsg: { type: String },
  2507. textAlign: { type: String, default: "left" },
  2508. style: { type: Object, default: () => ({}) },
  2509. },
  2510. template: `<div class="validate-vline"></div>
  2511. <div class="validate-tip" :style="style">
  2512. <div class="tip" :style="{ textAlign: textAlign }">{{ errMsg }}</div>
  2513. <div class="tip-more" :style="{ textAlign: textAlign }">{{ errMsg }}</div>
  2514. </div>`,
  2515. };
  2516. // ss-onoff-array 多选按钮 数组形式
  2517. const SsonoffArray = {
  2518. name: "SsonoffArray",
  2519. props: {
  2520. name: {
  2521. type: String,
  2522. required: true,
  2523. },
  2524. opt: {
  2525. type: Array,
  2526. default: () => [],
  2527. },
  2528. defaultValue: [String, Number, Array],
  2529. modelValue: [String, Number, Array],
  2530. multiple: {
  2531. // 新增多选模式属性
  2532. type: Boolean,
  2533. default: false,
  2534. },
  2535. // 是否允许一项都不选,默认true允许 by xu 20251212
  2536. null: {
  2537. type: Boolean,
  2538. default: true,
  2539. },
  2540. },
  2541. emits: ["update:modelValue"], // 允许更新 v-model 绑定的值
  2542. setup(props, { emit }) {
  2543. console.log("多选按钮", props.opt);
  2544. // 使用数组来存储选中值
  2545. const checkedValue = ref(
  2546. props.multiple
  2547. ? Array.isArray(props.defaultValue)
  2548. ? props.defaultValue
  2549. : []
  2550. : props.defaultValue
  2551. );
  2552. const errMsg = ref(props.errTip);
  2553. // 生成icon名字
  2554. const genIconName = (itemValue) => {
  2555. if (props.multiple) {
  2556. return checkedValue.value.includes(itemValue)
  2557. ? "form-icon-onoff-checked"
  2558. : "form-icon-onoff-unchecked";
  2559. }
  2560. return checkedValue.value === itemValue
  2561. ? "form-icon-onoff-checked"
  2562. : "form-icon-onoff-unchecked";
  2563. };
  2564. // 选中项
  2565. const selectItem = (value) => {
  2566. if (props.multiple) {
  2567. // 多选模式
  2568. const index = checkedValue.value.indexOf(value);
  2569. if (index === -1) {
  2570. checkedValue.value = [...checkedValue.value, value];
  2571. } else {
  2572. // 取消选中当前项
  2573. const newValue = checkedValue.value.filter((v) => v !== value);
  2574. // 如果不允许为空且取消后为空,则阻止取消操作 by xu 20251212
  2575. if (!props.null && newValue.length === 0) {
  2576. return; // 阻止取消最后一项
  2577. }
  2578. checkedValue.value = newValue;
  2579. }
  2580. } else {
  2581. // 单选模式
  2582. // 如果点击的是当前已选中的项,判断是否允许取消 by xu 20251212
  2583. if (checkedValue.value === value) {
  2584. if (!props.null) {
  2585. return; // 不允许为空时,阻止取消
  2586. }
  2587. checkedValue.value = ""; // 允许为空时,取消选中
  2588. } else {
  2589. checkedValue.value = value;
  2590. }
  2591. }
  2592. emit("update:modelValue", checkedValue.value);
  2593. nextTick(() => {
  2594. // 触发验证
  2595. if (window.ssVm) {
  2596. window.ssVm.validateField(props.name);
  2597. }
  2598. });
  2599. };
  2600. return { checkedValue, genIconName, selectItem };
  2601. },
  2602. // 使用渲染函数定义模板逻辑
  2603. render() {
  2604. const SsFormIcon = resolveComponent("ss-form-icon");
  2605. return h("div", { class: "radio-container" }, [
  2606. // 根据情况创建 input
  2607. this.multiple
  2608. ? this.checkedValue.length
  2609. ? // 多选且有选中值:为选中项创建 input
  2610. this.checkedValue.map((value) =>
  2611. h("input", {
  2612. type: "checkbox",
  2613. name: this.name,
  2614. value: value,
  2615. checked: true,
  2616. style: { display: "none" },
  2617. })
  2618. )
  2619. : // 多选但没有选中值:创建一个空值 input
  2620. h("input", {
  2621. type: "hidden",
  2622. name: this.name,
  2623. value: "",
  2624. })
  2625. : // 单选模式:创建一个 input
  2626. h("input", {
  2627. type: "hidden",
  2628. name: this.name,
  2629. value: this.checkedValue || "",
  2630. }),
  2631. this.opt.map((item, i) =>
  2632. h(
  2633. "div",
  2634. {
  2635. key: i,
  2636. class: {
  2637. checked: this.multiple
  2638. ? this.checkedValue.includes(item.value)
  2639. : this.checkedValue === item.value,
  2640. },
  2641. style: { width: item.width },
  2642. onClick: () => this.selectItem(item.value),
  2643. },
  2644. [
  2645. h("span", null, item.label),
  2646. h("div", { class: "mark" }, [
  2647. h(SsFormIcon, {
  2648. class: this.genIconName(item.value),
  2649. }),
  2650. ]),
  2651. ]
  2652. )
  2653. ),
  2654. ]);
  2655. },
  2656. };
  2657. // ss-onoff 一个按钮
  2658. const Ssonoff = {
  2659. name: "Ssonoff",
  2660. props: {
  2661. name: {
  2662. type: String,
  2663. required: true,
  2664. },
  2665. label: {
  2666. type: String,
  2667. required: true,
  2668. },
  2669. value: {
  2670. type: [String, Number],
  2671. required: true,
  2672. },
  2673. width: {
  2674. type: String,
  2675. default: "",
  2676. },
  2677. modelValue: [String, Number, Array],
  2678. multiple: {
  2679. type: Boolean,
  2680. default: false,
  2681. },
  2682. null: {
  2683. type: Boolean,
  2684. default: true,
  2685. },
  2686. },
  2687. emits: ["update:modelValue"],
  2688. setup(props, { emit }) {
  2689. const parseModelValue = (val) => {
  2690. if (!val) return [];
  2691. // 如果以逗号开头,去掉开头的逗号
  2692. const cleanValue = val.toString().replace(/^,+/, "");
  2693. if (cleanValue.includes("|")) {
  2694. return cleanValue.split("|");
  2695. }
  2696. if (cleanValue.includes(",")) {
  2697. return cleanValue.split(",");
  2698. }
  2699. return [cleanValue];
  2700. };
  2701. // 判断当前按钮是否选中
  2702. const isChecked = computed(() => {
  2703. if (props.multiple) {
  2704. const currentValue = parseModelValue(props.modelValue);
  2705. return currentValue.includes(props.value.toString());
  2706. // return Array.isArray(props.modelValue) && props.modelValue.includes(props.value);
  2707. }
  2708. return (props.modelValue+'') === (props.value+'');//强转为字符串类型再比较(改之前是数字类型和字符串类型作比较,永远为false) Ben 20251206
  2709. });
  2710. // 切换选中状态
  2711. const toggleSelect = () => {
  2712. if (props.multiple) {
  2713. const currentValue = parseModelValue(props.modelValue);
  2714. const index = currentValue.indexOf(props.value.toString());
  2715. let newValue;
  2716. if (index === -1) {
  2717. // 选中当前项
  2718. newValue = [...currentValue, props.value];
  2719. } else {
  2720. // 取消选中当前项
  2721. const filteredValue = currentValue.filter((v) => v !== props.value.toString());
  2722. // 如果不允许为空且取消后为空,则阻止取消操作
  2723. if (!props.null && filteredValue.length === 0) {
  2724. return; // 阻止取消最后一项
  2725. }
  2726. newValue = filteredValue;
  2727. }
  2728. emit("update:modelValue", newValue.join(","));
  2729. } else {
  2730. // 单选模式
  2731. const currentValue = parseModelValue(props.modelValue);
  2732. const isCurrentlySelected = currentValue.includes(props.value.toString());
  2733. if (!isCurrentlySelected) {
  2734. // 选中当前项
  2735. emit("update:modelValue", props.value);
  2736. } else {
  2737. // 取消选中当前项
  2738. // 如果不允许为空且当前只有这一项被选中,则阻止取消操作
  2739. if (!props.null && currentValue.length === 1) {
  2740. return; // 阻止取消唯一选中项
  2741. }
  2742. emit("update:modelValue", "");
  2743. }
  2744. }
  2745. nextTick(() => {
  2746. // 触发验证
  2747. if (window.ssVm) {
  2748. window.ssVm.validateField(props.name);
  2749. }
  2750. });
  2751. };
  2752. return { isChecked, toggleSelect };
  2753. },
  2754. render() {
  2755. const SsFormIcon = resolveComponent("ss-form-icon");
  2756. return h("div", { class: "radio-container2" }, [
  2757. // 隐藏的表单元素
  2758. this.multiple
  2759. ? h("input", {
  2760. type: "hidden",
  2761. name: `${this.name}`, // 多选模式下使用数组形式的 name
  2762. value: this.isChecked ? this.value : "",
  2763. })
  2764. : this.isChecked &&
  2765. h("input", {
  2766. // 只有当前按钮被选中时才创建 input
  2767. type: "hidden",
  2768. name: this.name,
  2769. value: this.value,
  2770. }),
  2771. // 按钮显示
  2772. h(
  2773. "div",
  2774. {
  2775. class: { checked: this.isChecked },
  2776. style: { width: this.width },
  2777. onClick: this.toggleSelect,
  2778. },
  2779. [
  2780. h("span", null, this.label),
  2781. h("div", { class: "mark" }, [
  2782. h(SsFormIcon, {
  2783. class: this.isChecked
  2784. ? "form-icon-onoff-checked"
  2785. : "form-icon-onoff-unchecked",
  2786. }),
  2787. ]),
  2788. ]
  2789. ),
  2790. ]);
  2791. },
  2792. };
  2793. // ss-textarea
  2794. const SsTextarea = {
  2795. name: "SsTextarea",
  2796. props: {
  2797. name: {
  2798. type: String,
  2799. required: true,
  2800. },
  2801. placeholder: {
  2802. type: String,
  2803. default: "请输入",
  2804. },
  2805. defaultValue: [String, Number],
  2806. modelValue: [String, Number],
  2807. },
  2808. emits: ["update:modelValue"],
  2809. setup(props, { emit }) {
  2810. const inputValue = ref(props.modelValue || props.defaultValue || "");
  2811. // 监听 modelValue 变化
  2812. watch(
  2813. () => props.modelValue,
  2814. (newVal) => {
  2815. inputValue.value = newVal;
  2816. }
  2817. );
  2818. // 输入事件处理
  2819. const onInput = (event) => {
  2820. const newValue = event.target.value;
  2821. inputValue.value = newValue;
  2822. emit("update:modelValue", newValue);
  2823. // 触发验证
  2824. if (window.ssVm) {
  2825. window.ssVm.validateField(props.name);
  2826. }
  2827. };
  2828. // 失焦时验证
  2829. const onBlur = () => {
  2830. if (window.ssVm) {
  2831. window.ssVm.validateField(props.name);
  2832. }
  2833. };
  2834. return { inputValue, onInput, onBlur };
  2835. },
  2836. render() {
  2837. return h("div", { class: "textarea-container" }, [
  2838. h("div", { class: "textarea" }, [
  2839. // 添加隐藏的 input 用于验证
  2840. h("input", {
  2841. type: "hidden",
  2842. name: this.name,
  2843. value: this.inputValue || "",
  2844. }),
  2845. h("textarea", {
  2846. placeholder: this.placeholder,
  2847. value: this.inputValue,
  2848. onInput: this.onInput,
  2849. onBlur: this.onBlur,
  2850. }),
  2851. ]),
  2852. ]);
  2853. },
  2854. };
  2855. // ss-editor 富文本编辑器 基于Jodit
  2856. const SsEditor = {
  2857. name: "SsEditor",
  2858. props: {
  2859. modelValue: {
  2860. type: String,
  2861. default: "",
  2862. },
  2863. name: {
  2864. type: String,
  2865. default: "",
  2866. },
  2867. url: {
  2868. type: String,
  2869. default: "",
  2870. },
  2871. height: {
  2872. type: [Number, String],
  2873. default: 400,
  2874. },
  2875. placeholder: {
  2876. type: String,
  2877. default: "请输入内容",
  2878. },
  2879. readonly: {
  2880. type: Boolean,
  2881. default: false,
  2882. },
  2883. uploadUrl: {
  2884. type: String,
  2885. default: "/ulByHttp",//原值为“upload” Ben(20251205)
  2886. },
  2887. param: {
  2888. type: Object,
  2889. default: () => ({}),
  2890. },
  2891. },
  2892. emits: ["update:modelValue", "ready", "change"],
  2893. setup(props, { emit }) {
  2894. const SsEditorIcon = resolveComponent("SsEditorIcon");
  2895. const editorRef = ref(null);
  2896. let editorContent = '';//保存富文本编辑器里面的富文本内容
  2897. const uniqueId = "editor-" + Date.now();
  2898. const errMsg = Vue.ref("");
  2899. let fjid = ref(props.param.button.val);
  2900. let fjName = props.param.button.desc;
  2901. let mode = props.param.mode;
  2902. const validate = () => {
  2903. if (window.ssVm) {
  2904. const result = window.ssVm.validateField(props.name);
  2905. console.log("validate", window.ssVm.validateField(props.name));
  2906. errMsg.value = result.valid ? "" : result.message;
  2907. }
  2908. };
  2909. onMounted(() => {
  2910. validate();
  2911. const editor = Jodit.make(`#${uniqueId}`, {
  2912. height: props.height,
  2913. placeholder: props.placeholder,
  2914. readonly: props.readonly,
  2915. language: "zh_cn",
  2916. i18n: {
  2917. zh_cn: {
  2918. Link: "链接",
  2919. URL: "链接",
  2920. "No follow": "无跟踪",
  2921. "Class name": "类名",
  2922. Image: "图片",
  2923. File: "文件",
  2924. "Line height": "行高",
  2925. Alternative: "描述",
  2926. "Alternative text": "描述",
  2927. "Lower Alpha": "小写字母",
  2928. "Upper Alpha": "大写字母",
  2929. "Upper Roman": "大写罗马数字",
  2930. "Lower Roman": "小写罗马数字",
  2931. "Lower Greek": "小写希腊字母",
  2932. "Lower Letter": "小写字母",
  2933. "Upper Letter": "大写字母",
  2934. },
  2935. },
  2936. showXPathInStatusbar: false,
  2937. showCharsCounter: false,
  2938. showWordsCounter: false,
  2939. allowResizeY: false,
  2940. toolbarSticky: false,
  2941. statusbar: false,
  2942. uploader: {
  2943. url: props.uploadUrl,
  2944. format: "json",
  2945. method: "POST",
  2946. filesVariableName: function (i) {
  2947. return "imgs[" + i + "]";
  2948. },
  2949. headers: {
  2950. Accept: "application/json",
  2951. },
  2952. prepareData: function (formData) {
  2953. // 这里可以在发送前处理表单数据
  2954. return formData;
  2955. },
  2956. isSuccess: function (resp) {
  2957. console.log("isSuccess resp:", resp);
  2958. return resp.code === 0;
  2959. },
  2960. getMessage: function (resp) {
  2961. console.log("getMessage resp:", resp);
  2962. return resp.msg || "上传失败";
  2963. },
  2964. process: function (resp) {
  2965. console.log("process resp:", resp);
  2966. return resp.data.url;
  2967. },
  2968. error: function (e) {
  2969. console.error("上传失败:", e.message);
  2970. },
  2971. defaultHandlerSuccess: function (resp) {
  2972. console.log("上传成功:", resp);
  2973. },
  2974. defaultHandlerError: function (err) {
  2975. console.error("上传错误:", err);
  2976. },
  2977. contentType: function (requestData) {
  2978. // 可以根据需要修改 Content-Type
  2979. return false; // 让浏览器自动设置
  2980. },
  2981. },
  2982. // 自定义字体列表
  2983. controls: {
  2984. font: {
  2985. list: {
  2986. Arial: "Arial",
  2987. SimSun: "宋体",
  2988. SimHei: "黑体",
  2989. "Microsoft YaHei": "微软雅黑",
  2990. KaiTi: "楷体",
  2991. FangSong: "仿宋",
  2992. "Times New Roman": "Times New Roman",
  2993. "Courier New": "Courier New",
  2994. },
  2995. },
  2996. customLinkButton: {
  2997. name: "link",
  2998. tooltip: "附件",
  2999. exec: function (editor) {
  3000. // 按钮点击时的处理函数
  3001. console.log("附件点击了");
  3002. console.log("param", props.param);
  3003. console.log("cmsAddUrl",props.param.button.cmsAddUrl);
  3004. if (fjid.value == null || fjid.value == "") {
  3005. $.ajax({
  3006. type: "post",
  3007. url: props.param.button.cmsAddUrl,
  3008. async: false,
  3009. data: {
  3010. name: "fjid",
  3011. ssNrObjName: "sh",
  3012. ssNrObjId: "",
  3013. },
  3014. success: function (_fjid) {
  3015. console.log("cmsAddUrl success", _fjid);
  3016. fjid.value = _fjid;
  3017. },
  3018. });
  3019. }
  3020. var str =
  3021. "&nrid=T-" +
  3022. fjid.value +
  3023. "&objectId=" +
  3024. fjid.value +
  3025. "&objectName=" +
  3026. fjName +
  3027. "&callback=" +
  3028. (window["fjidCallbackName"] || "");
  3029. console.log("str", str);
  3030. SS.openDialog({
  3031. src: props.param.button.cmsUpdUrl + str,
  3032. headerTitle: "编辑",
  3033. width: 900,
  3034. high: 664,
  3035. zIndex:51
  3036. });
  3037. // ss.display.showComponent({
  3038. // show: ["wdDialog"],
  3039. // url: props.param.button.cmsUpdUrl + str,
  3040. // title: "编辑",
  3041. // width: 900,
  3042. // high: 664,
  3043. // });
  3044. },
  3045. },
  3046. },
  3047. toolbarAdaptive: true,
  3048. buttons: [
  3049. "fullsize",
  3050. "bold",
  3051. "italic",
  3052. "underline",
  3053. "strikethrough",
  3054. "eraser",
  3055. "|",
  3056. "font",
  3057. "fontsize",
  3058. "brush",
  3059. "paragraph",
  3060. "|",
  3061. "left",
  3062. "center",
  3063. "right",
  3064. "justify",
  3065. "|",
  3066. "ul",
  3067. "ol",
  3068. "indent",
  3069. "outdent",
  3070. "|",
  3071. "image",
  3072. "table",
  3073. "customLinkButton",
  3074. "print",
  3075. "|",
  3076. "undo",
  3077. "redo",
  3078. "find",
  3079. ],
  3080. // 中等宽度时显示的按钮
  3081. buttonsMD: [
  3082. "fullsize",
  3083. "bold",
  3084. "italic",
  3085. "underline",
  3086. "strikethrough",
  3087. "eraser",
  3088. "|",
  3089. "font",
  3090. "fontsize",
  3091. "brush",
  3092. "paragraph",
  3093. "|",
  3094. "font",
  3095. "fontsize",
  3096. "|",
  3097. "left",
  3098. "center",
  3099. "right",
  3100. "justify",
  3101. "|",
  3102. "image",
  3103. "customLinkButton",
  3104. "|",
  3105. "dots", // 其余按钮会自动进入 dots 菜单
  3106. ],
  3107. // 小屏幕时显示的按钮
  3108. buttonsSM: ["fullsize", "bold", "italic", "|", "image", "|", "dots"],
  3109. // 超小屏幕时显示的按钮
  3110. buttonsXS: ["fullsize", "bold", "|", "dots"],
  3111. // 设置响应式断点
  3112. sizeLG: 1024, // 大屏幕
  3113. sizeMD: 768, // 中等屏幕
  3114. sizeSM: 576, // 小屏幕
  3115. // 自定义图标
  3116. getIcon: function (name, clearName) {
  3117. // 定义图标映射
  3118. const iconMap = {
  3119. bold: "editor-icon-bold",
  3120. italic: "editor-icon-italic",
  3121. underline: "editor-icon-underline",
  3122. strikethrough: "editor-icon-strikethrough",
  3123. eraser: "editor-icon-eraser",
  3124. copyformat: "editor-icon-copyformat",
  3125. font: "editor-icon-font",
  3126. fontsize: "editor-icon-fontsize",
  3127. brush: "editor-icon-brush",
  3128. paragraph: "editor-icon-paragraph",
  3129. left: "editor-icon-align-left",
  3130. center: "editor-icon-align-center",
  3131. right: "editor-icon-align-right",
  3132. justify: "editor-icon-align-justify",
  3133. ul: "editor-icon-ul",
  3134. ol: "editor-icon-ol",
  3135. indent: "editor-icon-indent",
  3136. outdent: "editor-icon-outdent",
  3137. image: "editor-icon-image",
  3138. file: "editor-icon-file",
  3139. video: "editor-icon-video",
  3140. table: "editor-icon-table",
  3141. link: "editor-icon-link",
  3142. source: "editor-icon-source",
  3143. eye: "editor-icon-preview",
  3144. fullsize: "editor-icon-fullsize",
  3145. shrink: "editor-icon-fullsize-exit", // 添加退出全屏图标
  3146. print: "editor-icon-print",
  3147. undo: "editor-icon-undo",
  3148. redo: "editor-icon-redo",
  3149. search: "editor-icon-find",
  3150. selectall: "editor-icon-selectall",
  3151. };
  3152. // 获取对应的图标类名
  3153. const iconClass = iconMap[clearName] || iconMap[name];
  3154. if (iconClass) {
  3155. // 返回带有我们自定义图标类的 span 元素
  3156. return `<span class="editor-icon ${iconClass}"></span>`;
  3157. }
  3158. return null;
  3159. },
  3160. });
  3161. // 设置初始值
  3162. editor.value = editorContent;
  3163. // editor.value = props.modelValue;
  3164. // 监听变化
  3165. editor.events.on("change", () => {
  3166. // emit("update:modelValue", editor.value);
  3167. editorContent = editor.value;
  3168. // alert('editorContent:'+editorContent);
  3169. let contentElements = document.getElementsByName(props.name.replace(/wj$/, "") + "Edit");
  3170. if(contentElements.length>0){
  3171. contentElements[0].value = editorContent;
  3172. }
  3173. emit("change", editor.value);
  3174. setTimeout(() => {
  3175. validate();
  3176. }, 50);
  3177. });
  3178. // 保存编辑器实例
  3179. editorRef.value = editor;
  3180. emit("ready", editor);
  3181. //回显编辑器富文本文件
  3182. if (props.url ) {
  3183. const params = new URLSearchParams();
  3184. if(mode)
  3185. params.append("mode", mode);
  3186. if(props.modelValue)
  3187. params.append("path", props.modelValue);
  3188. // alert('props.url:'+props.url+',props.modelValue:'+props.modelValue);
  3189. axios
  3190. .post(props.url, params, {
  3191. headers: {
  3192. "Content-Type": "application/x-www-form-urlencoded", // 必须手动设置!
  3193. },
  3194. })
  3195. .then((response) => {
  3196. // alert(JSON.stringify(response.data));
  3197. if ("timeout" == response.data.statusText) {
  3198. alert("网络超时!");
  3199. return;
  3200. }
  3201. let content = response.data.content;
  3202. if (content) {
  3203. // editor.value = content;
  3204. editorRef.value.value = content;
  3205. editorContent = content;
  3206. // alert('editor.value:'+editor.value)
  3207. }
  3208. let filePath = response.data.path;
  3209. // alert('response.data:'+JSON.stringify(response.data));
  3210. if(filePath){
  3211. props.modelValue = filePath;
  3212. emit("update:modelValue", filePath);
  3213. }
  3214. });
  3215. }
  3216. });
  3217. // 监听值变化
  3218. watch(
  3219. // () => props.modelValue,
  3220. () => editorContent,
  3221. (newValue) => {
  3222. if (editorRef.value && newValue !== editorRef.value.value) {
  3223. editorRef.value.value = newValue || "";
  3224. }
  3225. }
  3226. );
  3227. // 监听只读状态变化
  3228. watch(
  3229. () => props.readonly,
  3230. (newValue) => {
  3231. if (editorRef.value) {
  3232. editorRef.value.setReadOnly(newValue);
  3233. }
  3234. }
  3235. );
  3236. // 组件销毁时清理
  3237. onBeforeUnmount(() => {
  3238. if (editorRef.value) {
  3239. editorRef.value.destruct();
  3240. }
  3241. });
  3242. return () =>
  3243. h("div", { class: "ss-editor-container" }, [
  3244. fjid.value &&
  3245. h("input", {
  3246. type: "hidden",
  3247. name: "fjid",
  3248. value: fjid.value,
  3249. }),
  3250. h("input", {
  3251. type: "hidden",
  3252. name: props.name.replace(/wj$/, "") + "Edit",
  3253. value: editorContent
  3254. // value: props.modelValue,
  3255. }),
  3256. h("input", {
  3257. type: "hidden",
  3258. name: props.name.replace(/wj$/, "") + "wj",
  3259. value: props.modelValue
  3260. // value: props.url
  3261. }),
  3262. h("input", { type: "hidden", name: "ueditorpath", value: "mswj" }),
  3263. h("textarea", { id: uniqueId }),
  3264. ]);
  3265. },
  3266. };
  3267. // 弹窗右边图标
  3268. const SsFullStyleHeader = {
  3269. name: "SsFullStyleHeader",
  3270. props: {
  3271. title: {
  3272. type: String,
  3273. default: "标题",
  3274. },
  3275. },
  3276. emits: ["close"],
  3277. setup(props, { emit }) {
  3278. // console.log(props.title)
  3279. const onClose = () => {
  3280. emit("close");
  3281. };
  3282. const SsIcon = resolveComponent("ss-icon");
  3283. return () =>
  3284. h("div", { class: "header-container" }, [
  3285. h("div", { class: "title" }, props.title),
  3286. h("div", { class: "handle-bar" }, [
  3287. h("div", { class: "left-bar" }, [
  3288. h(SsDialogIcon, { class: "dialog-icon-download" }),
  3289. h(SsDialogIcon, { class: "dialog-icon-print" }),
  3290. h(SsDialogIcon, { class: "dialog-icon-setting" }),
  3291. h(SsDialogIcon, { class: "dialog-icon-collect" }),
  3292. h(SsDialogIcon, { class: "dialog-icon-help" }),
  3293. h(SsDialogIcon, { class: "dialog-icon-full-screen" }),
  3294. h(SsDialogIcon, { class: "dialog-icon-lock" }),
  3295. ]),
  3296. h("div", { class: "close-bar", onClick: onClose }, [
  3297. h(SsDialogIcon, { class: "dialog-icon-close" }),
  3298. ]),
  3299. ]),
  3300. ]);
  3301. },
  3302. };
  3303. // ss-dialog弹窗
  3304. const SsDialog = {
  3305. name: "SsDialog",
  3306. props: {
  3307. src: {
  3308. type: String,
  3309. },
  3310. headerTitle: {
  3311. type: String,
  3312. // required: true,
  3313. default: "弹窗",
  3314. },
  3315. width: {
  3316. type: String,
  3317. default: "1400",
  3318. },
  3319. height: {
  3320. type: String,
  3321. default: "600",
  3322. },
  3323. params: {
  3324. type: Object,
  3325. default: () => ({}),
  3326. },
  3327. zIndex: {
  3328. type: Number,
  3329. default: 1000,
  3330. },
  3331. },
  3332. emits: ["close"],
  3333. setup(props, { slots, emit }) {
  3334. // 关闭窗口方法
  3335. const onClose = () => {
  3336. emit("close");
  3337. };
  3338. const showHeader = ref(true);
  3339. const headerVisible = ref(false);
  3340. const popupHieght = ref(props.height);
  3341. // 状态:存储位置信息
  3342. const position = reactive({
  3343. // 页面居中
  3344. x: (window.innerWidth - props.width) / 2,
  3345. y: (window.innerHeight - popupHieght.value) / 2,
  3346. isDragging: false,
  3347. offsetX: 0,
  3348. offsetY: 0,
  3349. });
  3350. // 鼠标按下时设置起始坐标并开始拖拽
  3351. const startDrag = (event) => {
  3352. position.isDragging = true;
  3353. position.offsetX = event.clientX - position.x;
  3354. position.offsetY = event.clientY - position.y;
  3355. };
  3356. // 鼠标移动时更新位置
  3357. const onDrag = (event) => {
  3358. if (position.isDragging) {
  3359. position.x = event.clientX - position.offsetX;
  3360. position.y = event.clientY - position.offsetY;
  3361. }
  3362. };
  3363. // 鼠标放开时结束拖拽
  3364. const endDrag = () => {
  3365. position.isDragging = false;
  3366. };
  3367. // 监听来自 iframe 的消息
  3368. const handleMessage = (event) => {
  3369. // 顶天立地
  3370. if (event.data && typeof event.data.hasScrollBar !== "undefined") {
  3371. if (event.data.hasScrollBar) {
  3372. // console.log(event);
  3373. position.y = 10;
  3374. showHeader.value = false;
  3375. headerVisible.value = true;
  3376. popupHieght.value = window.innerHeight - 20;
  3377. // console.log(popupHieght.value);
  3378. document.querySelector(".body").style.height = "100%";
  3379. document.querySelector(".body").style.paddingTop = "30px";
  3380. document.querySelector(".header-container ").style.position =
  3381. "absolute";
  3382. document.querySelector(".header-container ").style.zIndex = "10";
  3383. }
  3384. }
  3385. };
  3386. // 鼠标移入关闭按钮区域时显示头部
  3387. const onMouseEnterCloseButton = () => {
  3388. headerVisible.value = false;
  3389. };
  3390. // 鼠标移出关闭按钮区域时隐藏头部
  3391. const onMouseLeaveCloseButton = () => {
  3392. headerVisible.value = true;
  3393. };
  3394. // 在组件挂载时添加全局事件监听器
  3395. Vue.onMounted(() => {
  3396. // 如果传过来的高度大于窗口高度,则设置为窗口高度减去20 否则保持传过来的高度
  3397. popupHieght.value =
  3398. popupHieght.value > window.innerHeight
  3399. ? window.innerHeight - 20
  3400. : popupHieght.value;
  3401. const container = document.querySelector(".header-container");
  3402. if (container) {
  3403. container.addEventListener("mousedown", startDrag);
  3404. }
  3405. document.addEventListener("mousemove", onDrag);
  3406. document.addEventListener("mouseup", endDrag);
  3407. window.addEventListener("message", handleMessage);
  3408. });
  3409. // 在组件卸载时移除全局事件监听器
  3410. Vue.onUnmounted(() => {
  3411. document.removeEventListener("mousemove", onDrag);
  3412. document.removeEventListener("mouseup", endDrag);
  3413. window.removeEventListener("message", handleMessage);
  3414. });
  3415. const SsMark = resolveComponent("ss-mark");
  3416. const SsFullStyleHeader = resolveComponent("ss-full-style-header");
  3417. // render函数定义组件结构
  3418. return () =>
  3419. h(
  3420. Teleport,
  3421. { to: "body" }, // 使用 Teleport 将弹窗内容挂载到 body
  3422. h(SsMark, { }, [
  3423. h(
  3424. "div",
  3425. {
  3426. class: "popup-container",
  3427. style: {
  3428. position: "absolute",
  3429. left: `${position.x}px`,
  3430. top: `${position.y}px`,
  3431. width: props.width + "px",
  3432. height: popupHieght.value + "px",
  3433. zIndex: props.zIndex, // 确保弹窗在最上层
  3434. },
  3435. },
  3436. [
  3437. h(SsFullStyleHeader, {
  3438. class: "header",
  3439. title: props.headerTitle,
  3440. onClose: onClose,
  3441. onMousedown: startDrag, // 绑定拖动事件
  3442. onMouseUp: endDrag,
  3443. ...(!showHeader.value && {
  3444. onMouseenter: onMouseEnterCloseButton,
  3445. onMouseleave: onMouseLeaveCloseButton,
  3446. }),
  3447. style: {
  3448. cursor: position.isDragging ? "grabbing" : "grab",
  3449. visibility: headerVisible.value ? "hidden" : "visible",
  3450. },
  3451. }),
  3452. h(
  3453. "div",
  3454. {
  3455. class: "body",
  3456. style: {},
  3457. },
  3458. [
  3459. h("iframe", {
  3460. src: props.src,
  3461. frameborder: 0,
  3462. style: { width: "100%", height: "100%" },
  3463. }),
  3464. ]
  3465. ),
  3466. headerVisible.value &&
  3467. h("div", {
  3468. class: "close-button",
  3469. onMouseenter: onMouseEnterCloseButton,
  3470. onMouseleave: onMouseLeaveCloseButton,
  3471. style: {
  3472. position: "absolute",
  3473. top: "0",
  3474. right: "0",
  3475. // background: 'black',
  3476. width: "60px",
  3477. height: "60px",
  3478. cursor: "pointer",
  3479. },
  3480. }),
  3481. ]
  3482. ),
  3483. ])
  3484. );
  3485. },
  3486. };
  3487. // ss-mark遮罩层
  3488. const SsMark = {
  3489. name: "SsMark",
  3490. setup(props, { slots, emit }) {
  3491. return () =>
  3492. h("div", { class: "dialog-container" }, [
  3493. h("div", { class: "mark-content" }, [
  3494. h("div", { class: "dialog-contianer" }, [
  3495. slots.default ? slots.default() : "",
  3496. ]),
  3497. ]),
  3498. ]);
  3499. },
  3500. };
  3501. // ss-bottom-button 底部按钮
  3502. // 修改支持更多按钮 by xu 20251211
  3503. const SsBottomButton = {
  3504. name: "SsBottomButton",
  3505. props: {
  3506. text: {
  3507. type: String,
  3508. required: false,
  3509. },
  3510. type: {
  3511. type: String,
  3512. default: "button",
  3513. },
  3514. iconClass: {
  3515. type: String,
  3516. },
  3517. class: {
  3518. type: String,
  3519. default: "",
  3520. },
  3521. onclick: {
  3522. type: [Function, String],
  3523. default: null,
  3524. },
  3525. // 修改支持更多按钮 by xu 20251211
  3526. more: {
  3527. type: [Boolean, String],
  3528. default: false,
  3529. },
  3530. },
  3531. setup(props, { emit }) {
  3532. const SsBottomDivIcon = Vue.resolveComponent("ss-bottom-div-icon");
  3533. const showDropdown = Vue.ref(false);
  3534. // 修改支持更多按钮 by xu 20251211
  3535. const moreKey = Vue.computed(() => {
  3536. const val = props.more;
  3537. if (val === false || val === null || typeof val === "undefined") {
  3538. return null;
  3539. }
  3540. if (val === true || val === "" || val === "true") {
  3541. return "moreChg";
  3542. }
  3543. return val;
  3544. });
  3545. // 从配置中读取按钮信息和下拉选项
  3546. const config = Vue.computed(() => {
  3547. if (moreKey.value && window.ss && window.ss.dom && window.ss.dom.btnElemConfig) {
  3548. return window.ss.dom.btnElemConfig[moreKey.value] || {};
  3549. }
  3550. return {};
  3551. });
  3552. const buttonText = Vue.computed(() => {
  3553. return props.text || config.value.desc || '';
  3554. });
  3555. const dropOptions = Vue.computed(() => {
  3556. return config.value.dropOptions || [];
  3557. });
  3558. const hasDropdown = Vue.computed(() => {
  3559. return dropOptions.value.length > 0;
  3560. });
  3561. const handleMouseEnter = () => {
  3562. if (hasDropdown.value) {
  3563. showDropdown.value = true;
  3564. }
  3565. };
  3566. const handleMouseLeave = () => {
  3567. showDropdown.value = false;
  3568. };
  3569. const handleDropItemClick = (option) => {
  3570. if (option.callback && typeof option.callback === 'function') {
  3571. option.callback();
  3572. }
  3573. showDropdown.value = false;
  3574. };
  3575. return () =>
  3576. h(
  3577. "div",
  3578. {
  3579. class: "ss-bottom-button-wrapper",
  3580. onMouseenter: handleMouseEnter,
  3581. onMouseleave: handleMouseLeave,
  3582. },
  3583. [
  3584. h(
  3585. "button",
  3586. {
  3587. class: props.class,
  3588. onClick: (e) => {
  3589. e.stopPropagation();
  3590. if (props.onclick) {
  3591. // 如果是函数直接调用
  3592. if (typeof props.onclick === "function") {
  3593. props.onclick(e);
  3594. } else if (typeof props.onclick === "string") {
  3595. // 如果是字符串,使用直接的方法执行
  3596. // 临时存储按钮元素到全局变量
  3597. window.__ss_current_button = e.currentTarget;
  3598. // 直接执行代码,使用eval以保留原始上下文
  3599. try {
  3600. eval(props.onclick);
  3601. } finally {
  3602. // 清理全局变量
  3603. delete window.__ss_current_button;
  3604. }
  3605. }
  3606. }
  3607. },
  3608. type: props.type,
  3609. },
  3610. [
  3611. h("span", null, [
  3612. h(SsBottomDivIcon, {
  3613. class: props.iconClass,
  3614. }),
  3615. ]),
  3616. h("span", null, buttonText.value),
  3617. ]
  3618. ),
  3619. // 渲染下拉菜单
  3620. hasDropdown.value && showDropdown.value
  3621. ? h(
  3622. "div",
  3623. {
  3624. class: "ss-bottom-button-dropdown",
  3625. },
  3626. dropOptions.value.map((option) =>
  3627. h(
  3628. "div",
  3629. {
  3630. class: "ss-bottom-button-dropdown-item",
  3631. onClick: (e) => {
  3632. e.stopPropagation();
  3633. handleDropItemClick(option);
  3634. },
  3635. },
  3636. option.desc
  3637. )
  3638. )
  3639. )
  3640. : null,
  3641. ]
  3642. );
  3643. },
  3644. };
  3645. // ss-search搜索框
  3646. const SsSearch = {
  3647. name: "SsSearch",
  3648. props: {
  3649. theme: {
  3650. type: String,
  3651. default: "light",
  3652. validator: function (value) {
  3653. return ["dark", "light"].includes(value);
  3654. },
  3655. },
  3656. placeholder: {
  3657. type: String,
  3658. default: "请输入搜索条件",
  3659. },
  3660. },
  3661. setup(props, { emit }) {
  3662. const onClick = () => {
  3663. console.log("Search clicked");
  3664. emit("click");
  3665. };
  3666. const SsIcon = Vue.resolveComponent("ss-icon");
  3667. return () =>
  3668. Vue.h(
  3669. "div",
  3670. {
  3671. class: ["search-container", props.theme],
  3672. onClick: onClick,
  3673. },
  3674. [
  3675. Vue.h("input", {
  3676. placeholder: props.placeholder,
  3677. disabled: true,
  3678. }),
  3679. Vue.h(SsIcon, {
  3680. name: "search-result",
  3681. size: "20px",
  3682. }),
  3683. ]
  3684. );
  3685. },
  3686. };
  3687. // ss-cart-item 菜单页面的卡片 左右结构
  3688. const SsCartItem = {
  3689. name: "SsCartItem",
  3690. props: {
  3691. active: Boolean,
  3692. item: {
  3693. type: Object,
  3694. default: () => ({
  3695. thumb: "images/example/project-img.png",
  3696. title: "广州(国际)科技成果转化天河基地专",
  3697. description: "佳能中国广州分公司",
  3698. all: 50,
  3699. finish: 5,
  3700. }),
  3701. },
  3702. },
  3703. setup(props, { emit }) {
  3704. const item = props.item;
  3705. const itemWidth = Vue.computed(() => {
  3706. const containerWidth =
  3707. document.body.clientWidth || document.body.scrollWidth - 520;
  3708. const halfWidth = containerWidth / 2;
  3709. if (halfWidth < 480) {
  3710. return Math.min(containerWidth, 702) + "px";
  3711. } else {
  3712. return Math.min(halfWidth, 702) + "px";
  3713. }
  3714. });
  3715. const onItemClick = (e) => {
  3716. emit("click", e);
  3717. };
  3718. return {
  3719. item,
  3720. itemWidth,
  3721. onItemClick,
  3722. };
  3723. },
  3724. render() {
  3725. const SsIcon = Vue.resolveComponent("ss-icon");
  3726. return Vue.h(
  3727. "div",
  3728. {
  3729. class: { "item-container": true, active: this.active },
  3730. onClick: this.onItemClick,
  3731. style: { width: this.itemWidth },
  3732. },
  3733. [
  3734. Vue.h("div", { class: "header" }, [
  3735. Vue.h(SsIcon, { name: "setting", size: "20px" }),
  3736. ]),
  3737. Vue.h("div", { class: "body" }, [
  3738. Vue.h("div", { class: "left" }, [
  3739. Vue.h("img", {
  3740. src: this.item.thumb,
  3741. alt: "Thumbnail",
  3742. class: "imgUnHandle",
  3743. style: { "object-fit": "cover", width: "100%", height: "100%" },
  3744. }),
  3745. ]),
  3746. Vue.h("div", { class: "right" }, [
  3747. Vue.h("div", { class: "title" }, this.item.title),
  3748. Vue.h("div", { class: "desc" }, this.item.description),
  3749. Vue.h("div", { class: "progress" }, [
  3750. Vue.h(
  3751. "div",
  3752. {
  3753. style: {
  3754. width: `${(this.item.finish / this.item.all) * 100}%`,
  3755. },
  3756. },
  3757. [Vue.h("div", `${this.item.finish}/${this.item.all}`)]
  3758. ),
  3759. ]),
  3760. ]),
  3761. ]),
  3762. ]
  3763. );
  3764. },
  3765. };
  3766. // ss-cart-item2 菜单页面的卡片 上下结构
  3767. const SsCartItem2 = {
  3768. name: "SsCartItem2",
  3769. props: {
  3770. active: Boolean,
  3771. item: {
  3772. type: Object,
  3773. default: () => ({
  3774. thumb: "images/example/project-img.png",
  3775. title: "广州(国际)科技成果转化天河基地专",
  3776. description: "佳能中国广州分公司",
  3777. all: 50,
  3778. finish: 5,
  3779. }),
  3780. },
  3781. },
  3782. setup(props, { emit }) {
  3783. const item = props.item;
  3784. const itemWidth = Vue.computed(() => {
  3785. const containerWidth =
  3786. document.body.clientWidth || document.body.scrollWidth - 520;
  3787. const halfWidth = containerWidth / 2;
  3788. if (halfWidth < 480) {
  3789. return Math.min(containerWidth, 702) + "px";
  3790. } else {
  3791. return Math.min(halfWidth, 702) + "px";
  3792. }
  3793. });
  3794. const onItemClick = (e) => {
  3795. emit("click", e);
  3796. };
  3797. return {
  3798. item,
  3799. itemWidth,
  3800. onItemClick,
  3801. };
  3802. },
  3803. render() {
  3804. const SsIcon = Vue.resolveComponent("ss-icon");
  3805. return Vue.h(
  3806. "div",
  3807. {
  3808. class: { "item-container2": true, active: this.active },
  3809. onClick: this.onItemClick,
  3810. style: { width: this.itemWidth },
  3811. },
  3812. [
  3813. Vue.h("div", { class: "action-bar" }, [
  3814. Vue.h(SsIcon, { name: "setting", size: "20px" }),
  3815. ]),
  3816. Vue.h("div", { class: "header" }, [
  3817. Vue.h("div", { class: "title" }, `${this.item.title}`),
  3818. ]),
  3819. Vue.h("div", { class: "body" }, [
  3820. Vue.h("div", { class: "left" }, [
  3821. Vue.h("img", {
  3822. src: this.item.thumb,
  3823. alt: "Thumbnail",
  3824. class: "imgUnHandle",
  3825. style: { "object-fit": "cover", width: "100%", height: "100%" },
  3826. }),
  3827. ]),
  3828. Vue.h("div", { class: "right" }, [
  3829. Vue.h("div", { class: "content" }, this.item.description),
  3830. Vue.h("div", { class: "tip" }, [
  3831. Vue.h("div", { class: "progress" }, [
  3832. Vue.h(
  3833. "div",
  3834. {
  3835. style: {
  3836. width: `${(this.item.finish / this.item.all) * 100}%`,
  3837. },
  3838. },
  3839. [Vue.h("div", `${this.item.finish}/${this.item.all}`)]
  3840. ),
  3841. ]),
  3842. ]),
  3843. ]),
  3844. ]),
  3845. ]
  3846. );
  3847. },
  3848. };
  3849. /**
  3850. * SsListCard - 列表卡片组件
  3851. *
  3852. * @description 用于显示列表项的卡片组件,支持缩略图、标签、状态、操作按钮和选择功能
  3853. *
  3854. * @prop {Object} item - 卡片数据对象
  3855. * @prop {String} item.title - 卡片标题
  3856. * @prop {String} [item.thumb] - 缩略图 URL(可选)
  3857. * @prop {String} [item.thumbType] - 缩略图类型:'thumbnail'(缩略图)或默认(证件照)
  3858. * @prop {String} [item.status] - 卡片状态:'available'(可用-绿色)、'unavailable'(不可用-黄色)、'disabled'(禁用-红色)
  3859. * @prop {Array} item.tags - 标签数组,格式:[{键: 值}, ...]
  3860. * @prop {Function} item.onclick - 点击卡片的回调函数
  3861. * @prop {Array} [item.buttons] - 操作按钮数组(可选),显示在右上角齿轮
  3862. * @prop {Array} [item.statusIcons] - 状态图标数组(可选),显示在右上角,格式:[{class: '图标类名', title: '提示文字'}, ...]
  3863. *
  3864. * @example
  3865. * // 基础用法
  3866. * const item = {
  3867. * title: "卡片标题",
  3868. * tags: [
  3869. * { 类型: '文档' },
  3870. * { 状态: '进行中' }
  3871. * ],
  3872. * onclick: () => console.log('点击了卡片')
  3873. * };
  3874. *
  3875. * @example
  3876. * // 带缩略图和状态
  3877. * const item = {
  3878. * title: "场地预定",
  3879. * thumbType: 'thumbnail',
  3880. * thumb: "https://example.com/image.jpg",
  3881. * status: "available", // 绿色背景
  3882. * tags: [{ 容量: '50人' }],
  3883. * onclick: () => {}
  3884. * };
  3885. *
  3886. * @example
  3887. * // 带操作按钮和状态图标
  3888. * const item = {
  3889. * title: "会议室A",
  3890. * tags: [{ 楼层: '3F' }],
  3891. * onclick: () => {},
  3892. * // 右上角操作按钮(齿轮)
  3893. * buttons: [{
  3894. * class: 'cart-list-setting',
  3895. * title: '编辑',
  3896. * onclick: () => console.log('编辑')
  3897. * }],
  3898. * // 右上角状态图标(在齿轮右边)
  3899. * statusIcons: [{
  3900. * class: 'icon-emoji',
  3901. * title: '清洁中'
  3902. * }]
  3903. * };
  3904. *
  3905. * @features
  3906. * - 卡片选择:鼠标悬停右下角显示选择角标,点击切换选中状态,选中后显示底部深灰色线条
  3907. * - 状态颜色:根据 status 字段显示不同背景色(可用/不可用/禁用)
  3908. * - 图片类型:支持证件照(73×100px)和缩略图(180×100px)两种尺寸
  3909. * - 操作按钮:右上角齿轮,hover 显示,支持多个按钮下拉菜单
  3910. * - 状态图标:右上角显示状态图标,齿轮会根据图标数量自动左移
  3911. *
  3912. * @author xu
  3913. * @date 20260105
  3914. */
  3915. // 组件文档补全(JSDoc) by xu 20260108
  3916. /**
  3917. * SsListCard(左侧对象卡片)
  3918. *
  3919. * 用途:
  3920. * - 渲染左侧卡片(标题 + tags)
  3921. * - 右下角“角标”用于选中/取消选中(不会触发卡片 click)
  3922. *
  3923. * 调用示例:
  3924. * ```html
  3925. * <ss-list-card :item="item" @toggle-select="handleToggleSelect" @click="openDetail"></ss-list-card>
  3926. * ```
  3927. *
  3928. * Props:
  3929. * - `item`:卡片数据对象(建议含 `id/title/tags[]`;内部会读写 `item._ssSelected` 作为选中态)
  3930. *
  3931. * Emits:
  3932. * - `toggle-select`:点击角标触发,参数 `{ item, selected }`
  3933. * - `click`:点击卡片主体触发(用于打开详情等)
  3934. */
  3935. const SsListCard = {
  3936. name: "SsListCard",
  3937. props: {
  3938. ssObjName: { type: String, default: "" }, // 功能:业务对象名(用于默认缩略图 icon) by xu 20260109
  3939. cardClickAction: { type: String, default: "view" }, // 功能:卡片主体点击动作(view=查看;single=单选互斥) by xu 20260109
  3940. item: {
  3941. type: Object,
  3942. required: true,
  3943. },
  3944. },
  3945. emits: ["click", "change", "toggle-select"],
  3946. setup(props, { emit }) {
  3947. const item = props.item;
  3948. // 移除 itemWidth 计算属性,不再需要 by xu 20260105
  3949. // 判断卡片类型 by xu 20260105
  3950. const cardType = Vue.computed(() => {
  3951. // 支持“无图但保留缩略图占位”(同一业务列表图片形态一致) by xu 20260109
  3952. if (!item.thumb && !item.thumbType) return ''; // 业务列表“无图”形态
  3953. // 根据 thumbType 字段判断,如果没有则默认为证件照
  3954. return item.thumbType === 'thumbnail' ? 'card-thumbnail' : 'card-photo';
  3955. });
  3956. // 判断状态类型 - 场地预定状态 by xu 20260105
  3957. const statusClass = Vue.computed(() => {
  3958. if (!item.status) return ''; // 无状态,默认白色
  3959. // 映射状态值到 CSS 类名
  3960. const statusMap = {
  3961. 'available': 'status-available',
  3962. 'unavailable': 'status-unavailable',
  3963. 'disabled': 'status-disabled'
  3964. };
  3965. return statusMap[item.status] || '';
  3966. });
  3967. const onItemClick = (e) => {
  3968. // 清除所有类型卡片的 active 状态(卡片主体点击仅做 active 高亮) by xu 20260109
  3969. const allListCards = document.querySelectorAll(
  3970. ".knowledge-item-container"
  3971. );
  3972. const allFolderCards = document.querySelectorAll(".ss-folder-list");
  3973. allListCards.forEach((card) => card.classList.remove("active"));
  3974. allFolderCards.forEach((card) => card.classList.remove("active"));
  3975. // 设置当前项的 active 状态
  3976. e.currentTarget.classList.add("active");
  3977. // 卡片主体点击动作由页面级配置控制 by xu 20260109
  3978. if (props.cardClickAction === "view") {
  3979. props.item.onclick?.();
  3980. // 通知父级:卡片点击(查看) by xu 20260109
  3981. emit("click", props.item);
  3982. }
  3983. };
  3984. const onItemChange = (e, icon, index) => {
  3985. e.stopPropagation(); // 阻止事件冒泡到卡片
  3986. props.item.buttons[0].onclick();
  3987. // emit("change", { item: props.item, icon, index });
  3988. };
  3989. return {
  3990. item,
  3991. cardType,
  3992. statusClass,
  3993. onItemClick,
  3994. onItemChange,
  3995. };
  3996. },
  3997. data() {
  3998. return {
  3999. showButtons: false,
  4000. selected: false, // 选择状态 by xu 20260105
  4001. showTextPopover: false, // 功能:右侧文字区 hover 展示全量 by xu 20260108
  4002. textPopoverType: "", // second-summary / second-tags / third / third-full by xu 20260108
  4003. textPopoverBottom: 0, // 功能:popover 从当前省略行位置向上展开 by xu 20260108
  4004. hideTextPopoverTimer: null, // 功能:鼠标从省略行移到浮层的缓冲 by xu 20260108
  4005. textPopoverPayload: null, // { kind, text?, lines? } by xu 20260108
  4006. ellipsisVisible: { // 功能:只在真实出现 ... 时才显示命中区/允许 goheight by xu 20260109
  4007. secondSummary: false,
  4008. secondTags: false,
  4009. third: false,
  4010. thirdFull: false,
  4011. },
  4012. };
  4013. },
  4014. methods: {
  4015. // 切换选择状态(对外 emit,支持方案A父级 state 中转) by xu 20260106
  4016. toggleSelect(e) {
  4017. e.stopPropagation();
  4018. // 使用 item 上的状态,便于父级/右侧边栏反向同步 by xu 20260106
  4019. this.item._ssSelected = !this.item?._ssSelected;
  4020. this.$emit("toggle-select", { item: this.item, selected: !!this.item?._ssSelected });
  4021. },
  4022. // 卡片主体点击=单选互斥:只有“本次切到选中”才清理其他选中 by xu 20260109
  4023. toggleSelectExclusive(e) {
  4024. e?.stopPropagation?.();
  4025. this.item._ssSelected = !this.item?._ssSelected;
  4026. const selected = !!this.item?._ssSelected;
  4027. this.$emit("toggle-select", { item: this.item, selected, exclusive: true });
  4028. },
  4029. // 功能:无缩略图时,用业务对象 icon 做默认图(ss-icon + icon-obj-xx) by xu 20260109
  4030. getBizThumbIconClass() {
  4031. const name = String(
  4032. this.ssObjName ||
  4033. this.item?.ssObjName ||
  4034. this.$root?.ssObjName ||
  4035. window?.ss?.dom?.ssObjName ||
  4036. ""
  4037. ).trim();
  4038. if (!name) return "";
  4039. return `icon-obj-${name}`;
  4040. },
  4041. // 功能:构造右侧文字区 4 行(摘要/类目或标签/对象号) by xu 20260108
  4042. buildRightTextLines() {
  4043. const item = this.item || {};
  4044. const summary = String(item?.desc ?? "").trim(); // 后端字段后续映射 by xu 20260108
  4045. const objNum = String(item?.objNum ?? "").trim(); // 后端字段后续映射 by xu 20260108
  4046. const categoryArr = Array.isArray(item?.category) ? item.category : [];
  4047. const tagsArr = Array.isArray(item?.tags) ? item.tags : [];
  4048. const hasTags = tagsArr.length > 0;
  4049. const hasCategory = categoryArr.length > 0;
  4050. // 第二部分(L1-L3):摘要优先,其次物品参数 by xu 20260108
  4051. const secondKind = summary ? "summary" : hasTags ? "tags" : "";
  4052. const hasSecond = !!secondKind;
  4053. // 第三部分(L4):对象号优先,其次类目 by xu 20260108
  4054. const thirdKind = objNum ? "objNum" : hasCategory ? "category" : "";
  4055. const hasThird = !!thirdKind;
  4056. const thirdFull = !hasSecond && hasThird; // 第二部分为空则第三部分占满 4 行 by xu 20260108
  4057. const secondFull = hasSecond && !hasThird && secondKind === "tags"; // 仅标签时占满 4 行(不留空行) by xu 20260109
  4058. const toValueText = (obj) => { // 功能:类目/标签回显统一只保留 value(去掉 key:) by xu 20260109
  4059. const [k, v] = Object.entries(obj || {})[0] || ["", ""];
  4060. if (v !== undefined && v !== null && String(v).trim() !== "") return String(v);
  4061. // 兼容后端可能只给 key 没给 value 的情况:退化为显示 key by xu 20260109
  4062. if (k !== undefined && k !== null && String(k).trim() !== "") return String(k);
  4063. return "";
  4064. };
  4065. const toLineList = (arr) =>
  4066. (arr || [])
  4067. .map(toValueText)
  4068. .map((s) => String(s ?? "").trim())
  4069. .filter(Boolean);
  4070. const flat = (arr) => toLineList(arr).join(" ");
  4071. // 第二部分 tags:默认 3 行;仅标签时占满 4 行(避免底部空一行) by xu 20260109
  4072. const secondTagsMaxLines = secondFull ? 4 : 3;
  4073. const secondTagsLinesFull = toLineList(tagsArr);
  4074. const secondTagsHead = secondTagsLinesFull.slice(0, Math.max(0, secondTagsMaxLines - 1));
  4075. const secondTagsTail = secondTagsLinesFull.slice(Math.max(0, secondTagsMaxLines - 1));
  4076. const secondTagsLast =
  4077. secondTagsTail.length <= 1 ? (secondTagsTail[0] || "") : secondTagsTail.join(" "); // 功能:最后一行平铺剩余 by xu 20260108
  4078. // 第三部分类目:卡片上串成一行;goheight 展开时一条一行 by xu 20260109
  4079. const categoryLinesFull = toLineList(categoryArr);
  4080. const categoryLine = categoryLinesFull.join(" ");
  4081. const thirdText = thirdKind === "objNum" ? objNum : thirdKind === "category" ? categoryLine : "";
  4082. return {
  4083. secondKind,
  4084. thirdKind,
  4085. hasSecond,
  4086. hasThird,
  4087. thirdFull,
  4088. secondFull,
  4089. summary,
  4090. secondTagsMaxLines,
  4091. secondTagsHead,
  4092. secondTagsLast,
  4093. secondTagsLinesFull,
  4094. objNum,
  4095. categoryLine,
  4096. categoryLinesFull,
  4097. thirdText,
  4098. };
  4099. },
  4100. measureTextOverflowByLines(text, maxLines, width) {
  4101. const w = Number(width) || 0;
  4102. if (!w || !text) return false;
  4103. const probe = document.createElement("div");
  4104. probe.style.position = "fixed";
  4105. probe.style.left = "-99999px";
  4106. probe.style.top = "0";
  4107. probe.style.width = w + "px";
  4108. probe.style.fontSize = "18px";
  4109. probe.style.lineHeight = "24px";
  4110. probe.style.whiteSpace = "normal";
  4111. probe.style.wordBreak = "break-word";
  4112. probe.style.visibility = "hidden";
  4113. probe.textContent = text;
  4114. document.body.appendChild(probe);
  4115. const h = probe.getBoundingClientRect().height || 0;
  4116. document.body.removeChild(probe);
  4117. return h > maxLines * 24 + 1;
  4118. },
  4119. measureSingleLineOverflow(text, width) {
  4120. const w = Number(width) || 0;
  4121. if (!w || !text) return false;
  4122. const probe = document.createElement("span");
  4123. probe.style.position = "fixed";
  4124. probe.style.left = "-99999px";
  4125. probe.style.top = "0";
  4126. probe.style.display = "inline-block";
  4127. probe.style.maxWidth = w + "px";
  4128. probe.style.fontSize = "18px";
  4129. probe.style.lineHeight = "24px";
  4130. probe.style.whiteSpace = "nowrap";
  4131. probe.style.visibility = "hidden";
  4132. probe.textContent = text;
  4133. document.body.appendChild(probe);
  4134. const overflow = (probe.scrollWidth || 0) > (probe.clientWidth || w) + 1;
  4135. document.body.removeChild(probe);
  4136. return overflow;
  4137. },
  4138. // 功能:根据当前卡片宽度刷新「是否出现 ...」状态(用于控制命中区显示) by xu 20260109
  4139. refreshEllipsisVisible() {
  4140. try {
  4141. const right = this.$el?.querySelector?.(".right");
  4142. const rawWidth = right?.getBoundingClientRect?.().width || right?.clientWidth || 0;
  4143. const width = Math.max(0, Math.round(rawWidth)); // 修复:内容区不再使用 padding-right 预留,测量按真实宽度 by xu 20260109
  4144. const model = this.buildRightTextLines();
  4145. const next = {
  4146. secondSummary: false,
  4147. secondTags: false,
  4148. third: false,
  4149. thirdFull: false,
  4150. };
  4151. if (model.secondKind === "summary" && model.summary) {
  4152. next.secondSummary = this.measureTextOverflowByLines(model.summary, 3, width);
  4153. }
  4154. if (model.secondKind === "tags") {
  4155. // 第二部分 tags:只有最后一行允许出现 ...;超出行数或最后一行过长才认为会出现 ... by xu 20260109
  4156. next.secondTags =
  4157. (Array.isArray(model.secondTagsLinesFull) && model.secondTagsLinesFull.length > (model.secondTagsMaxLines || 3)) ||
  4158. this.measureSingleLineOverflow(model.secondTagsLast, width);
  4159. }
  4160. if (model.hasThird && !model.thirdFull) {
  4161. next.third = this.measureSingleLineOverflow(model.thirdText, width);
  4162. }
  4163. if (model.hasThird && model.thirdFull) {
  4164. next.thirdFull = this.measureTextOverflowByLines(model.thirdText, 4, width);
  4165. }
  4166. const prev = this.ellipsisVisible || {};
  4167. const changed =
  4168. prev.secondSummary !== next.secondSummary ||
  4169. prev.secondTags !== next.secondTags ||
  4170. prev.third !== next.third ||
  4171. prev.thirdFull !== next.thirdFull;
  4172. if (changed) this.ellipsisVisible = next;
  4173. } catch (e) {
  4174. // ignore by xu 20260109
  4175. }
  4176. },
  4177. showTextPopoverFor(el, kind) {
  4178. // 调试开关:window.__SS_LISTCARD_DEBUG__ = true 时打印 hover/溢出判断日志 by xu 20260108
  4179. const debug = typeof window !== "undefined" && !!window.__SS_LISTCARD_DEBUG__;
  4180. if (debug) {
  4181. console.log("[SsListCard] ellipsis hover", {
  4182. kind,
  4183. el: el?.className,
  4184. });
  4185. }
  4186. const model = this.buildRightTextLines();
  4187. const lineEl = el?.closest?.(".ss-card-text__line") || el;
  4188. const right = lineEl?.closest?.(".right") || el?.closest?.(".right");
  4189. const rawWidth = right?.getBoundingClientRect?.().width || right?.clientWidth || 0;
  4190. const width = Math.max(0, Math.round(rawWidth)); // 修复:内容区不再预留 padding-right,测量按真实宽度 by xu 20260109
  4191. const textEl =
  4192. kind === "second-summary"
  4193. ? lineEl?.querySelector?.(".ss-card-text__secondSummary")
  4194. : kind === "second-tags"
  4195. ? lineEl?.querySelector?.(".ss-card-text__tagLineLast")
  4196. : kind === "third"
  4197. ? lineEl?.querySelector?.(".ss-card-text__thirdLine")
  4198. : lineEl?.querySelector?.(".ss-card-text__thirdFull");
  4199. let payload = null;
  4200. // 仅当真实会出现 ... 时才允许 goheight(避免“没超出也能出 goheight”) by xu 20260109
  4201. const overflowed =
  4202. kind === "second-summary"
  4203. ? this.measureTextOverflowByLines(model.summary, 3, width)
  4204. : kind === "second-tags"
  4205. ? ((Array.isArray(model.secondTagsLinesFull) && model.secondTagsLinesFull.length > (model.secondTagsMaxLines || 3)) ||
  4206. this.measureSingleLineOverflow(model.secondTagsLast, width))
  4207. : kind === "third"
  4208. ? this.measureSingleLineOverflow(model.thirdText, width)
  4209. : this.measureTextOverflowByLines(model.thirdText, 4, width);
  4210. if (!overflowed) return;
  4211. if (kind === "second-summary") {
  4212. if (model.summary) payload = { kind, text: model.summary };
  4213. } else if (kind === "second-tags") {
  4214. if (Array.isArray(model.secondTagsLinesFull) && model.secondTagsLinesFull.length) {
  4215. payload = { kind, lines: model.secondTagsLinesFull };
  4216. }
  4217. } else if (kind === "third") {
  4218. if (model.thirdKind === "category" && Array.isArray(model.categoryLinesFull) && model.categoryLinesFull.length) {
  4219. payload = { kind, lines: model.categoryLinesFull }; // 功能:类目展开一条一行 by xu 20260109
  4220. } else if (model.thirdText) {
  4221. payload = { kind, text: model.thirdText };
  4222. }
  4223. } else if (kind === "third-full") {
  4224. if (model.thirdKind === "category" && Array.isArray(model.categoryLinesFull) && model.categoryLinesFull.length) {
  4225. payload = { kind, lines: model.categoryLinesFull }; // 功能:类目占满模式展开一条一行 by xu 20260109
  4226. } else if (model.thirdText) {
  4227. payload = { kind, text: model.thirdText };
  4228. }
  4229. }
  4230. if (debug) {
  4231. console.log("[SsListCard] ellipsis decide", {
  4232. kind,
  4233. rawWidth: Math.round(rawWidth),
  4234. width,
  4235. hasPayload: !!payload,
  4236. textEl: textEl?.className,
  4237. textClient: textEl ? { cw: textEl.clientWidth, ch: textEl.clientHeight, sw: textEl.scrollWidth, sh: textEl.scrollHeight } : null,
  4238. });
  4239. }
  4240. if (!payload) return;
  4241. this.clearHideTextPopoverTimer();
  4242. const container = lineEl?.closest?.(".right");
  4243. const containerRect = container?.getBoundingClientRect?.();
  4244. const lineRect = lineEl?.getBoundingClientRect?.();
  4245. if (containerRect && lineRect) {
  4246. const bottom = Math.max(0, Math.round(containerRect.bottom - lineRect.bottom));
  4247. this.textPopoverBottom = bottom;
  4248. } else {
  4249. this.textPopoverBottom = 0;
  4250. }
  4251. this.textPopoverPayload = payload;
  4252. this.textPopoverType = kind;
  4253. this.showTextPopover = true;
  4254. if (debug) console.log("[SsListCard] goheight show", payload);
  4255. },
  4256. isOverflowing(el) {
  4257. if (!el) return false;
  4258. // 单行/多行省略统一判断:scroll 尺寸大于 client 尺寸即认为有 ... by xu 20260108
  4259. return (el.scrollWidth && el.clientWidth && el.scrollWidth > el.clientWidth + 1) ||
  4260. (el.scrollHeight && el.clientHeight && el.scrollHeight > el.clientHeight + 1);
  4261. },
  4262. isSummaryOverflowing(el) {
  4263. if (!el) return false;
  4264. // -webkit-line-clamp 场景下 scrollHeight 不稳定,改用“无 clamp 的离屏测量”判断是否超过 2 行 by xu 20260108
  4265. const text = String(this.item?.desc ?? "").trim();
  4266. if (!text) return false;
  4267. const rect = el.getBoundingClientRect?.();
  4268. const width = rect?.width || el.clientWidth || 0;
  4269. if (!width) return false;
  4270. const probe = document.createElement("div");
  4271. probe.style.position = "fixed";
  4272. probe.style.left = "-99999px";
  4273. probe.style.top = "0";
  4274. probe.style.width = width + "px";
  4275. probe.style.fontSize = "18px";
  4276. probe.style.lineHeight = "24px";
  4277. probe.style.whiteSpace = "normal";
  4278. probe.style.wordBreak = "break-word";
  4279. probe.style.visibility = "hidden";
  4280. probe.textContent = text;
  4281. document.body.appendChild(probe);
  4282. const h = probe.getBoundingClientRect().height || 0;
  4283. document.body.removeChild(probe);
  4284. return h > 48 + 1;
  4285. },
  4286. clearHideTextPopoverTimer() {
  4287. if (this.hideTextPopoverTimer) {
  4288. clearTimeout(this.hideTextPopoverTimer);
  4289. this.hideTextPopoverTimer = null;
  4290. }
  4291. },
  4292. // 修复 goheight hover 无响应:移除重复方法覆盖,统一使用上面的 showTextPopoverFor(el, kind) by xu 20260109
  4293. hideTextPopoverLater() {
  4294. this.clearHideTextPopoverTimer();
  4295. this.hideTextPopoverTimer = setTimeout(() => {
  4296. this.showTextPopover = false;
  4297. this.textPopoverType = "";
  4298. this.textPopoverPayload = null;
  4299. }, 120);
  4300. },
  4301. hideTextPopover() {
  4302. this.clearHideTextPopoverTimer();
  4303. this.showTextPopover = false;
  4304. this.textPopoverType = "";
  4305. this.textPopoverPayload = null;
  4306. },
  4307. // 功能:新需求下不在 updated 内做测量,避免死循环 by xu 20260108
  4308. },
  4309. mounted() {
  4310. // 无需在 mounted/updated 里做 overflow 测量(避免死循环),只在 hover 触发时判断 by xu 20260108
  4311. // 仅用于控制“...命中区是否显示”,不会触发循环更新 by xu 20260109
  4312. this.$nextTick?.(() => {
  4313. requestAnimationFrame(() => this.refreshEllipsisVisible?.());
  4314. });
  4315. this.__ssListCardResizeHandler = () => this.refreshEllipsisVisible?.(); // 功能:窗口变化时刷新 ... 显示 by xu 20260109
  4316. window.addEventListener?.("resize", this.__ssListCardResizeHandler);
  4317. },
  4318. updated() {
  4319. // 卡片数据更新后刷新一次 ... 显示状态(避免“宽度/内容变了但命中区不变”) by xu 20260109
  4320. this.$nextTick?.(() => {
  4321. requestAnimationFrame(() => this.refreshEllipsisVisible?.());
  4322. });
  4323. },
  4324. beforeUnmount() {
  4325. // 清理 timer,避免残留导致异常 by xu 20260108
  4326. this.clearHideTextPopoverTimer?.();
  4327. if (this.__ssListCardResizeHandler) {
  4328. window.removeEventListener?.("resize", this.__ssListCardResizeHandler);
  4329. this.__ssListCardResizeHandler = null;
  4330. }
  4331. },
  4332. render() {
  4333. const SsCartListIcon = Vue.resolveComponent("ss-cart-list-icon");
  4334. const SsIcon = Vue.resolveComponent("ss-icon");
  4335. const hasThumbArea = !!(this.item?.thumb || this.item?.thumbType); // 功能:无图但有 thumbType 时仍保留占位 by xu 20260109
  4336. return Vue.h(
  4337. "div",
  4338. {
  4339. class: {
  4340. "knowledge-item-container": true,
  4341. active: this.item.active,
  4342. [this.cardType]: !!this.cardType, // 动态添加卡片类型类名 by xu 20260105
  4343. [this.statusClass] : !!this.statusClass
  4344. },
  4345. onClick: (e) => {
  4346. this.onItemClick?.(e);
  4347. if (this.cardClickAction === "single") {
  4348. this.toggleSelectExclusive?.(e);
  4349. }
  4350. }, // 功能:卡片主体点击动作(view/single) by xu 20260109
  4351. // 移除固定宽度,由 CSS min-width 控制 by xu 20260105
  4352. },
  4353. [
  4354. // 右上角状态图标区域 by xu 20260105
  4355. this.item?.statusIcons?.length > 0 &&
  4356. Vue.h(
  4357. "div",
  4358. { class: "card-status-icons" },
  4359. this.item.statusIcons.map((icon) =>
  4360. Vue.h(SsIcon, {
  4361. class: `status-icon ${icon.class}`,
  4362. title: icon.title,
  4363. })
  4364. )
  4365. ),
  4366. this.item?.buttons?.length > 0 &&
  4367. Vue.h(
  4368. "div",
  4369. {
  4370. class: "header",
  4371. style: this.item?.statusIcons?.length > 0
  4372. ? {
  4373. right: `${this.item.statusIcons.length * 48}px`,
  4374. borderTopRightRadius: '0'
  4375. }
  4376. : {},
  4377. onMouseenter: () => (this.showButtons = true),
  4378. onMouseleave: () => (this.showButtons = false),
  4379. onClick: (e) => this.onItemChange(e, this.item.buttons[0], 0),
  4380. },
  4381. [
  4382. // 只在有按钮时渲染设置图标
  4383. // this.item?.buttons?.length > 0 &&
  4384. Vue.h("div", {
  4385. class: "cart-list-setting cart-list-icon",
  4386. title: this.item?.buttons?.[0]?.title,
  4387. }),
  4388. // 鼠标移入时显示按钮列表,与图标同级
  4389. // this.item?.buttons?.length > 0 &&
  4390. this.showButtons &&
  4391. this.item?.buttons?.length > 1 &&
  4392. Vue.h(
  4393. "div",
  4394. {
  4395. class: "cart-list-button-popup",
  4396. },
  4397. this.item.buttons.map((btn) =>
  4398. Vue.h(
  4399. "div",
  4400. {
  4401. onClick: (e) => {
  4402. e.stopPropagation();
  4403. btn.onclick?.();
  4404. },
  4405. },
  4406. [
  4407. // 如果有 class,显示对应的图标
  4408. btn.class &&
  4409. Vue.h(SsCartListIcon, {
  4410. class: [btn.class],
  4411. }),
  4412. // 显示按钮文本
  4413. Vue.h("span", null, btn.title),
  4414. ]
  4415. )
  4416. )
  4417. ),
  4418. ]
  4419. ),
  4420. Vue.h("div", { class: "body" }, [
  4421. Vue.h("div", { class: "box-header" }, [
  4422. Vue.h("div", `${this.item.title}`),
  4423. ]),
  4424. Vue.h(
  4425. "div",
  4426. {
  4427. class: !hasThumbArea ? "no-thumb box-body" : "box-body",
  4428. },
  4429. [
  4430. hasThumbArea
  4431. ? this.item.thumb
  4432. ? Vue.h("div", { class: "left" }, [
  4433. Vue.h("img", {
  4434. src: this.item.thumb,
  4435. alt: "Thumbnail",
  4436. class: "imgUnHandle",
  4437. style: {
  4438. "object-fit": "cover",
  4439. width: "100%",
  4440. height: "100%",
  4441. },
  4442. }),
  4443. ])
  4444. : Vue.h( // 功能:无图占位(ss-icon + biz icon,居中) by xu 20260109
  4445. "div",
  4446. { class: "left ss-objlist-thumbPlaceholder" },
  4447. [
  4448. Vue.h(SsIcon, {
  4449. class: `${this.getBizThumbIconClass()} ss-objlist-thumbIcon`,
  4450. }),
  4451. ]
  4452. )
  4453. : null,
  4454. Vue.h(
  4455. "div",
  4456. {
  4457. class: "right",
  4458. },
  4459. (() => {
  4460. const model = this.buildRightTextLines(); // 功能:右侧文字区新规则(第二部分/第三部分优先级) by xu 20260108
  4461. const hasAny = !!(model?.hasSecond || model?.hasThird);
  4462. if (!hasAny) return [];
  4463. const children = [];
  4464. // 第二部分:L1-L3(摘要优先,其次 tags;不足留空;超出 L3 ...) by xu 20260108
  4465. if (model.hasSecond) {
  4466. if (model.secondKind === "summary") {
  4467. children.push(
  4468. Vue.h("div", { class: "ss-card-text__line ss-card-text__secondBlock" }, [
  4469. Vue.h("div", { class: "ss-card-text__secondSummary", title: model.summary }, model.summary),
  4470. Vue.h("span", {
  4471. class: ["ss-card-text__ellipsisHit", "ss-card-text__ellipsisHit--second", this.ellipsisVisible?.secondSummary ? "is-on" : ""],
  4472. title: "查看完整摘要",
  4473. onMouseenter: (e) => this.showTextPopoverFor(e?.currentTarget, "second-summary"),
  4474. onClick: (e) => { e?.stopPropagation?.(); this.showTextPopoverFor(e?.currentTarget, "second-summary"); }, // 功能:点击 ... 也可展开(避免 hover 受遮挡) by xu 20260109
  4475. onMouseleave: () => this.hideTextPopoverLater(),
  4476. }),
  4477. ])
  4478. );
  4479. } else if (model.secondKind === "tags") {
  4480. children.push(
  4481. Vue.h("div", { class: ["ss-card-text__line", model.secondFull ? "ss-card-text__secondFullBlock" : "ss-card-text__secondBlock"] }, [ // 功能:仅标签时占满 4 行 by xu 20260109
  4482. Vue.h(
  4483. "div",
  4484. { class: "ss-card-text__secondTags" },
  4485. [
  4486. ...model.secondTagsHead.map((t) =>
  4487. Vue.h("div", { class: "ss-card-text__tagLine", title: t }, t)
  4488. ),
  4489. // 第三行:平铺剩余(可能为空) by xu 20260108
  4490. Vue.h("div", { class: "ss-card-text__tagLine is-last ss-card-text__tagLineLast", title: model.secondTagsLast }, model.secondTagsLast),
  4491. ].filter(Boolean)
  4492. ),
  4493. // 只在最后一行出现 ... 时才触发 goheight by xu 20260108
  4494. Vue.h("span", {
  4495. class: ["ss-card-text__ellipsisHit", "ss-card-text__ellipsisHit--second", this.ellipsisVisible?.secondTags ? "is-on" : ""],
  4496. title: "查看完整物品参数",
  4497. onMouseenter: (e) => this.showTextPopoverFor(e?.currentTarget, "second-tags"),
  4498. onClick: (e) => { e?.stopPropagation?.(); this.showTextPopoverFor(e?.currentTarget, "second-tags"); }, // 功能:点击 ... 也可展开(避免 hover 受遮挡) by xu 20260109
  4499. onMouseleave: () => this.hideTextPopoverLater(),
  4500. }),
  4501. ])
  4502. );
  4503. }
  4504. }
  4505. // 第三部分:默认 L4;第二部分为空则占满 L1-L4 by xu 20260108
  4506. if (model.hasThird) {
  4507. if (model.thirdFull) {
  4508. children.push(
  4509. Vue.h("div", { class: "ss-card-text__line ss-card-text__thirdFullBlock" }, [
  4510. Vue.h("div", { class: "ss-card-text__thirdFull", title: model.thirdText }, model.thirdText),
  4511. Vue.h("span", {
  4512. class: ["ss-card-text__ellipsisHit", "ss-card-text__ellipsisHit--third", this.ellipsisVisible?.thirdFull ? "is-on" : ""],
  4513. title: "查看完整信息",
  4514. onMouseenter: (e) => this.showTextPopoverFor(e?.currentTarget, "third-full"),
  4515. onClick: (e) => { e?.stopPropagation?.(); this.showTextPopoverFor(e?.currentTarget, "third-full"); }, // 功能:点击 ... 也可展开(避免 hover 受遮挡) by xu 20260109
  4516. onMouseleave: () => this.hideTextPopoverLater(),
  4517. }),
  4518. ])
  4519. );
  4520. } else {
  4521. children.push(
  4522. Vue.h("div", { class: "ss-card-text__line ss-card-text__thirdLineWrap" }, [
  4523. Vue.h("div", { class: "ss-card-text__thirdLine", title: model.thirdText }, model.thirdText),
  4524. Vue.h("span", {
  4525. class: ["ss-card-text__ellipsisHit", "ss-card-text__ellipsisHit--third", this.ellipsisVisible?.third ? "is-on" : ""],
  4526. title: "查看完整信息",
  4527. onMouseenter: (e) => this.showTextPopoverFor(e?.currentTarget, "third"),
  4528. onClick: (e) => { e?.stopPropagation?.(); this.showTextPopoverFor(e?.currentTarget, "third"); }, // 功能:点击 ... 也可展开(避免 hover 受遮挡) by xu 20260109
  4529. onMouseleave: () => this.hideTextPopoverLater(),
  4530. }),
  4531. ])
  4532. );
  4533. }
  4534. }
  4535. // hover 展开浮层:宽度=右侧文字区,底对齐向上展开,带阴影 by xu 20260108
  4536. // popover 作为 `.right` 的 sibling 渲染,避免被 `.ss-card-text{overflow:hidden}` 裁剪 by xu 20260108
  4537. const popover =
  4538. this.showTextPopover &&
  4539. Vue.h(
  4540. "div",
  4541. {
  4542. class: "ss-card-text-popover",
  4543. style: { bottom: this.textPopoverBottom + "px" },
  4544. onMouseenter: () => {
  4545. this.clearHideTextPopoverTimer();
  4546. this.showTextPopover = true;
  4547. },
  4548. onMouseleave: () => this.hideTextPopoverLater(),
  4549. },
  4550. (() => {
  4551. const p = this.textPopoverPayload || {};
  4552. if (p.kind === "second-summary" && p.text) {
  4553. return [Vue.h("div", { class: "ss-card-text-popover__summary" }, p.text)];
  4554. }
  4555. if (Array.isArray(p.lines)) {
  4556. return [
  4557. Vue.h(
  4558. "div",
  4559. { class: "ss-card-text-popover__kvlist" },
  4560. p.lines.map((t) => Vue.h("div", { class: "ss-card-text-popover__kv" }, t))
  4561. ),
  4562. ];
  4563. }
  4564. if ((p.kind === "third" || p.kind === "third-full") && p.text) {
  4565. return [Vue.h("div", { class: "ss-card-text-popover__objno" }, p.text)];
  4566. }
  4567. return [];
  4568. })()
  4569. );
  4570. return [
  4571. Vue.h("div", { class: "ss-card-text" }, children),
  4572. popover,
  4573. ];
  4574. })()
  4575. ),
  4576. ]
  4577. ),
  4578. ]),
  4579. // 右下角卡片选择图标 by xu 20260105
  4580. Vue.h(SsIcon, {
  4581. class: this.item?._ssSelected ? "card-icon icon-cardChk-on" : "card-icon icon-cardChk",
  4582. onClick: this.toggleSelect,
  4583. }),
  4584. // 选中后底部线条 by xu 20260105
  4585. this.item?._ssSelected && Vue.h("div", { class: "select-bottom-line" }),
  4586. ]
  4587. );
  4588. },
  4589. };
  4590. // ss-sidebar 右侧边栏(容器 + 子组件),用于 objList 右侧区域 by xu 20260106
  4591. // 组件文档补全(JSDoc) by xu 20260108
  4592. /**
  4593. * SsSidebarButtons(右侧边栏顶部按钮栏)
  4594. *
  4595. * 用途:
  4596. * - 渲染 objList 右侧顶部快捷操作(预定/入住/退房/清洁...)
  4597. * - 内部复用 `ss-search-button`(项目现有按钮样式/交互)
  4598. *
  4599. * 调用示例:
  4600. * ```html
  4601. * <ss-sidebar-buttons :items="sidebarButtons" />
  4602. * ```
  4603. *
  4604. * Props:
  4605. * - `items`: 按钮配置数组
  4606. * - `{ id, text, icon?, onClick? }`
  4607. *
  4608. * Emits:
  4609. * - `click`:点击按钮时触发,参数为按钮对象
  4610. */
  4611. const SsSidebarButtons = {
  4612. name: "SsSidebarButtons",
  4613. props: {
  4614. items: { type: Array, default: () => [] },
  4615. },
  4616. emits: ["click"],
  4617. render() {
  4618. const SsSearchButton = Vue.resolveComponent("ss-search-button");
  4619. const items = this.items || [];
  4620. if (!items.length) return null;
  4621. return Vue.h(
  4622. "div",
  4623. { class: "ss-sidebar-actions" },
  4624. items.map((btn) =>
  4625. // 顶部操作按钮复用 ss-search-button(先 mock 固定按钮) by xu 20260106
  4626. Vue.h(SsSearchButton, {
  4627. text: btn?.text ?? "",
  4628. iconClass: btn?.iconClass ?? "",
  4629. opt: btn?.opt ?? [],
  4630. checkId: btn?.checkId ?? "0",
  4631. width: btn?.width,
  4632. id: btn?.id,
  4633. onClick: (e) => {
  4634. e?.stopPropagation?.();
  4635. btn?.onClick?.(btn);
  4636. this.$emit("click", btn);
  4637. },
  4638. })
  4639. )
  4640. );
  4641. },
  4642. };
  4643. // 组件文档补全(JSDoc) by xu 20260108
  4644. /**
  4645. * SsSidebarChart(ECharts 容器渲染)
  4646. *
  4647. * 用途:
  4648. * - 仅负责 echarts init / setOption / resize / dispose
  4649. * - 被 `ss-sidebar-chart-hover` 与图表面板复用
  4650. *
  4651. * 调用示例:
  4652. * ```html
  4653. * <ss-sidebar-chart :options="option" height="220px" />
  4654. * ```
  4655. *
  4656. * Props:
  4657. * - `options`:ECharts option(Object)
  4658. * - `height`:容器高度(String)
  4659. */
  4660. const SsSidebarChart = {
  4661. name: "SsSidebarChart",
  4662. props: {
  4663. options: { type: Object, default: () => ({}) },
  4664. height: { type: String, default: "200px" },
  4665. },
  4666. setup(props) {
  4667. const elRef = Vue.ref(null);
  4668. let chart = null;
  4669. const renderChart = () => {
  4670. if (!elRef.value || !window.echarts) return;
  4671. if (!chart) {
  4672. chart = window.echarts.init(elRef.value);
  4673. }
  4674. chart.setOption(props.options || {}, true);
  4675. };
  4676. const resizeChart = () => {
  4677. chart?.resize?.();
  4678. };
  4679. Vue.onMounted(() => {
  4680. renderChart();
  4681. window.addEventListener("resize", resizeChart);
  4682. });
  4683. Vue.onBeforeUnmount(() => {
  4684. window.removeEventListener("resize", resizeChart);
  4685. chart?.dispose?.();
  4686. chart = null;
  4687. });
  4688. Vue.watch(
  4689. () => props.options,
  4690. () => {
  4691. renderChart();
  4692. },
  4693. { deep: true }
  4694. );
  4695. return { elRef };
  4696. },
  4697. render() {
  4698. return Vue.h("div", {
  4699. ref: "elRef",
  4700. style: {
  4701. width: "100%",
  4702. height: this.height,
  4703. // 图表容器不加 padding/border,由外层布局控制 by xu 20260106
  4704. background: "transparent",
  4705. border: "none",
  4706. "border-radius": "0",
  4707. },
  4708. });
  4709. },
  4710. };
  4711. // ss-sidebar-chart-hover:hover 弹出左侧大图(支持图钉/全屏) by xu 20260106
  4712. // 组件文档补全(JSDoc) by xu 20260108
  4713. /**
  4714. * SsSidebarChartHover(小图 + hover 左侧大图预览 + 图钉固定 + 全屏)
  4715. *
  4716. * 用途:
  4717. * - 右侧统计图小卡片:hover 时在左侧弹出大图预览
  4718. * - 预览头部:左侧图标+标题;右侧固定/全屏按钮(icon-base)
  4719. * - 全屏:方案A(浏览器 Fullscreen API)
  4720. *
  4721. * 调用示例(由 ss-sidebar chart panel 内部调用):
  4722. * ```html
  4723. * <ss-sidebar-chart-hover
  4724. * title="校舍建筑面积和总体分布"
  4725. * icon-class="menu-icon icon-obj-jzw"
  4726. * :options="option"
  4727. * height="220px"
  4728. * />
  4729. * ```
  4730. *
  4731. * Props:
  4732. * - `title/iconClass/icon`:用于预览/全屏 header 显示(与面板 header 一致)
  4733. * - `options`:ECharts option
  4734. * - `height`:小图高度
  4735. * - `previewWidth/previewHeight`:预览建议尺寸(会按视口自适应)
  4736. */
  4737. const SsSidebarChartHover = {
  4738. name: "SsSidebarChartHover",
  4739. props: {
  4740. // hover 大图标题/图标(与小图面板 header 一致) by xu 20260108
  4741. title: { type: String, default: "" },
  4742. iconClass: { type: String, default: "" },
  4743. icon: { type: String, default: "" },
  4744. options: { type: Object, default: () => ({}) },
  4745. height: { type: String, default: "220px" },
  4746. // hover 弹窗建议尺寸:约 1000x650 by xu 20260108
  4747. previewWidth: { type: Number, default: 1000 },
  4748. previewHeight: { type: Number, default: 650 },
  4749. },
  4750. setup(props) {
  4751. const triggerRef = Vue.ref(null);
  4752. const fullscreenRef = Vue.ref(null);
  4753. const open = Vue.ref(false);
  4754. const pinned = Vue.ref(false);
  4755. const fullscreen = Vue.ref(false);
  4756. const hoveringTrigger = Vue.ref(false);
  4757. const hoveringPreview = Vue.ref(false);
  4758. const previewStyle = Vue.ref({});
  4759. let closeTimer = null;
  4760. const updatePreviewPosition = () => {
  4761. const el = triggerRef.value;
  4762. if (!el) return;
  4763. const rect = el.getBoundingClientRect();
  4764. const vw = window.innerWidth;
  4765. const vh = window.innerHeight;
  4766. // 预览窗尺寸:优先用 props 的建议值,但确保距离视口边缘留空 by xu 20260108
  4767. const viewportPaddingX = 40;
  4768. const viewportPaddingY = 60;
  4769. const width = Math.min(props.previewWidth, Math.max(320, vw - viewportPaddingX));
  4770. const height = Math.min(props.previewHeight, Math.max(240, vh - viewportPaddingY));
  4771. // 默认贴着小图左侧弹出,右边缘与小图左边缘轻微重叠,避免 1px 缝隙导致 hover 闪断 by xu 20260108
  4772. const overlap = 2;
  4773. const gapFromSidebar = 14; // 功能说明:弹窗与右侧边栏留出距离(更不贴近) by xu 20260108
  4774. let left = rect.left - width - gapFromSidebar + overlap;
  4775. // 如果左侧空间不足,则贴右侧(兜底,同样重叠) by xu 20260108
  4776. if (left < 0) left = rect.right + gapFromSidebar - overlap;
  4777. left = Math.max(0, Math.min(left, vw - width));
  4778. // top 对齐 header 顶部:向上查找 .ss-sidebar-panel__header 元素 by xu 20260108
  4779. const viewportPaddingTop = 20;
  4780. const viewportPaddingBottom = 10; // 功能说明:弹窗 bottom 留 10px 左右 by xu 20260108
  4781. let headerEl = el;
  4782. while (headerEl && !headerEl.classList?.contains("ss-sidebar-panel")) {
  4783. headerEl = headerEl.parentElement;
  4784. }
  4785. let headerRect = headerEl?.querySelector(".ss-sidebar-panel__header")?.getBoundingClientRect();
  4786. let top = headerRect?.top ?? rect.top;
  4787. top = Math.max(viewportPaddingTop, Math.min(top, vh - height - viewportPaddingBottom));
  4788. previewStyle.value = {
  4789. position: "fixed",
  4790. left: `${Math.round(left)}px`,
  4791. top: `${Math.round(top)}px`,
  4792. width: `${width}px`,
  4793. height: `${height}px`,
  4794. zIndex: 3000,
  4795. };
  4796. };
  4797. const clearCloseTimer = () => {
  4798. if (closeTimer) {
  4799. clearTimeout(closeTimer);
  4800. closeTimer = null;
  4801. }
  4802. };
  4803. const scheduleClose = () => {
  4804. clearCloseTimer();
  4805. if (pinned.value || fullscreen.value) return;
  4806. if (hoveringTrigger.value || hoveringPreview.value) return; // 功能:鼠标在小图/大图之间移动不关闭 by xu 20260108
  4807. closeTimer = setTimeout(() => {
  4808. open.value = false;
  4809. }, 100);
  4810. };
  4811. const openPreview = () => {
  4812. clearCloseTimer();
  4813. updatePreviewPosition();
  4814. open.value = true;
  4815. };
  4816. const togglePin = () => {
  4817. pinned.value = !pinned.value;
  4818. if (pinned.value) {
  4819. open.value = true;
  4820. updatePreviewPosition();
  4821. }
  4822. };
  4823. const toggleFullscreen = () => {
  4824. // 全屏:采用浏览器 Fullscreen API(方案A),不使用遮罩弹窗 by xu 20260108
  4825. if (!fullscreen.value) {
  4826. open.value = false; // 避免同时渲染预览与全屏 by xu 20260108
  4827. fullscreen.value = true;
  4828. Vue.nextTick(() => {
  4829. const el = fullscreenRef.value;
  4830. if (el?.requestFullscreen) {
  4831. el.requestFullscreen().catch(() => {
  4832. // requestFullscreen 失败则回退为非全屏状态 by xu 20260108
  4833. fullscreen.value = false;
  4834. });
  4835. } else {
  4836. fullscreen.value = false;
  4837. }
  4838. });
  4839. } else {
  4840. if (document?.exitFullscreen) {
  4841. document.exitFullscreen().catch(() => {});
  4842. }
  4843. }
  4844. };
  4845. const handleFullscreenChange = () => {
  4846. const isFs = !!document.fullscreenElement;
  4847. fullscreen.value = isFs; // 功能说明:同步 ESC/系统退出全屏状态 by xu 20260108
  4848. if (isFs) {
  4849. open.value = false;
  4850. clearCloseTimer();
  4851. return;
  4852. }
  4853. // 退出全屏后:若固定或仍 hover,则恢复预览,否则关闭 by xu 20260108
  4854. if (pinned.value || hoveringTrigger.value || hoveringPreview.value) {
  4855. open.value = true;
  4856. updatePreviewPosition();
  4857. } else {
  4858. open.value = false;
  4859. }
  4860. };
  4861. Vue.onMounted(() => {
  4862. window.addEventListener("resize", updatePreviewPosition);
  4863. window.addEventListener("scroll", updatePreviewPosition, true);
  4864. document.addEventListener("fullscreenchange", handleFullscreenChange); // 功能说明:监听全屏状态变化 by xu 20260108
  4865. });
  4866. Vue.onBeforeUnmount(() => {
  4867. clearCloseTimer();
  4868. window.removeEventListener("resize", updatePreviewPosition);
  4869. window.removeEventListener("scroll", updatePreviewPosition, true);
  4870. document.removeEventListener("fullscreenchange", handleFullscreenChange);
  4871. });
  4872. return {
  4873. triggerRef,
  4874. fullscreenRef,
  4875. open,
  4876. pinned,
  4877. fullscreen,
  4878. hoveringTrigger,
  4879. hoveringPreview,
  4880. previewStyle,
  4881. openPreview,
  4882. scheduleClose,
  4883. clearCloseTimer,
  4884. togglePin,
  4885. toggleFullscreen,
  4886. };
  4887. },
  4888. render() {
  4889. const SsIcon = Vue.resolveComponent("ss-icon");
  4890. const Chart = Vue.resolveComponent("ss-sidebar-chart");
  4891. const hasHeader = !!(this.title || this.iconClass || this.icon); // 功能:hover 大图显示左侧图标+标题 by xu 20260108
  4892. const previewContent = Vue.h(
  4893. "div",
  4894. {
  4895. class: { "ss-sidebar-chart-preview": true, "is-pinned": this.pinned },
  4896. style: this.previewStyle,
  4897. onMouseenter: () => {
  4898. this.hoveringPreview = true;
  4899. this.clearCloseTimer();
  4900. },
  4901. onMouseleave: () => {
  4902. this.hoveringPreview = false;
  4903. this.scheduleClose();
  4904. },
  4905. },
  4906. [
  4907. hasHeader
  4908. ? Vue.h("div", { class: "ss-sidebar-panel__header ss-sidebar-chart-preview__header" }, [
  4909. Vue.h("div", { class: "ss-sidebar-panel__title" }, [
  4910. this.iconClass
  4911. ? Vue.h(SsIcon, { class: this.iconClass + " ss-sidebar-panel__icon" })
  4912. : this.icon
  4913. ? Vue.h(SsIcon, { name: this.icon, size: "16px", class: "ss-sidebar-panel__icon" })
  4914. : null,
  4915. Vue.h("span", null, this.title || "统计图"),
  4916. ]),
  4917. Vue.h("div", { class: "ss-sidebar-panel__tools" }, [
  4918. Vue.h(
  4919. "button",
  4920. {
  4921. type: "button",
  4922. class: { "ss-sidebar-chart-tool": true, "is-active": this.pinned },
  4923. title: this.pinned ? "取消固定" : "固定",
  4924. onClick: (e) => {
  4925. e.stopPropagation();
  4926. this.togglePin();
  4927. },
  4928. },
  4929. // 固定图标:未固定 icon-fix,固定 icon-fix-bold(icon-base) by xu 20260108
  4930. [Vue.h(SsIcon, { class: this.pinned ? "menu-base-icon icon-fix-bold" : "menu-base-icon icon-fix" })]
  4931. ),
  4932. Vue.h(
  4933. "button",
  4934. {
  4935. type: "button",
  4936. class: "ss-sidebar-chart-tool",
  4937. title: "全屏",
  4938. onClick: (e) => {
  4939. e.stopPropagation();
  4940. this.toggleFullscreen();
  4941. },
  4942. },
  4943. // 全屏图标:未展开 icon-chk,展开 icon-chk-on(icon-base) by xu 20260108
  4944. [Vue.h(SsIcon, { class: this.fullscreen ? "menu-base-icon icon-tuichuquanping" : "menu-base-icon icon-a-quanping_xi" })]
  4945. ),
  4946. ]),
  4947. ])
  4948. : Vue.h("div", { class: "ss-sidebar-chart-preview__header ss-sidebar-chart-preview__header--simple" }, [
  4949. Vue.h("div", { class: "ss-sidebar-panel__tools" }, [
  4950. Vue.h(
  4951. "button",
  4952. {
  4953. type: "button",
  4954. class: { "ss-sidebar-chart-tool": true, "is-active": this.pinned },
  4955. title: this.pinned ? "取消固定" : "固定",
  4956. onClick: (e) => {
  4957. e.stopPropagation();
  4958. this.togglePin();
  4959. },
  4960. },
  4961. // 固定图标:未固定 icon-fix,固定 icon-fix-bold(icon-base) by xu 20260108
  4962. [Vue.h(SsIcon, { class: this.pinned ? "menu-base-icon icon-fix-bold" : "menu-base-icon icon-fix" })]
  4963. ),
  4964. Vue.h(
  4965. "button",
  4966. {
  4967. type: "button",
  4968. class: "ss-sidebar-chart-tool",
  4969. title: "全屏",
  4970. onClick: (e) => {
  4971. e.stopPropagation();
  4972. this.toggleFullscreen();
  4973. },
  4974. },
  4975. // 全屏图标:未展开 icon-chk,展开 icon-chk-on(icon-base) by xu 20260108
  4976. [Vue.h(SsIcon, { class: this.fullscreen ? "menu-base-icon icon-chk-on" : "menu-base-icon icon-chk" })]
  4977. ),
  4978. ]),
  4979. ]),
  4980. Vue.h("div", { class: "ss-sidebar-chart-preview__body" }, [
  4981. Vue.h(Chart, { options: this.options, height: "100%" }),
  4982. ]),
  4983. ]
  4984. );
  4985. const fullscreenContent =
  4986. this.fullscreen &&
  4987. Vue.h(
  4988. "div",
  4989. {
  4990. ref: "fullscreenRef",
  4991. class: "ss-sidebar-chart-fullscreen",
  4992. },
  4993. [
  4994. Vue.h("div", { class: "ss-sidebar-panel__header ss-sidebar-chart-fullscreen__header" }, [
  4995. Vue.h("div", { class: "ss-sidebar-panel__title" }, [
  4996. this.iconClass
  4997. ? Vue.h(SsIcon, { class: this.iconClass + " ss-sidebar-panel__icon" })
  4998. : this.icon
  4999. ? Vue.h(SsIcon, { name: this.icon, size: "16px", class: "ss-sidebar-panel__icon" })
  5000. : null,
  5001. Vue.h("span", null, this.title || "统计图"),
  5002. ]),
  5003. Vue.h("div", { class: "ss-sidebar-panel__tools" }, [
  5004. Vue.h(
  5005. "button",
  5006. {
  5007. type: "button",
  5008. class: { "ss-sidebar-chart-tool": true, "is-active": this.pinned },
  5009. title: this.pinned ? "取消固定" : "固定",
  5010. onClick: (e) => {
  5011. e.stopPropagation();
  5012. this.togglePin();
  5013. },
  5014. },
  5015. [Vue.h(SsIcon, { class: this.pinned ? "menu-base-icon icon-fix-bold" : "menu-base-icon icon-fix" })]
  5016. ),
  5017. Vue.h(
  5018. "button",
  5019. {
  5020. type: "button",
  5021. class: "ss-sidebar-chart-tool",
  5022. title: "退出全屏",
  5023. onClick: (e) => {
  5024. e.stopPropagation();
  5025. this.toggleFullscreen();
  5026. },
  5027. },
  5028. [Vue.h(SsIcon, { class: "menu-base-icon icon-tuichuquanping" })]
  5029. ),
  5030. ]),
  5031. ]),
  5032. Vue.h("div", { class: "ss-sidebar-chart-fullscreen__body" }, [
  5033. Vue.h(Chart, { options: this.options, height: "100%" }),
  5034. ]),
  5035. ]
  5036. );
  5037. return Vue.h("div", { class: "ss-sidebar-chart-hover" }, [
  5038. Vue.h(
  5039. "div",
  5040. {
  5041. ref: "triggerRef",
  5042. class: "ss-sidebar-chart-hover__trigger",
  5043. onMouseenter: () => {
  5044. this.hoveringTrigger = true;
  5045. this.openPreview();
  5046. },
  5047. onMouseleave: () => {
  5048. this.hoveringTrigger = false;
  5049. this.scheduleClose();
  5050. },
  5051. },
  5052. [Vue.h(Chart, { options: this.options, height: this.height })]
  5053. ),
  5054. (this.open || this.fullscreen) &&
  5055. Vue.h(Vue.Teleport, { to: "body" }, [
  5056. this.open ? previewContent : null,
  5057. fullscreenContent || null,
  5058. ]),
  5059. ]);
  5060. },
  5061. };
  5062. // 组件文档补全(JSDoc) by xu 20260108
  5063. /**
  5064. * SsSidebarList(右侧业务面板:人员/已选/服务/预定...)
  5065. *
  5066. * 用途:
  5067. * - 统一渲染面板 header(图标/标题/数量/右侧按钮)
  5068. * - 统一渲染 list(固定行高、hover、右侧移除按钮等)
  5069. *
  5070. * 调用示例(由 ss-sidebar 通过 panels 配置驱动):
  5071. * ```js
  5072. * { type:'list', title:'已选', iconClass:'menu-icon icon-obj-xcd', mode:'selected', items:selectedItems, closable:true }
  5073. * ```
  5074. *
  5075. * Props(核心):
  5076. * - `title`:header 标题
  5077. * - `iconClass/icon`:header 图标(优先 iconClass)
  5078. * - `count`:数量回显(图表面板可不传)
  5079. * - `closable`:是否显示“清空”按钮(触发 emit clear)
  5080. * - `headerFilters`:header 条件数组(组件名 + props),用于联调接口搜索
  5081. * - `headerSearchButton`:是否显示搜索按钮(触发 emit search)
  5082. * - `items`:列表数据
  5083. * - `mode`:`selected` 时右侧按钮语义为“移除”
  5084. * - `itemLayout`:`simple` / `person`(人员号槽位)
  5085. * - `itemAction`:是否显示 item 右侧操作按钮(hover 才出现)
  5086. *
  5087. * Emits:
  5088. * - `remove(item)`:点击 item 右侧移除
  5089. * - `clear()`:点击 header 清空
  5090. * - `search({keyword, filters})`:点击 header 搜索
  5091. */
  5092. const SsSidebarList = {
  5093. name: "SsSidebarList",
  5094. props: {
  5095. title: { type: String, default: "" },
  5096. // header 图标:优先使用 iconClass(走 ss-icon v3.0 class 分支) by xu 20260106
  5097. iconClass: { type: String, default: "" },
  5098. icon: { type: String, default: "" }, // 兼容旧写法(ss-icon name)
  5099. count: { type: [Number, String], default: "" },
  5100. // 选中类分区:右侧关闭按钮=清空分区数据 by xu 20260106
  5101. closable: { type: Boolean, default: false },
  5102. searchable: { type: Boolean, default: false },
  5103. // 搜索框是否放在 header 内(人员块需要该布局) by xu 20260106
  5104. searchInHeader: { type: Boolean, default: false },
  5105. // header 搜索:下拉条件 + 搜索按钮(适合“人员”块) by xu 20260106
  5106. headerFilters: { type: Array, default: () => [] },
  5107. headerSearchButton: { type: Boolean, default: false },
  5108. searchPlaceholder: { type: String, default: "搜索" },
  5109. // 列表项布局:simple(仅标题) / person(标题+人员号槽位) by xu 20260106
  5110. itemLayout: { type: String, default: "simple" },
  5111. itemAction: { type: Boolean, default: true },
  5112. items: { type: Array, default: () => [] },
  5113. mode: { type: String, default: "search" }, // search / selected
  5114. },
  5115. emits: ["select", "remove", "clear", "search"],
  5116. data() {
  5117. return { keyword: "", filterValues: {} };
  5118. },
  5119. created() {
  5120. // header 下拉条件默认值初始化 by xu 20260106
  5121. (this.headerFilters || []).forEach((f) => {
  5122. if (!f || !f.key) return;
  5123. if (this.filterValues[f.key] !== undefined) return;
  5124. const first = f?.options?.[0]?.value ?? "";
  5125. this.filterValues[f.key] = f.value !== undefined ? f.value : first;
  5126. });
  5127. },
  5128. render() {
  5129. const items = this.items || [];
  5130. const SsIcon = Vue.resolveComponent("ss-icon");
  5131. const isSelectedMode = this.mode === "selected";
  5132. const activeKeyword = this.filterValues?.keyword ?? this.keyword; // 功能:keyword 优先取 headerFilters.keyword by xu 20260106
  5133. const hasHeaderKeyword = (this.headerFilters || []).some((f) => f?.key === "keyword"); // 功能:header 内 keyword 过滤 by xu 20260106
  5134. const renderHeaderFilter = (f) => {
  5135. if (!f) return null;
  5136. const key = f.key;
  5137. const componentName = f.component;
  5138. if (!key || !componentName) return null;
  5139. const Comp = Vue.resolveComponent(componentName);
  5140. if (!Comp) return null;
  5141. const modelValue = this.filterValues[key];
  5142. const props = f.props || {};
  5143. return Vue.h(Comp, {
  5144. ...props,
  5145. modelValue,
  5146. "onUpdate:modelValue": (v) => {
  5147. this.filterValues[key] = v;
  5148. },
  5149. });
  5150. };
  5151. const filteredItems =
  5152. this.searchable && activeKeyword
  5153. ? items.filter((it) =>
  5154. String(it?.title ?? "")
  5155. .toLowerCase()
  5156. .includes(String(activeKeyword).toLowerCase())
  5157. )
  5158. : items;
  5159. if (!filteredItems.length && !this.title) return null;
  5160. return Vue.h("div", { class: "ss-sidebar-panel" }, [
  5161. this.title
  5162. ? Vue.h("div", { class: "ss-sidebar-panel__header" }, [
  5163. Vue.h("div", { class: "ss-sidebar-panel__title" }, [
  5164. // 图标 + 标题(每个分区都有) by xu 20260106
  5165. this.iconClass
  5166. ? Vue.h(SsIcon, { class: this.iconClass + " ss-sidebar-panel__icon" })
  5167. : this.icon
  5168. ? Vue.h(SsIcon, { name: this.icon, size: "16px", class: "ss-sidebar-panel__icon" })
  5169. : null,
  5170. Vue.h("span", null, this.title),
  5171. // 数量回显:图表分区可不传 count by xu 20260106
  5172. this.count !== "" ? Vue.h("span", { class: "ss-sidebar-panel__count" }, `(${this.count})`) : null,
  5173. ]),
  5174. Vue.h("div", { class: "ss-sidebar-panel__tools" }, [
  5175. // header 条件(例如下拉框)+ 右侧搜索按钮 by xu 20260106
  5176. this.headerFilters?.length
  5177. ? Vue.h(
  5178. "div",
  5179. { class: "ss-sidebar-panel__filters" },
  5180. this.headerFilters.map(renderHeaderFilter).filter(Boolean)
  5181. )
  5182. : null,
  5183. this.headerSearchButton
  5184. ? Vue.h(
  5185. "button",
  5186. {
  5187. type: "button",
  5188. class: "ss-sidebar-icon-btn",
  5189. title: "搜索",
  5190. onClick: (e) => {
  5191. e.stopPropagation();
  5192. this.$emit("search", {
  5193. // headerFilters 内也可能包含 keyword by xu 20260106
  5194. keyword: activeKeyword,
  5195. filters: { ...(this.filterValues || {}) },
  5196. });
  5197. },
  5198. },
  5199. [Vue.h(SsIcon, { name: "search", size: "14px" })]
  5200. )
  5201. : null,
  5202. // 人员块:搜索框在 header 内 by xu 20260106
  5203. this.searchable && this.searchInHeader && !this.headerSearchButton
  5204. ? Vue.h("div", { class: "ss-sidebar-panel__searchInline" }, [
  5205. Vue.h("div", { class: "ss-sidebar-search is-inline" }, [
  5206. Vue.h(SsIcon, { name: "search", size: "14px", class: "ss-sidebar-search__prefix" }),
  5207. Vue.h("input", {
  5208. class: "ss-sidebar-search__input",
  5209. value: this.keyword,
  5210. placeholder: this.searchPlaceholder,
  5211. onInput: (e) => {
  5212. this.keyword = e?.target?.value ?? "";
  5213. },
  5214. }),
  5215. ]),
  5216. ])
  5217. : null,
  5218. this.closable
  5219. ? Vue.h(
  5220. "button",
  5221. {
  5222. type: "button",
  5223. class: "ss-sidebar-icon-btn ss-sidebar-header-btn",
  5224. title: "清空",
  5225. onClick: (e) => {
  5226. e.stopPropagation();
  5227. this.$emit("clear");
  5228. },
  5229. },
  5230. // 清空按钮使用 icon-base 的 icon-cl by xu 20260106
  5231. [Vue.h(SsIcon, { class: "menu-base-icon icon-cl" })]
  5232. )
  5233. : null,
  5234. ]),
  5235. ])
  5236. : null,
  5237. // 非 header 内搜索:独立一行 by xu 20260106
  5238. // headerSearchButton/headerFilters 已覆盖搜索能力时,不再额外渲染独立搜索行 by xu 20260106
  5239. this.searchable && !this.searchInHeader && !this.headerSearchButton && !hasHeaderKeyword
  5240. ? Vue.h("div", { class: "ss-sidebar-panel__search" }, [
  5241. Vue.h("div", { class: "ss-sidebar-search" }, [
  5242. Vue.h(SsIcon, { name: "search", size: "14px", class: "ss-sidebar-search__prefix" }),
  5243. Vue.h("input", {
  5244. class: "ss-sidebar-search__input",
  5245. value: this.keyword,
  5246. placeholder: this.searchPlaceholder,
  5247. onInput: (e) => {
  5248. this.keyword = e?.target?.value ?? "";
  5249. },
  5250. }),
  5251. ]),
  5252. ])
  5253. : null,
  5254. Vue.h(
  5255. "div",
  5256. { class: "ss-sidebar-list" },
  5257. filteredItems.map((item, idx) => {
  5258. const title = item?.title ?? "";
  5259. const tags = item?.tags || [];
  5260. const isPersonLayout = this.itemLayout === "person";
  5261. const hasTags = !isPersonLayout && (tags?.length > 0); // 列表项垂直对齐:有 tags 顶对齐 by xu 20260106
  5262. return Vue.h(
  5263. "div",
  5264. {
  5265. class: {
  5266. "ss-sidebar-list-item": true,
  5267. "is-first": idx === 0,
  5268. "is-person": isPersonLayout,
  5269. "has-tags": hasTags,
  5270. },
  5271. },
  5272. [
  5273. Vue.h("div", { class: "ss-sidebar-list-item__main" }, [
  5274. Vue.h(
  5275. "div",
  5276. { class: "ss-sidebar-list-item__title" },
  5277. Vue.h(
  5278. "span",
  5279. {
  5280. style: {
  5281. "white-space": "nowrap",
  5282. overflow: "hidden",
  5283. "text-overflow": "ellipsis",
  5284. },
  5285. },
  5286. title
  5287. )
  5288. ),
  5289. // 非人员布局才显示 tags by xu 20260106
  5290. !isPersonLayout && tags?.length
  5291. ? Vue.h(
  5292. "div",
  5293. { class: "ss-sidebar-list-item__tags" },
  5294. tags.map((tag) => {
  5295. const [k, v] = Object.entries(tag)[0] || ["", ""];
  5296. return Vue.h("span", { class: "ss-sidebar-tag", title: `${k}: ${v}` }, `${k}: ${v}`);
  5297. })
  5298. )
  5299. : null,
  5300. ]),
  5301. // 人员布局:中间保留“人员号”槽位 by xu 20260106
  5302. isPersonLayout
  5303. ? Vue.h(
  5304. "div",
  5305. { class: "ss-sidebar-list-item__meta", title: String(item?.meta ?? "") },
  5306. item?.meta ?? ""
  5307. )
  5308. : null,
  5309. this.itemAction
  5310. ? Vue.h(
  5311. "button",
  5312. {
  5313. type: "button",
  5314. class: {
  5315. // item 操作按钮:默认无背景/无边框,hover 才高亮 by xu 20260106
  5316. "ss-sidebar-item-btn": true,
  5317. },
  5318. title: isSelectedMode ? "移除" : "选择",
  5319. onClick: (e) => {
  5320. e.stopPropagation();
  5321. if (isSelectedMode) this.$emit("remove", item);
  5322. else this.$emit("select", item);
  5323. },
  5324. },
  5325. [
  5326. // item 移除图标使用 icon-base 的 icon-cl by xu 20260106
  5327. isSelectedMode
  5328. ? Vue.h(SsIcon, { class: "menu-base-icon icon-cl" })
  5329. : Vue.h(SsIcon, { name: "check", size: "14px" }),
  5330. ]
  5331. )
  5332. : null,
  5333. ]
  5334. );
  5335. })
  5336. ),
  5337. ]);
  5338. },
  5339. };
  5340. // 组件文档补全(JSDoc) by xu 20260108
  5341. /**
  5342. * SsSidebar(objList 右侧边栏容器)
  5343. *
  5344. * 用途:
  5345. * - 统一渲染顶部按钮栏(buttons)
  5346. * - 统一渲染中间业务面板(list panels,可拖拽调高度)
  5347. * - 统一渲染底部图表(chart panels,内部用 ss-sidebar-chart-hover)
  5348. *
  5349. * 调用示例:
  5350. * ```html
  5351. * <ss-sidebar :buttons="sidebarButtons" :panels="sidebarPanels" @remove="handleSidebarRemove" />
  5352. * ```
  5353. *
  5354. * Props:
  5355. * - `buttons`:顶部按钮配置数组
  5356. * - `panels`:分区配置数组(`type: 'list' | 'chart'`)
  5357. *
  5358. * Events(向外透传):
  5359. * - `remove(item)`:来自 list 面板移除
  5360. * - `select(item)`:来自 list 面板选择(如后续需要)
  5361. */
  5362. const SsSidebar = {
  5363. name: "SsSidebar",
  5364. props: {
  5365. buttons: { type: Array, default: () => [] },
  5366. charts: { type: Array, default: () => [] },
  5367. list: { type: Array, default: () => [] }, // legacy
  5368. listMode: { type: String, default: "search" }, // legacy
  5369. panels: { type: Array, default: () => [] },
  5370. },
  5371. emits: ["select", "remove"],
  5372. data() {
  5373. return {
  5374. // 业务面板高度(索引 -> px) by xu 20260106
  5375. sectionHeights: [],
  5376. resizeTimer: null,
  5377. resizing: false,
  5378. resizeIndex: -1,
  5379. resizeStartY: 0,
  5380. resizeStartPrev: 0,
  5381. resizeStartNext: 0,
  5382. };
  5383. },
  5384. methods: {
  5385. // 初始化默认高度(只在第一次/面板数量变化时补齐) by xu 20260106
  5386. ensureSectionHeights(sectionCount) {
  5387. if (!Array.isArray(this.sectionHeights)) this.sectionHeights = [];
  5388. if (this.sectionHeights.length === sectionCount) return;
  5389. const next = [];
  5390. for (let i = 0; i < sectionCount; i++) {
  5391. next[i] = this.sectionHeights[i] ?? 190; // 默认高度 by xu 20260106
  5392. }
  5393. this.sectionHeights = next;
  5394. },
  5395. startResize(index, e) {
  5396. if (e?.preventDefault) e.preventDefault();
  5397. if (e?.stopPropagation) e.stopPropagation();
  5398. if (this.resizing) return;
  5399. // 长按 0.5s 后才进入拖拽调高度 by xu 20260106
  5400. clearTimeout(this.resizeTimer);
  5401. const startY = e?.clientY ?? 0;
  5402. const gapEl = e?.currentTarget;
  5403. this.resizeTimer = setTimeout(() => {
  5404. this.resizing = true;
  5405. this.resizeIndex = index;
  5406. this.resizeStartY = startY;
  5407. this.resizeStartPrev = this.sectionHeights[index] ?? 190;
  5408. this.resizeStartNext = this.sectionHeights[index + 1] ?? 190;
  5409. gapEl?.classList?.add("is-active");
  5410. window.addEventListener("pointermove", this.onResizeMove, { passive: false });
  5411. window.addEventListener("pointerup", this.endResize, { passive: false, once: true });
  5412. }, 500);
  5413. },
  5414. onResizeMove(e) {
  5415. if (!this.resizing) return;
  5416. if (e?.preventDefault) e.preventDefault();
  5417. const dy = (e?.clientY ?? 0) - this.resizeStartY;
  5418. const minPanelHeight = 83; // header(35) + listMin(48) by xu 20260106
  5419. const prev = Math.max(minPanelHeight, this.resizeStartPrev + dy);
  5420. const next = Math.max(minPanelHeight, this.resizeStartNext - dy);
  5421. // 若其中一个达到最小值,则停止继续挤压 by xu 20260106
  5422. const adjustedDy = prev - this.resizeStartPrev;
  5423. const nextAdjusted = this.resizeStartNext - adjustedDy;
  5424. this.sectionHeights.splice(this.resizeIndex, 1, prev);
  5425. this.sectionHeights.splice(this.resizeIndex + 1, 1, Math.max(minPanelHeight, nextAdjusted));
  5426. },
  5427. endResize(e) {
  5428. clearTimeout(this.resizeTimer);
  5429. this.resizeTimer = null;
  5430. if (!this.resizing) return;
  5431. if (e?.preventDefault) e.preventDefault();
  5432. const activeGaps = document.querySelectorAll(".ss-sidebar-gap.is-active");
  5433. activeGaps.forEach((g) => g.classList.remove("is-active"));
  5434. this.resizing = false;
  5435. this.resizeIndex = -1;
  5436. window.removeEventListener("pointermove", this.onResizeMove);
  5437. },
  5438. },
  5439. mounted() {
  5440. clearTimeout(this.resizeTimer);
  5441. this.resizeTimer = null;
  5442. },
  5443. beforeUnmount() {
  5444. clearTimeout(this.resizeTimer);
  5445. this.resizeTimer = null;
  5446. window.removeEventListener("pointermove", this.onResizeMove);
  5447. },
  5448. render() {
  5449. const SsSidebarButtonsComp = Vue.resolveComponent("ss-sidebar-buttons");
  5450. const SsSidebarChartComp = Vue.resolveComponent("ss-sidebar-chart");
  5451. const SsSidebarListComp = Vue.resolveComponent("ss-sidebar-list");
  5452. const SsIcon = Vue.resolveComponent("ss-icon");
  5453. // 支持 panels(多分区),list/listMode 作为 legacy 兜底 by xu 20260106
  5454. const panels = (this.panels || []).length
  5455. ? this.panels
  5456. : this.list?.length
  5457. ? [{ type: "list", title: "已选", icon: "", mode: this.listMode, items: this.list }]
  5458. : [];
  5459. const sectionPanels = panels.filter((p) => p?.type !== "chart");
  5460. const chartPanels = panels.filter((p) => p?.type === "chart");
  5461. this.ensureSectionHeights(sectionPanels.length);
  5462. return Vue.h("div", { class: "ss-sidebar" }, [
  5463. this.buttons?.length ? Vue.h(SsSidebarButtonsComp, { items: this.buttons }) : null,
  5464. Vue.h(
  5465. "div",
  5466. { class: "ss-sidebar__inner" },
  5467. [
  5468. ...(this.charts || []).map((c) =>
  5469. Vue.h(SsSidebarChartComp, { options: c?.options || {}, height: c?.height || "200px" })
  5470. ),
  5471. // 可拖拽的业务面板容器 by xu 20260106
  5472. Vue.h(
  5473. "div",
  5474. { class: "ss-sidebar-sections" },
  5475. sectionPanels.flatMap((p, idx) => {
  5476. const section = Vue.h(
  5477. "div",
  5478. {
  5479. class: "ss-sidebar-section",
  5480. style: { height: (this.sectionHeights[idx] ?? 190) + "px" },
  5481. },
  5482. [
  5483. Vue.h("div", { class: "ss-sidebar-section__content" }, [
  5484. Vue.h(SsSidebarListComp, {
  5485. title: p?.title ?? "",
  5486. icon: p?.icon ?? "",
  5487. count: p?.count ?? (p?.items?.length ?? ""),
  5488. closable: !!p?.closable,
  5489. searchable: !!p?.searchable,
  5490. searchInHeader: !!p?.searchInHeader,
  5491. headerFilters: p?.headerFilters || [],
  5492. headerSearchButton: !!p?.headerSearchButton,
  5493. searchPlaceholder: p?.searchPlaceholder ?? "搜索",
  5494. itemLayout: p?.itemLayout ?? "simple",
  5495. iconClass: p?.iconClass ?? "",
  5496. items: p?.items || [],
  5497. mode: p?.mode || "search",
  5498. onSelect: (item) => this.$emit("select", item),
  5499. onRemove: (item) => this.$emit("remove", item),
  5500. // closable = 清空分区数据 by xu 20260106
  5501. onClear: () => p?.onClear?.(),
  5502. onSearch: (payload) => p?.onSearch?.(payload),
  5503. }),
  5504. ]),
  5505. ]
  5506. );
  5507. const gap =
  5508. idx < sectionPanels.length - 1
  5509. ? Vue.h("div", {
  5510. class: "ss-sidebar-gap",
  5511. onPointerdown: (e) => this.startResize(idx, e),
  5512. })
  5513. : null;
  5514. return gap ? [section, gap] : [section];
  5515. })
  5516. ),
  5517. // 图表区固定在底部(hover 弹出大图) by xu 20260106
  5518. ...chartPanels.map((p) =>
  5519. Vue.h("div", { class: "ss-sidebar-panel" }, [
  5520. p?.title
  5521. ? Vue.h("div", { class: "ss-sidebar-panel__header" }, [
  5522. Vue.h("div", { class: "ss-sidebar-panel__title" }, [
  5523. p?.iconClass
  5524. ? Vue.h(SsIcon, { class: p.iconClass + " ss-sidebar-panel__icon" })
  5525. : p?.icon
  5526. ? Vue.h(SsIcon, { name: p.icon, size: "16px", class: "ss-sidebar-panel__icon" })
  5527. : null,
  5528. Vue.h("span", null, p.title),
  5529. ]),
  5530. Vue.h("div", { class: "ss-sidebar-panel__tools" }),
  5531. ])
  5532. : null,
  5533. // hover 大图也展示与 header 一致的图标/标题 by xu 20260108
  5534. Vue.h(Vue.resolveComponent("ss-sidebar-chart-hover"), {
  5535. title: p?.title ?? "",
  5536. iconClass: p?.iconClass ?? "",
  5537. icon: p?.icon ?? "",
  5538. options: p?.options || {},
  5539. height: p?.height || "240px",
  5540. }),
  5541. ])
  5542. ),
  5543. ].filter(Boolean)
  5544. ),
  5545. ]);
  5546. },
  5547. };
  5548. // ss-folder-card 文件夹卡片
  5549. const SsFolderCard = {
  5550. name: "SsFolderCard",
  5551. props: {
  5552. item: {
  5553. type: Object,
  5554. required: true,
  5555. },
  5556. },
  5557. data() {
  5558. return {
  5559. showButtons: false,
  5560. };
  5561. },
  5562. emits: ["click", "change"],
  5563. setup(props, { emit }) {
  5564. const item = props.item;
  5565. const showChildren = ref(false);
  5566. const eventBus = window.parent.sharedEventBus;
  5567. const itemWidth = Vue.computed(() => {
  5568. const containerWidth =
  5569. document.body.clientWidth || document.body.scrollWidth;
  5570. return containerWidth > 1200 ? "45%" : "90%";
  5571. });
  5572. onMounted(() => {
  5573. eventBus.subscribe("folderPath", (path) => {
  5574. const currentPath = path || [];
  5575. // 如果当前文件夹不在路径中,则销毁视图
  5576. if (
  5577. !currentPath.some((item) => item.folder.title === props.item.title)
  5578. ) {
  5579. showChildren.value = false;
  5580. }
  5581. });
  5582. });
  5583. const onItemClick = (e) => {
  5584. if (e && e.stopPropagation) {
  5585. e.stopPropagation();
  5586. }
  5587. // 单击只处理 active 状态
  5588. if (e && e.currentTarget) {
  5589. const allListCards = document.querySelectorAll(
  5590. ".knowledge-item-container"
  5591. );
  5592. const allFolderCards = document.querySelectorAll(".ss-folder-list");
  5593. allListCards.forEach((card) => card.classList.remove("active"));
  5594. allFolderCards.forEach((card) => card.classList.remove("active"));
  5595. e.currentTarget.classList.add("active");
  5596. } else {
  5597. // 如果是数据对象,需要找到对应的 DOM 元素
  5598. const allListCards = document.querySelectorAll(
  5599. ".knowledge-item-container"
  5600. );
  5601. const allFolderCards = document.querySelectorAll(".ss-folder-list");
  5602. allListCards.forEach((card) => card.classList.remove("active"));
  5603. allFolderCards.forEach((card) => card.classList.remove("active"));
  5604. // 找到标题匹配的文件夹元素
  5605. const targetFolder = Array.from(allFolderCards).find((card) =>
  5606. card.textContent.includes(e.title)
  5607. );
  5608. if (targetFolder) {
  5609. targetFolder.classList.add("active");
  5610. }
  5611. }
  5612. emit("click", item);
  5613. };
  5614. // 修改双击处理函数
  5615. const handleFolderDblClick = (folder, e) => {
  5616. if (e) e.stopPropagation();
  5617. if (folder.children?.length) {
  5618. showChildren.value = true;
  5619. const pathInfo = {
  5620. title: folder.title,
  5621. folder: folder,
  5622. };
  5623. const currentPath = eventBus.getState("folderPath") || [];
  5624. if (!currentPath.some((item) => item.title === folder.title)) {
  5625. eventBus.publish("folderPath", [...currentPath, pathInfo]);
  5626. }
  5627. }
  5628. };
  5629. const onItemChange = (e, icon, index) => {
  5630. e.stopPropagation();
  5631. props.item.buttons[0].onclick();
  5632. // emit("change", { item: props.item, icon, index });
  5633. };
  5634. return {
  5635. item,
  5636. itemWidth,
  5637. showChildren,
  5638. onItemClick,
  5639. onItemChange,
  5640. handleFolderDblClick,
  5641. };
  5642. },
  5643. render() {
  5644. const SsCartListIcon = Vue.resolveComponent("ss-cart-list-icon");
  5645. if (this.showChildren) {
  5646. return h(SsFolderCartView, {
  5647. folder: this.item,
  5648. });
  5649. }
  5650. return Vue.h(
  5651. "div",
  5652. {
  5653. class: { "ss-folder-list": true, active: this.item.active },
  5654. onClick: (e) => {
  5655. e.stopPropagation();
  5656. this.onItemClick(e);
  5657. },
  5658. onDblclick: (e) => this.handleFolderDblClick(this.item, e),
  5659. style: { width: this.itemWidth },
  5660. },
  5661. [
  5662. // 文件夹特有的装饰元素
  5663. Vue.h("div", { class: "ss-folder-list-trapezoid" }),
  5664. Vue.h("div", { class: "ss-folder-list-top-transparent" }),
  5665. Vue.h("div", { class: "ss-folder-list-top" }),
  5666. Vue.h("div", { class: "ss-folder-list-right" }),
  5667. // header 部分(按钮)
  5668. this.item?.buttons?.length > 0 &&
  5669. Vue.h(
  5670. "div",
  5671. {
  5672. class: "header",
  5673. onMouseenter: () => (this.showButtons = true),
  5674. onMouseleave: () => (this.showButtons = false),
  5675. onClick: (e) => this.onItemChange(e, this.item.buttons[0], 0),
  5676. },
  5677. [
  5678. // this.item?.buttons?.length > 0 &&
  5679. Vue.h("div", {
  5680. class: "cart-list-setting cart-list-icon",
  5681. title: this.item?.buttons?.[0]?.title,
  5682. }),
  5683. // this.item?.buttons?.length > 0 &&
  5684. this.showButtons &&
  5685. this.item?.buttons?.length > 1 &&
  5686. Vue.h(
  5687. "div",
  5688. {
  5689. class: "cart-list-button-popup",
  5690. },
  5691. this.item.buttons.map((btn) =>
  5692. Vue.h(
  5693. "div",
  5694. {
  5695. onClick: (e) => {
  5696. e.stopPropagation();
  5697. btn.onclick?.();
  5698. },
  5699. },
  5700. [
  5701. btn.class &&
  5702. Vue.h(SsCartListIcon, {
  5703. class: [btn.class],
  5704. }),
  5705. Vue.h("span", null, btn.title),
  5706. ]
  5707. )
  5708. )
  5709. ),
  5710. ]
  5711. ),
  5712. // body 部分
  5713. Vue.h("div", { class: "body" }, [
  5714. Vue.h("div", { class: "box-header" }, [
  5715. Vue.h("div", null, this.item.title),
  5716. ]),
  5717. Vue.h(
  5718. "div",
  5719. {
  5720. class: !this.item.thumb ? "no-thumb box-body" : "box-body",
  5721. },
  5722. [
  5723. this.item.thumb
  5724. ? Vue.h("div", { class: "left" }, [
  5725. Vue.h("img", {
  5726. src: this.item.thumb,
  5727. alt: "Thumbnail",
  5728. class: "imgUnHandle",
  5729. style: {
  5730. "object-fit": "cover",
  5731. width: "100%",
  5732. height: "100%",
  5733. },
  5734. }),
  5735. ])
  5736. : null,
  5737. Vue.h("div", { class: "right" }, [
  5738. ...this.item.tags.map((tag) => {
  5739. const [key, value] = Object.entries(tag)[0];
  5740. return Vue.h(
  5741. "div",
  5742. {
  5743. class: "title",
  5744. title: `${key}: ${value}`,
  5745. },
  5746. `${key}: ${value}`
  5747. );
  5748. }),
  5749. ]),
  5750. ]
  5751. ),
  5752. ]),
  5753. ]
  5754. );
  5755. },
  5756. };
  5757. // SsFolderCartView 组件 - 用于显示文件夹内容
  5758. const SsFolderCartView = {
  5759. name: "SsFolderCartView",
  5760. props: {
  5761. folder: {
  5762. type: Object,
  5763. required: true,
  5764. },
  5765. },
  5766. emits: ["click"],
  5767. setup(props, { emit }) {
  5768. const eventBus = window.parent.sharedEventBus;
  5769. const currentFolder = ref(props.folder);
  5770. const showChildren = ref(false);
  5771. const onItemClick = (e) => {
  5772. if (e && e.stopPropagation) {
  5773. e.stopPropagation();
  5774. }
  5775. // 单击只处理 active 状态
  5776. if (e && e.currentTarget) {
  5777. const allListCards = document.querySelectorAll(
  5778. ".knowledge-item-container"
  5779. );
  5780. const allFolderCards = document.querySelectorAll(".ss-folder-list");
  5781. allListCards.forEach((card) => card.classList.remove("active"));
  5782. allFolderCards.forEach((card) => card.classList.remove("active"));
  5783. e.currentTarget.classList.add("active");
  5784. } else {
  5785. // 如果是数据对象,需要找到对应的 DOM 元素
  5786. const allListCards = document.querySelectorAll(
  5787. ".knowledge-item-container"
  5788. );
  5789. const allFolderCards = document.querySelectorAll(".ss-folder-list");
  5790. allListCards.forEach((card) => card.classList.remove("active"));
  5791. allFolderCards.forEach((card) => card.classList.remove("active"));
  5792. // 找到标题匹配的文件夹元素
  5793. const targetFolder = Array.from(allFolderCards).find((card) =>
  5794. card.textContent.includes(e.title)
  5795. );
  5796. if (targetFolder) {
  5797. targetFolder.classList.add("active");
  5798. }
  5799. }
  5800. emit("click", props.folder);
  5801. };
  5802. const handleFolderDblClick = (folder, e) => {
  5803. if (e) e.stopPropagation();
  5804. if (folder.children?.length) {
  5805. showChildren.value = true;
  5806. const pathInfo = {
  5807. title: folder.title,
  5808. folder: folder,
  5809. };
  5810. const currentPath = eventBus.getState("folderPath") || [];
  5811. if (!currentPath.some((item) => item.title === folder.title)) {
  5812. eventBus.publish("folderPath", [...currentPath, pathInfo]);
  5813. currentFolder.value = folder;
  5814. }
  5815. }
  5816. };
  5817. const goBack = (targetFolder) => {
  5818. if (targetFolder === null) {
  5819. // 返回根目录
  5820. eventBus.publish("folderPath", []);
  5821. } else {
  5822. currentFolder.value = targetFolder;
  5823. }
  5824. };
  5825. return {
  5826. currentFolder,
  5827. showChildren,
  5828. onItemClick,
  5829. handleFolderDblClick,
  5830. goBack,
  5831. };
  5832. },
  5833. render() {
  5834. return h(
  5835. "div",
  5836. {
  5837. class: "page-container",
  5838. style: {
  5839. position: "fixed",
  5840. top: 0,
  5841. left: 0,
  5842. width: "100%",
  5843. height: "100%",
  5844. background: "var(--lightgray)",
  5845. padding: "20px 0",
  5846. zIndex: 1000,
  5847. },
  5848. },
  5849. [
  5850. // 搜索栏
  5851. h("div", { class: "search-bar" }, [
  5852. h("div", { class: "search-bar-contaienr" }, [
  5853. h(SsBreadcrumb, {
  5854. level: {
  5855. onBack: this.goBack,
  5856. },
  5857. }),
  5858. ]),
  5859. ]),
  5860. // 内容区域
  5861. h(
  5862. "div",
  5863. {
  5864. class: "content-area item-content-area",
  5865. style: { gap: "20px" },
  5866. },
  5867. [
  5868. ...(this.currentFolder.children || []).map((child, index) =>
  5869. h(child.children ? SsFolderCard : SsListCard, {
  5870. key: index,
  5871. item: child,
  5872. onClick: (e) => this.onItemClick(e),
  5873. onDblclick: (e) => this.handleFolderDblClick(child, e),
  5874. })
  5875. ),
  5876. ]
  5877. ),
  5878. ]
  5879. );
  5880. },
  5881. };
  5882. // ss-page分页
  5883. const SsPage = {
  5884. name: "SsPage",
  5885. props: {
  5886. total: {
  5887. type: Number,
  5888. required: true,
  5889. },
  5890. size: {
  5891. type: Number,
  5892. default: 10,
  5893. },
  5894. page: {
  5895. type: Number,
  5896. default: 1,
  5897. },
  5898. onChange: {
  5899. type: Function,
  5900. default: () => {},
  5901. },
  5902. },
  5903. setup(props) {
  5904. const totalItems = ref(props.total); // 总条目数
  5905. const totalPages = ref(Math.ceil(props.total / props.size));
  5906. const currentPage = ref(props.page); // 当前页码
  5907. // 计算显示的信息
  5908. const pageInfo = ref(
  5909. `共${totalItems.value}条,第 ${currentPage.value}/${totalPages.value} 页`
  5910. );
  5911. // 上一页的逻辑
  5912. const goToPreviousPage = (e) => {
  5913. e.preventDefault(); // 阻止默认行为
  5914. if (currentPage.value > 1) {
  5915. currentPage.value -= 1;
  5916. updatePageInfo();
  5917. props.onChange?.({
  5918. pageNo: currentPage.value, // 当前页码
  5919. rowNumPer: props.size, // 每页条数
  5920. rowNum: props.total, // 总记录数
  5921. });
  5922. }
  5923. };
  5924. // 下一页的逻辑
  5925. const goToNextPage = (e) => {
  5926. e.preventDefault(); // 阻止默认行为
  5927. if (currentPage.value < totalPages.value) {
  5928. currentPage.value += 1;
  5929. updatePageInfo();
  5930. props.onChange?.({
  5931. pageNo: currentPage.value, // 当前页码
  5932. rowNumPer: props.size, // 每页条数
  5933. rowNum: props.total, // 总记录数
  5934. });
  5935. }
  5936. };
  5937. // 更新页码信息的函数
  5938. const updatePageInfo = () => {
  5939. pageInfo.value = `共${totalItems.value}条,第 ${currentPage.value}/${totalPages.value} 页`;
  5940. };
  5941. return {
  5942. pageInfo,
  5943. totalPages,
  5944. goToPreviousPage,
  5945. goToNextPage,
  5946. };
  5947. },
  5948. render(props, { slots, emit }) {
  5949. return Vue.h("div", { class: "pager-container" }, [
  5950. Vue.h("input", { type: "hidden", name: "rowNum", value: props.total }),
  5951. Vue.h("input", {
  5952. type: "hidden",
  5953. name: "rowNumPer",
  5954. value: props.size,
  5955. }),
  5956. Vue.h("input", {
  5957. type: "hidden",
  5958. name: "pageCount",
  5959. value: this.totalPages,
  5960. }),
  5961. Vue.h("input", { type: "hidden", name: "pageNo", value: props.page }),
  5962. Vue.h("div", { class: "pager-content" }, [
  5963. Vue.h("div", { class: "info" }, this.pageInfo),
  5964. Vue.h(
  5965. "div",
  5966. { class: "btn" },
  5967. Vue.h(
  5968. "button",
  5969. { onClick: (e) => this.goToPreviousPage(e) },
  5970. "上一页"
  5971. )
  5972. ),
  5973. Vue.h(
  5974. "div",
  5975. { class: "btn" },
  5976. Vue.h("button", { onClick: (e) => this.goToNextPage(e) }, "下一页")
  5977. ),
  5978. ]),
  5979. ]);
  5980. },
  5981. };
  5982. // ss-right-info 一级页面右边栏
  5983. const SSRightInfo = {
  5984. name: "SSRightInfo",
  5985. setup() {
  5986. // 初始化响应式数据
  5987. const item = ref({
  5988. thumb: "images/example/project-img.png", // 更换为适合你项目的实际路径
  5989. title: "工业和信息化产业高质量发展资金",
  5990. });
  5991. return {
  5992. item,
  5993. };
  5994. },
  5995. render() {
  5996. return Vue.h("div", { class: "info-container" }, [
  5997. Vue.h("div", { class: "header" }, [
  5998. Vue.h("div", [
  5999. Vue.h("img", {
  6000. src: this.item.thumb,
  6001. class: "imgUnHandle",
  6002. style: { "object-fit": "cover", width: "100%", height: "100%" },
  6003. }), // 将 ImageViewer 替换为 img 标签
  6004. ]),
  6005. Vue.h("div", [Vue.h("div", this.item.title)]),
  6006. ]),
  6007. Vue.h("div", { class: "section-container" }, [
  6008. Vue.h("div", { class: "section" }, [
  6009. Vue.h("div", { class: "title" }, "合同"),
  6010. Vue.h("div", { class: "text" }, "合同总金额:42,399,320"),
  6011. Vue.h(
  6012. "div",
  6013. { class: "a" },
  6014. "《工业和信息化产业高质量发展资金补助合同》"
  6015. ),
  6016. ]),
  6017. Vue.h("div", { class: "section" }, [
  6018. Vue.h("div", { class: "title" }, "发票"),
  6019. Vue.h("div", { class: "text" }, "应开发票总额:42,399,320"),
  6020. Vue.h("div", { class: "text" }, "已开发票金额:17,235,345"),
  6021. Vue.h("div", { class: "text" }, "未开发票金额:25,163,975"),
  6022. ]),
  6023. Vue.h("div", { class: "section" }, [
  6024. Vue.h("div", { class: "title" }, "项目组成员"),
  6025. Vue.h("div", { class: "text" }, "我司:3人"),
  6026. Vue.h("div", { class: "text" }, "对方:2人"),
  6027. Vue.h("div", { class: "text" }, "项目负责人:张三"),
  6028. ]),
  6029. Vue.h("div", { class: "section" }, [
  6030. Vue.h("div", { class: "title" }, "采购"),
  6031. Vue.h("div", { class: "text" }, "总额:999,320"),
  6032. Vue.h("div", { class: "text" }, "已付金额:335,345"),
  6033. Vue.h("div", { class: "text" }, "未付金额:663,975"),
  6034. ]),
  6035. ]),
  6036. ]);
  6037. },
  6038. };
  6039. //
  6040. const SsSuccessPopup = {
  6041. name: "SsSuccessPopup",
  6042. props: {
  6043. right: {
  6044. type: String,
  6045. default: "20px",
  6046. },
  6047. bottom: {
  6048. type: String,
  6049. default: "calc(100% + 5px)",
  6050. },
  6051. },
  6052. setup(props, { expose }) {
  6053. // 响应式状态:是否可见
  6054. const visible = ref(false);
  6055. // 计算样式
  6056. const style = computed(() => {
  6057. return {
  6058. "--message-dialog-right": props.right,
  6059. "--message-dialog-bottom": props.bottom,
  6060. };
  6061. });
  6062. // 显示对话框的方法
  6063. const show = () => {
  6064. visible.value = true;
  6065. };
  6066. // 隐藏对话框的方法
  6067. const hide = () => {
  6068. visible.value = false;
  6069. };
  6070. // 将方法暴露给外部使用
  6071. expose({ show, hide });
  6072. // 返回渲染函数
  6073. return () => {
  6074. if (!visible.value) return null;
  6075. const SsIcon = resolveComponent("ss-icon");
  6076. return h(
  6077. "div",
  6078. {
  6079. class: "success-popup",
  6080. style: style.value,
  6081. onClick: (e) => e.stopPropagation(),
  6082. },
  6083. [
  6084. h("div", { class: "left" }, [
  6085. h("div", { class: "icon" }, [
  6086. h(SsIcon, { name: "check", size: "36px" }),
  6087. ]),
  6088. ]),
  6089. h("div", { class: "right" }, [
  6090. h("div", { class: "title" }, "提交成功"),
  6091. h("div", { class: "desc" }, "您的信息已成功提交。"),
  6092. ]),
  6093. ]
  6094. );
  6095. };
  6096. },
  6097. };
  6098. const SsErrorDialog = {
  6099. name: "SsErrorDialog",
  6100. setup(props, { emit }) {
  6101. const visible = ref(false);
  6102. const style = computed(() => {
  6103. return {};
  6104. });
  6105. const show = () => {
  6106. visible.value = true;
  6107. };
  6108. const hide = () => {
  6109. visible.value = false;
  6110. };
  6111. const onBack = () => {
  6112. emit("back");
  6113. hide();
  6114. };
  6115. return {
  6116. visible,
  6117. style,
  6118. show,
  6119. hide,
  6120. onBack,
  6121. };
  6122. },
  6123. render() {
  6124. const SsIcon = resolveComponent("ss-icon");
  6125. return this.visible
  6126. ? h(
  6127. "div",
  6128. {
  6129. class: "errorDialog",
  6130. style: this.style,
  6131. onClick: (event) => event.stopPropagation(),
  6132. },
  6133. [
  6134. h("div", { class: "body" }, [
  6135. h("div", { class: "left" }, [
  6136. h("div", { class: "icon" }, [
  6137. h(SsIcon, { name: "close", size: "36px" }),
  6138. ]),
  6139. ]),
  6140. h("div", { class: "right" }, [
  6141. h("div", { class: "title" }, "操作失败"),
  6142. h("div", { class: "desc" }, "请点击返回以继续。"),
  6143. ]),
  6144. ]),
  6145. h("div", { class: "footer" }, [
  6146. h("div", { class: "left" }),
  6147. h("div", { class: "right" }, [
  6148. h(
  6149. "div",
  6150. {
  6151. class: "btn",
  6152. onClick: this.onBack,
  6153. },
  6154. [h(SsIcon, { name: "arrow-left-line" }), h("div", "返回")]
  6155. ),
  6156. ]),
  6157. ]),
  6158. ]
  6159. )
  6160. : null;
  6161. },
  6162. };
  6163. /**
  6164. * 审核链条
  6165. * @name ss-verify
  6166. * @param { Array } verify-list 审核节点列表
  6167. * @property { Array } verify-list 审核节点列表
  6168. * @example <ss-verify :verify-list="verifyList"></ss-verify>
  6169. * verify-list [
  6170. * {
  6171. * groupName: "", // 群组名称
  6172. * open: true, // 默认是否展开
  6173. * children:[ //群组里的人员
  6174. * {
  6175. * thumb: "images/example/user-4.png", // 头像
  6176. * name: "李丽思 ", // 姓名
  6177. * role: "人事处处长", // 角色
  6178. * description: "同意。", // 审核意见
  6179. * time: "09:38 08/11", // 审核时间
  6180. * video: false, // false不显示/true显示 视频icon
  6181. * link: false, // false不显示/true显示 链接icon 后续应该是附件
  6182. * }
  6183. * ]
  6184. * }
  6185. * ]
  6186. */
  6187. const SsVerify = {
  6188. name: "SsVerify",
  6189. props: {
  6190. verifyList: {
  6191. type: Array,
  6192. required: true,
  6193. },
  6194. },
  6195. setup(props) {
  6196. const toggleOpen = (item) => {
  6197. item.open = !item.open;
  6198. };
  6199. onMounted(() => {
  6200. setTimeout(() => {
  6201. const lastOpenGroup = document.querySelector(".group-item-last-open");
  6202. console.log("lastOpenGroup", lastOpenGroup);
  6203. if (lastOpenGroup) {
  6204. const nodes = $(lastOpenGroup).find(".verify-node-container");
  6205. if (nodes.length) {
  6206. let totalHeight = 0;
  6207. const gudingHeight = 100;
  6208. if (nodes.length === 1) {
  6209. totalHeight = gudingHeight;
  6210. } else {
  6211. // 累加除最后一个节点外的所有节点高度
  6212. for (let i = 0; i < nodes.length - 1; i++) {
  6213. totalHeight += $(nodes[i]).outerHeight();
  6214. }
  6215. totalHeight += gudingHeight;
  6216. }
  6217. console.log("节点信息:", {
  6218. 节点总数: nodes.length,
  6219. 计算后的高度: totalHeight,
  6220. });
  6221. lastOpenGroup.style.setProperty(
  6222. "--group-line-height",
  6223. `${totalHeight}px`
  6224. );
  6225. }
  6226. }
  6227. }, 0);
  6228. });
  6229. return {
  6230. toggleOpen,
  6231. };
  6232. },
  6233. render() {
  6234. const SsIcon = resolveComponent("ss-icon");
  6235. const SsCommonIcon = resolveComponent("ss-common-icon");
  6236. const SsVerifyNode = resolveComponent("ss-verify-node");
  6237. return h(
  6238. "div",
  6239. { class: "verify-nodes" },
  6240. this.verifyList.map((item, i) =>
  6241. h(
  6242. "div",
  6243. {
  6244. key: i,
  6245. class: {
  6246. "group-item": true,
  6247. "group-item-last-open":
  6248. i === this.verifyList.length - 1 && item.open,
  6249. },
  6250. },
  6251. [
  6252. h(
  6253. "div",
  6254. {
  6255. class: "group-item-title",
  6256. onClick: () => this.toggleOpen(item),
  6257. },
  6258. [
  6259. h("div", { class: "icon" }, [
  6260. item.open
  6261. ? h(SsCommonIcon, { class: "common-icon-folder-open" })
  6262. : h(SsCommonIcon, { class: "common-icon-folder-close" }),
  6263. h(
  6264. "div",
  6265. {
  6266. class: "num",
  6267. style: { top: item.open ? "60%" : "55%" },
  6268. },
  6269. item.children?.length || 0
  6270. ),
  6271. ]),
  6272. h("div", { class: "name" }, item.groupName),
  6273. ]
  6274. ),
  6275. item.open && item.children?.length > 0
  6276. ? h(
  6277. "div",
  6278. { class: "group-item-children" },
  6279. item.children.map((citem, j) =>
  6280. h(SsVerifyNode, {
  6281. key: j,
  6282. item: citem,
  6283. // isGroup: i + 1 !== this.verifyList.length,
  6284. isGroup: true,
  6285. })
  6286. )
  6287. )
  6288. : null,
  6289. ]
  6290. )
  6291. )
  6292. );
  6293. },
  6294. };
  6295. /**
  6296. * 审核页面的审核节点
  6297. * @name ss-verify-node
  6298. * @param {Object} item 审核节点信息
  6299. * @param {Boolean} isGroup 是否为分组节点
  6300. */
  6301. const SsVerifyNode = {
  6302. name: "SsVerifyNode",
  6303. props: {
  6304. item: {
  6305. type: Object,
  6306. required: true,
  6307. },
  6308. isGroup: {
  6309. type: Boolean,
  6310. default: false,
  6311. },
  6312. },
  6313. render() {
  6314. const SsIcon = resolveComponent("ss-icon");
  6315. const SsCommonIcon = resolveComponent("ss-common-icon");
  6316. return Vue.h("div", { class: "verify-node-container" }, [
  6317. Vue.h("div", { class: "info" }, [
  6318. Vue.h("div", { class: "avatar" }, [
  6319. Vue.h("img", {
  6320. src: this.item.thumb,
  6321. style: {
  6322. width: "50px",
  6323. height: "50px",
  6324. borderRadius: "50%",
  6325. },
  6326. }),
  6327. ]),
  6328. Vue.h("div", { class: "desc" }, [
  6329. Vue.h("div", this.item.name),
  6330. Vue.h("div", this.item.role),
  6331. ]),
  6332. Vue.h("div", { class: "link" }, [
  6333. Vue.h("div", [
  6334. this.item.video
  6335. ? Vue.h(SsCommonIcon, { class: "common-icon-video" })
  6336. : null,
  6337. this.item.link
  6338. ? Vue.h(SsCommonIcon, {
  6339. class: "common-icon-paper-clip",
  6340. })
  6341. : null,
  6342. ]),
  6343. ]),
  6344. ]),
  6345. Vue.h(
  6346. "div",
  6347. {
  6348. class: {
  6349. description: true,
  6350. link: this.isGroup,
  6351. },
  6352. attrs: { "data-num": "3" },
  6353. },
  6354. [Vue.h("div", this.item.description)]
  6355. ),
  6356. Vue.h("div", { class: "time" }, this.item.time),
  6357. ]);
  6358. },
  6359. };
  6360. /**
  6361. * 智能识别图片的左侧图片播放 可以放大缩小旋转图片
  6362. * @name ss-orc-img-box
  6363. * @param { Object } image-obj 包含图片的url, 和图片的名称
  6364. *
  6365. */
  6366. const SsOrcImgBox = {
  6367. name: "SsOrcImgBox",
  6368. props: {
  6369. imageObj: {
  6370. type: Object,
  6371. required: true,
  6372. },
  6373. },
  6374. setup(props) {
  6375. const zoom = ref(1);
  6376. const rotation = ref(0);
  6377. const containerWidth = ref(0);
  6378. const containerHeight = ref(0);
  6379. const container = ref(null);
  6380. const imgPosition = ref({ x: 0, y: 0 });
  6381. const isDragging = ref(false);
  6382. const lastMousePosition = ref({ x: 0, y: 0 });
  6383. const imgStyle = computed(() => ({
  6384. width: `${zoom.value * 100}%`,
  6385. height: `${zoom.value * 100}%`,
  6386. transform: `rotate(${rotation.value}deg) translate(${imgPosition.value.x}px, ${imgPosition.value.y}px)`,
  6387. transformOrigin: "center center",
  6388. cursor: isDragging.value ? "grabbing" : "grab",
  6389. }));
  6390. const resetZoom = () => {
  6391. zoom.value = 1;
  6392. rotation.value = rotation.value + 90;
  6393. imgPosition.value = { x: 0, y: 0 };
  6394. };
  6395. const handleRangeChange = (event) => {
  6396. const value = event.target.value / 50; // 0 到 100 映射到 0 到 2 的缩放
  6397. zoom.value = Math.max(value, 0.1); // 设置最小缩放值为 0.1
  6398. };
  6399. const updateImgBoxDimensions = () => {
  6400. if (container.value) {
  6401. containerWidth.value = container.value.clientWidth;
  6402. containerHeight.value = container.value.clientHeight;
  6403. }
  6404. };
  6405. const onMouseDown = (event) => {
  6406. isDragging.value = true;
  6407. lastMousePosition.value = { x: event.clientX, y: event.clientY };
  6408. };
  6409. const onMouseMove = (event) => {
  6410. if (isDragging.value) {
  6411. const dx = event.clientX - lastMousePosition.value.x;
  6412. const dy = event.clientY - lastMousePosition.value.y;
  6413. // 防止旋转后拖动的x,y反转
  6414. // 首先将当前旋转角度从度数转换为弧度,因为 JavaScript 的 Math 库使用弧度
  6415. const angle = rotation.value * (Math.PI / 180);
  6416. // 使用基本的二维旋转矩阵将原始位移 dx 和 dy 转换为旋转后的位移 rotatedDx 和 rotatedDy。
  6417. const rotatedDx = dx * Math.cos(angle) + dy * Math.sin(angle);
  6418. const rotatedDy = dy * Math.cos(angle) - dx * Math.sin(angle);
  6419. imgPosition.value = {
  6420. x: imgPosition.value.x + rotatedDx,
  6421. y: imgPosition.value.y + rotatedDy,
  6422. };
  6423. lastMousePosition.value = { x: event.clientX, y: event.clientY };
  6424. }
  6425. };
  6426. const onMouseUp = () => {
  6427. isDragging.value = false;
  6428. };
  6429. onMounted(() => {
  6430. nextTick(() => {
  6431. updateImgBoxDimensions();
  6432. window.addEventListener("resize", updateImgBoxDimensions);
  6433. window.addEventListener("mousemove", onMouseMove);
  6434. window.addEventListener("mouseup", onMouseUp);
  6435. });
  6436. });
  6437. return {
  6438. zoom,
  6439. rotation,
  6440. container,
  6441. imgStyle,
  6442. resetZoom,
  6443. handleRangeChange,
  6444. containerWidth,
  6445. containerHeight,
  6446. onMouseDown,
  6447. imgPosition,
  6448. };
  6449. },
  6450. render() {
  6451. const SsIcon = resolveComponent("ss-icon");
  6452. return h("div", { class: "ocr-img-box" }, [
  6453. h("div", { class: "img-bar" }, [
  6454. h("div", this.imageObj.name),
  6455. h("div", { class: "action-bar" }, [
  6456. h("div", { class: "ocr-img-range-box" }, [
  6457. h("input", {
  6458. type: "range",
  6459. min: 0,
  6460. max: 100,
  6461. value: this.zoom * 50, // 初始位置为50
  6462. onInput: this.handleRangeChange,
  6463. }),
  6464. h("span", { class: "line" }),
  6465. ]),
  6466. h(SsIcon, {
  6467. name: "reset",
  6468. size: "26px",
  6469. onClick: this.resetZoom,
  6470. }),
  6471. ]),
  6472. ]),
  6473. h("div", { class: "img-viewer", ref: "container" }, [
  6474. h(
  6475. "div",
  6476. {
  6477. class: "img-box",
  6478. style: {
  6479. width: `${this.containerWidth}px`,
  6480. height: `${this.containerHeight}px`,
  6481. overflow: "hidden",
  6482. position: "relative",
  6483. },
  6484. },
  6485. [
  6486. h("img", {
  6487. src: this.imageObj.thumb,
  6488. style: this.imgStyle,
  6489. class: "zoomable-img",
  6490. onMousedown: this.onMouseDown,
  6491. }),
  6492. ]
  6493. ),
  6494. ]),
  6495. ]);
  6496. },
  6497. };
  6498. // 搜索输入框组件
  6499. const SsSearchInput = {
  6500. name: "SsSearchInput",
  6501. props: {
  6502. name: String,
  6503. placeholder: String,
  6504. width: {
  6505. type: String,
  6506. default: "100px",
  6507. },
  6508. modelValue: String,
  6509. },
  6510. emits: ["update:modelValue", "search"],
  6511. setup(props, { emit }) {
  6512. const handleInput = (e) => {
  6513. emit("update:modelValue", e.target.value);
  6514. };
  6515. const handleKeyup = (e) => {
  6516. if (e.key === "Enter") {
  6517. emit("search");
  6518. }
  6519. };
  6520. return { handleInput, handleKeyup };
  6521. },
  6522. render() {
  6523. return h(
  6524. "div",
  6525. {
  6526. class: "input",
  6527. style: this.width ? { width: this.width } : undefined,
  6528. },
  6529. [
  6530. h("input", {
  6531. name: this.name,
  6532. placeholder: this.placeholder,
  6533. value: this.modelValue,
  6534. onInput: this.handleInput,
  6535. onKeyup: this.handleKeyup,
  6536. }),
  6537. ]
  6538. );
  6539. },
  6540. };
  6541. // ss-search-date-picker 日期时间选择器组件
  6542. const SsSearchDatePicker = {
  6543. name: "SsSearchDatePicker",
  6544. props: {
  6545. modelValue: {
  6546. type: [String, Number, Date],
  6547. default: "",
  6548. },
  6549. name: {
  6550. type: String,
  6551. required: true,
  6552. },
  6553. type: {
  6554. type: String,
  6555. default: "date",
  6556. validator: (value) => ["date", "datetime", "time"].includes(value),
  6557. },
  6558. fmt: {
  6559. type: String,
  6560. default: null,
  6561. },
  6562. placeholder: {
  6563. type: String,
  6564. default: "",
  6565. },
  6566. width: {
  6567. type: String,
  6568. default: "100%",
  6569. },
  6570. },
  6571. emits: ["update:modelValue"],
  6572. setup(props, { emit }) {
  6573. const errMsg = ref("");
  6574. const validate = () => {
  6575. if (window.ssVm) {
  6576. const result = window.ssVm.validateField(props.name);
  6577. console.log("validate", window.ssVm.validateField(props.name));
  6578. errMsg.value = result.valid ? "" : result.message;
  6579. }
  6580. };
  6581. // 根据type确定默认格式
  6582. const defaultFormat = computed(() => {
  6583. switch (props.type) {
  6584. case "datetime":
  6585. return "YYYY-MM-DD HH:mm:ss";
  6586. case "date":
  6587. return "YYYY-MM-DD";
  6588. case "time":
  6589. return "HH:mm:ss";
  6590. }
  6591. });
  6592. const convertJavaFormatToElement = (javaFormat) => {
  6593. if (!javaFormat) return null;
  6594. return javaFormat
  6595. .replace("yyyy", "YYYY")
  6596. .replace("MM", "MM")
  6597. .replace("dd", "DD")
  6598. .replace("HH", "HH")
  6599. .replace("mm", "mm")
  6600. .replace("ss", "ss");
  6601. };
  6602. const finalFormat = computed(() => {
  6603. if (props.fmt) {
  6604. return convertJavaFormatToElement(props.fmt);
  6605. }
  6606. return defaultFormat.value;
  6607. });
  6608. // 使用 resolveComponent 获取组件
  6609. const ElDatePicker = resolveComponent("ElDatePicker");
  6610. const ElTimePicker = resolveComponent("ElTimePicker");
  6611. const SsFormIcon = resolveComponent("SsFormIcon");
  6612. const ElIcon = resolveComponent("ElIcon");
  6613. let useTimePicker = true;
  6614. //"yyyy-MM-dd HH:mm:ss"; "日期字符串格式在java的写法",传到本组件fmt属性也是按这个格式
  6615. if (props.fmt) {
  6616. //有fmt属性,则以fmt属性优先判断类型
  6617. if (/[dMy]/.test(props.fmt)) {
  6618. //如果有传入日期格式,且含年月日
  6619. useTimePicker = false;
  6620. } else {
  6621. useTimePicker = true;
  6622. }
  6623. } else if (props.type !== "time") {
  6624. useTimePicker = false;
  6625. }
  6626. const dateType = computed(() => {
  6627. const fmt = props.fmt || "";
  6628. if (fmt.includes("HH:mm:ss")) {
  6629. return "datetime";
  6630. } else if (fmt.includes("HH:mm")) {
  6631. return "datetime";
  6632. } else if (fmt.includes("mm:ss")) {
  6633. return "time";
  6634. }
  6635. return "date";
  6636. });
  6637. const handleValueUpdate = (val) => {
  6638. emit("update:modelValue", val);
  6639. emit("change", val); // 同时触发 change 事件
  6640. setTimeout(() => {
  6641. validate();
  6642. }, 50);
  6643. };
  6644. return () =>
  6645. h(
  6646. "div",
  6647. { class: "ss-search-date-picker", style: { width: props.width } },
  6648. [
  6649. h("input", {
  6650. type: "hidden",
  6651. name: props.name,
  6652. value: props.modelValue,
  6653. }),
  6654. h(useTimePicker ? ElTimePicker : ElDatePicker, {
  6655. modelValue: props.modelValue,
  6656. "onUpdate:modelValue": handleValueUpdate,
  6657. type: dateType.value,
  6658. format: finalFormat.value,
  6659. "value-format": finalFormat.value,
  6660. clearable: true,
  6661. placeholder: props.placeholder,
  6662. class: "custom-date-picker", // 用于自定义样式
  6663. "time-arrow-control": props.type === "datetime", // 修改这里
  6664. size: "large", // 添加这一行,改为 large 尺寸
  6665. style: { width: "100%" },
  6666. "prefix-icon": h(SsFormIcon, { class: "form-icon-time" }),
  6667. }),
  6668. ]
  6669. );
  6670. },
  6671. };
  6672. // 搜索按钮组件(包含下拉按钮)
  6673. const SsSearchButton = {
  6674. name: "SsSearchButton",
  6675. props: {
  6676. text: {
  6677. type: String,
  6678. required: true,
  6679. },
  6680. iconClass: {
  6681. type: String,
  6682. required: false,
  6683. },
  6684. opt: {
  6685. type: Array,
  6686. default: () => [],
  6687. },
  6688. checkId: {
  6689. type: String,
  6690. default: "0",
  6691. },
  6692. width: { //add by Ben(20251225)
  6693. type: String,
  6694. required: false
  6695. },
  6696. id: { //add by Ben(20251225)
  6697. type: String,
  6698. required: false
  6699. },
  6700. },
  6701. emits: ["click"],
  6702. setup(props, { emit }) {
  6703. const currentId = ref(props.checkId || "0");
  6704. const showPopup = ref(false);
  6705. const handleMouseEnter = () => {
  6706. showPopup.value = true;
  6707. };
  6708. const handleMouseLeave = () => {
  6709. showPopup.value = false;
  6710. };
  6711. // 添加点击事件处理,阻止默认行为
  6712. const handleClick = (e) => {
  6713. e.preventDefault();
  6714. if (props.opt?.length > 0) {
  6715. const selectedOption =
  6716. currentId.value === "0"
  6717. ? props.opt[0]
  6718. : props.opt.find((opt) => opt.id === currentId.value);
  6719. if (selectedOption) {
  6720. selectedOption.callback?.();
  6721. }
  6722. } else {
  6723. emit("click", e);
  6724. }
  6725. };
  6726. // 获取显示文本
  6727. const getDisplayText = () => {
  6728. if (!props.opt?.length) return props.text;
  6729. const selectedOption =
  6730. currentId.value === "0"
  6731. ? props.opt[0]
  6732. : props.opt.find((opt) => opt.id === currentId.value);
  6733. return selectedOption ? selectedOption.desc : props.opt[0].desc;
  6734. };
  6735. return () =>
  6736. h(
  6737. "button",
  6738. {
  6739. class:
  6740. props.opt?.length > 0
  6741. ? "ss-drop-button ss-drop-button-more"
  6742. : "ss-drop-button",
  6743. type: "button", // 明确指定按钮类型为 button
  6744. onMouseenter: handleMouseEnter,
  6745. onMouseleave: handleMouseLeave,
  6746. onClick: handleClick, // 添加点击事件处理
  6747. style: { width: props.width }, //add by Ben(20251225)
  6748. id:props.id //add by Ben(20251225)
  6749. },
  6750. [
  6751. props.iconClass
  6752. ? h("span", {
  6753. class: props.iconClass,
  6754. style: { fontFamily: "iconfont", marginRight: "5px" },
  6755. })
  6756. : null,
  6757. h("span", getDisplayText()),
  6758. props.opt.length > 0 &&
  6759. showPopup.value &&
  6760. h(
  6761. "div",
  6762. {
  6763. class: "popup",
  6764. },
  6765. props.opt.map((item) =>
  6766. h(
  6767. "div",
  6768. {
  6769. onClick: (e) => {
  6770. e.preventDefault(); // 选项点击也阻止默认行为
  6771. e.stopPropagation(); // 阻止事件冒泡
  6772. currentId.value = item.id; // 更新当前选中的ID
  6773. item.callback();
  6774. showPopup.value = false; // 选择后关闭弹窗
  6775. },
  6776. },
  6777. item.desc
  6778. )
  6779. )
  6780. ),
  6781. ]
  6782. );
  6783. },
  6784. };
  6785. // 下拉按钮组件
  6786. const SsDropButton = {
  6787. name: "SsDropButton",
  6788. props: {
  6789. text: {
  6790. type: String,
  6791. required: true,
  6792. },
  6793. iconClass: {
  6794. type: String,
  6795. required: true,
  6796. },
  6797. opt: {
  6798. type: Array,
  6799. default: () => [],
  6800. },
  6801. checkId: {
  6802. type: String,
  6803. default: "0",
  6804. },
  6805. onclick: {
  6806. type: Function,
  6807. default: null,
  6808. },
  6809. },
  6810. setup(props) {
  6811. const currentId = ref(props.checkId || "0");
  6812. const showPopup = ref(false);
  6813. const handleMouseEnter = () => {
  6814. showPopup.value = true;
  6815. };
  6816. const handleMouseLeave = () => {
  6817. showPopup.value = false;
  6818. };
  6819. // 添加点击事件处理,阻止默认行为
  6820. const handleClick = (e) => {
  6821. e.preventDefault();
  6822. if (props.opt?.length > 0) {
  6823. const selectedOption =
  6824. currentId.value === "0"
  6825. ? props.opt[0]
  6826. : props.opt.find((opt) => opt.id === currentId.value);
  6827. if (selectedOption) {
  6828. selectedOption.callback?.();
  6829. }
  6830. } else if (props.onclick) {
  6831. props.onclick();
  6832. }
  6833. };
  6834. // 获取显示文本
  6835. const getDisplayText = () => {
  6836. if (!props.opt?.length) return props.text;
  6837. const selectedOption =
  6838. currentId.value === "0"
  6839. ? props.opt[0]
  6840. : props.opt.find((opt) => opt.id === currentId.value);
  6841. return selectedOption ? selectedOption.desc : props.opt[0].desc;
  6842. };
  6843. return () =>
  6844. h(
  6845. "button",
  6846. {
  6847. class:
  6848. props.opt?.length > 0
  6849. ? "ss-drop-button ss-drop-button-more"
  6850. : "ss-drop-button",
  6851. type: "button", // 明确指定按钮类型为 button
  6852. onMouseenter: handleMouseEnter,
  6853. onMouseleave: handleMouseLeave,
  6854. onClick: handleClick, // 添加点击事件处理
  6855. },
  6856. [
  6857. h("span", {
  6858. class: props.iconClass,
  6859. style: { fontFamily: "iconfont" },
  6860. }),
  6861. h("span", getDisplayText()),
  6862. props.opt.length > 0 &&
  6863. showPopup.value &&
  6864. h(
  6865. "div",
  6866. {
  6867. class: "popup",
  6868. },
  6869. props.opt.map((item) =>
  6870. h(
  6871. "div",
  6872. {
  6873. onClick: (e) => {
  6874. e.preventDefault(); // 选项点击也阻止默认行为
  6875. e.stopPropagation(); // 阻止事件冒泡
  6876. currentId.value = item.id; // 更新当前选中的ID
  6877. item.callback();
  6878. showPopup.value = false; // 选择后关闭弹窗
  6879. },
  6880. },
  6881. item.desc
  6882. )
  6883. )
  6884. ),
  6885. ]
  6886. );
  6887. },
  6888. };
  6889. /**
  6890. * 二级页面标签组件
  6891. * @name ss-sub-tab
  6892. * @description 用于展示二级页面的布局组件,包含左侧垂直标签导航(支持分组)和右侧iframe内容区
  6893. * @property {String} headerImage - 左侧顶部图片地址
  6894. * @property {Array} menuList - 菜单配置列表
  6895. * @property {Object} [activeMenu] - 当前选中的菜单项,不传则自动选择第一个可选菜单
  6896. * @property {Array} footerButtons - 底部按钮配置列表
  6897. */
  6898. /**
  6899. * SsSubTab 左侧菜单+iframe内容组件
  6900. * v3.0 改造:去掉顶部图片,改为图标+悬浮模式,iframe懒加载 by xu 20251216
  6901. */
  6902. const SsSubTab = {
  6903. name: "SsSubTab",
  6904. props: {
  6905. menuList: {
  6906. type: Array,
  6907. required: true,
  6908. },
  6909. activeMenu: {
  6910. type: String,
  6911. default: "",
  6912. },
  6913. footerButtons: {
  6914. type: Array,
  6915. default: () => [],
  6916. },
  6917. leftDisplay: {
  6918. type: Boolean,
  6919. default: true,
  6920. },
  6921. // v3.0 新增:菜单模式 collapse(悬浮展开) / fixed(始终收起) by xu 20251216
  6922. initialMode: {
  6923. type: String,
  6924. default: 'collapse',
  6925. },
  6926. },
  6927. emits: ["menu-change", "footer-click"],
  6928. setup(props, { emit }) {
  6929. // v3.0 新增:默认图标映射,使用icon-biz图标 by xu 20251216
  6930. const defaultIcons = [
  6931. 'icon-obj-ry', // 人员
  6932. 'icon-obj-dw', // 单位
  6933. 'icon-obj-gw', // 岗位
  6934. 'icon-biz-rc', // 人才
  6935. 'icon-biz-xc', // 巡查
  6936. 'icon-biz-cl', // 材料
  6937. 'icon-biz-men', // 门
  6938. 'icon-obj-xy' // 协议
  6939. ];
  6940. //功能: SsSubTab 支持后端下发 iconName + pobj/cobj 两级菜单 by xu 20251222
  6941. const isTrue = (v) => v === true || v === "true" || v === 1 || v === "1"; //功能 by xu 20251222
  6942. const resolveIconClass = (iconNameOrClass, fallbackIndex) => { //功能 by xu 20251222
  6943. const fallback = `menu-icon ${defaultIcons[fallbackIndex % defaultIcons.length]}`;
  6944. if (!iconNameOrClass) {
  6945. return fallback;
  6946. }
  6947. // 已经是完整 class(可能包含 menu-icon / menu-base-icon / 多个 class)
  6948. if (typeof iconNameOrClass === "string" && iconNameOrClass.indexOf(" ") > -1) {
  6949. return iconNameOrClass;
  6950. }
  6951. const iconName = iconNameOrClass;
  6952. if (iconName === "menu-icon" || iconName === "menu-base-icon") {
  6953. return fallback;
  6954. }
  6955. // 业务图标库:icon-biz / icon-obj -> menu-icon
  6956. if (
  6957. typeof iconName === "string" &&
  6958. (iconName.indexOf("icon-obj-") === 0 || iconName.indexOf("icon-biz-") === 0)
  6959. ) {
  6960. return `menu-icon ${iconName}`;
  6961. }
  6962. // 默认认为是 icon-base 图标 -> menu-base-icon
  6963. return `menu-base-icon ${iconName}`;
  6964. };
  6965. const getMenuIcon = (item, index) => { //功能 by xu 20251222
  6966. if (!item) {
  6967. return resolveIconClass(null, index);
  6968. }
  6969. //功能: 变动图标后端暂不正确,前端先写死为 icon-chg by xu 20251223
  6970. if (item.title === "变动" || item.name === "sys_bd") {
  6971. return resolveIconClass("icon-chg", index);
  6972. }
  6973. // 兼容旧字段 icon(优先使用)
  6974. if (item.icon) return resolveIconClass(item.icon, index);
  6975. // v3.0 使用后端下发 iconName
  6976. if (item.iconName) return resolveIconClass(item.iconName, index);
  6977. return resolveIconClass(null, index);
  6978. };
  6979. //功能: SsSubTab 底部按钮支持 icon+文字(icon-base)by xu 20251224
  6980. const getFooterIcon = (button) => { //功能 by xu 20251224
  6981. if (!button) return "menu-base-icon icon-save";
  6982. const iconNameOrClass = button.iconClass || button.iconName || button.icon;
  6983. if (!iconNameOrClass) return "menu-base-icon icon-save";
  6984. if (typeof iconNameOrClass === "string" && iconNameOrClass.indexOf(" ") > -1) {
  6985. return iconNameOrClass;
  6986. }
  6987. return `menu-base-icon ${iconNameOrClass}`;
  6988. };
  6989. //功能: pobj/cobj 扁平结构转换为 children 树结构,兼容原 children 结构 by xu 20251222
  6990. const normalizeMenuList = (rawList) => {
  6991. if (!Array.isArray(rawList) || rawList.length === 0) {
  6992. return [];
  6993. }
  6994. const hasTree = rawList.some((it) => Array.isArray(it?.children) && it.children.length > 0);
  6995. if (hasTree) {
  6996. return rawList.map((it) => ({
  6997. ...it,
  6998. __level: 1,
  6999. children: Array.isArray(it.children)
  7000. ? it.children.map((c) => ({ ...c, __level: 2 }))
  7001. : it.children,
  7002. }));
  7003. }
  7004. const hasMarker = rawList.some((it) => it && ("pobj" in it || "cobj" in it));
  7005. if (!hasMarker) {
  7006. return rawList.map((it) => ({ ...it, __level: 1 }));
  7007. }
  7008. const result = [];
  7009. let currentGroup = null;
  7010. for (const item of rawList) {
  7011. //功能: “变动”始终按一级处理(即使后端误传 pobj/cobj)by xu 20251223
  7012. const isChgItem = item && (item.title === "变动" || item.name === "sys_bd");
  7013. if (isChgItem) {
  7014. result.push({ ...item, __level: 1 });
  7015. continue;
  7016. }
  7017. const isParent = isTrue(item?.pobj);
  7018. const isChild = isTrue(item?.cobj);
  7019. if (isParent) {
  7020. currentGroup = {
  7021. ...item,
  7022. __level: 1,
  7023. children: [],
  7024. };
  7025. result.push(currentGroup);
  7026. continue;
  7027. }
  7028. if (isChild && currentGroup) {
  7029. currentGroup.children.push({ ...item, __level: 2 });
  7030. continue;
  7031. }
  7032. //功能: 变动等无 pobj/cobj 的选项按一级展示(不挂到 children,也不打断当前分组)by xu 20251223
  7033. result.push({ ...item, __level: 1 });
  7034. }
  7035. return result;
  7036. };
  7037. const menuListComputed = computed(() => normalizeMenuList(props.menuList)); //功能 by xu 20251222
  7038. //功能: 分组展开状态(默认展开),避免 computed 生成对象导致 open 状态丢失 by xu 20251222
  7039. const groupOpenState = reactive({}); // { [key]: boolean }
  7040. const getGroupKey = (item) => (item?.name || item?.title || ""); //功能 by xu 20251222
  7041. const isGroupOpen = (item) => { //功能 by xu 20251222
  7042. const key = getGroupKey(item);
  7043. if (!key) return true;
  7044. return groupOpenState[key] !== false;
  7045. };
  7046. const toggleGroupOpen = (item) => { //功能 by xu 20251222
  7047. const key = getGroupKey(item);
  7048. if (!key) return;
  7049. groupOpenState[key] = !isGroupOpen(item);
  7050. };
  7051. const getLevelClass = (item, fallbackLevel) => { //功能 by xu 20251222
  7052. //功能: “变动”始终按一级样式处理 by xu 20251223
  7053. if (item && (item.title === "变动" || item.name === "sys_bd")) {
  7054. return "level-1";
  7055. }
  7056. const level = item?.__level || fallbackLevel || 1;
  7057. return level === 2 ? "level-2" : "level-1";
  7058. };
  7059. // v3.0 新增:菜单模式管理 by xu 20251216
  7060. const menuMode = ref(props.initialMode);
  7061. const isHovering = ref(false);
  7062. const toggleMenuMode = () => {
  7063. menuMode.value = menuMode.value === 'collapse' ? 'fixed' : 'collapse';
  7064. };
  7065. //功能: 提供给旧UI弹窗顶部按钮调用的 API(替代点击 .menu-mode-toggle DOM)by xu 20251224
  7066. const registerSsSubTabApi = () => { //功能 by xu 20251224
  7067. try {
  7068. window.SS = window.SS || {};
  7069. window.SS.dom = window.SS.dom || {};
  7070. //功能: 兼容小写 ss 命名空间(部分页面只引用 window.ss)by xu 20251224
  7071. window.ss = window.ss || window.SS;
  7072. window.ss.dom = window.ss.dom || window.SS.dom;
  7073. const api = {
  7074. toggleMenuMode,
  7075. getMenuMode: () => menuMode.value,
  7076. };
  7077. window.SS.dom.ssSubTabApi = api;
  7078. window.ss.dom.ssSubTabApi = api;
  7079. //功能: 多层弹窗(如 objPlay -> objInfo) 场景,将 API 注册到 topWindow 供按钮跨层调用 by xu 20251224
  7080. try {
  7081. const wdDialogId = window.wd && wd.display && wd.display.getwdDialogId && wd.display.getwdDialogId();
  7082. if (wdDialogId && window.top) {
  7083. window.top.__ssSubTabApiMap = window.top.__ssSubTabApiMap || {};
  7084. window.top.__ssSubTabApiMap[wdDialogId] = api;
  7085. }
  7086. } catch (e) { }
  7087. try { console.log("[SsSubTabApi] registered", window.location && window.location.pathname); } catch (e) { }
  7088. } catch (e) { }
  7089. };
  7090. const unregisterSsSubTabApi = () => { //功能 by xu 20251224
  7091. try {
  7092. //功能: 从 topWindow 解绑(避免弹窗关闭后残留)by xu 20251224
  7093. try {
  7094. const wdDialogId = window.wd && wd.display && wd.display.getwdDialogId && wd.display.getwdDialogId();
  7095. if (wdDialogId && window.top && window.top.__ssSubTabApiMap && window.top.__ssSubTabApiMap[wdDialogId]) {
  7096. delete window.top.__ssSubTabApiMap[wdDialogId];
  7097. }
  7098. } catch (e) { }
  7099. if (window.SS?.dom?.ssSubTabApi?.toggleMenuMode === toggleMenuMode) {
  7100. delete window.SS.dom.ssSubTabApi;
  7101. }
  7102. if (window.ss?.dom?.ssSubTabApi?.toggleMenuMode === toggleMenuMode) {
  7103. delete window.ss.dom.ssSubTabApi;
  7104. }
  7105. } catch (e) { }
  7106. };
  7107. //功能: 立即注册,避免 enable 早于 onMounted 导致“api not ready”by xu 20251224
  7108. registerSsSubTabApi(); //功能 by xu 20251224
  7109. onBeforeUnmount(unregisterSsSubTabApi); //功能 by xu 20251224
  7110. const onMouseEnter = () => {
  7111. if (menuMode.value === 'collapse') {
  7112. isHovering.value = true;
  7113. }
  7114. };
  7115. const onMouseLeave = () => {
  7116. isHovering.value = false;
  7117. };
  7118. const isExpanded = computed(() => {
  7119. return menuMode.value === 'collapse' && isHovering.value;
  7120. });
  7121. // v3.0 新增:iframe 懒加载,点击才加载 by xu 20251216
  7122. const loadedMenus = ref(new Set());
  7123. const isMenuLoaded = (menuName) => {
  7124. return loadedMenus.value.has(menuName);
  7125. };
  7126. // 根据标题找到对应的菜单项
  7127. const findMenuByTitle = (title) => {
  7128. for (const item of menuListComputed.value) { //功能 by xu 20251222
  7129. if (item.children?.length > 0) {
  7130. const child = item.children.find((c) => c.title === title);
  7131. if (child) return child;
  7132. } else if (item.title === title) {
  7133. return item;
  7134. }
  7135. }
  7136. return null;
  7137. };
  7138. // 计算默认选中的菜单项
  7139. const defaultActiveMenu = computed(() => {
  7140. if (props.activeMenu) {
  7141. const menu = findMenuByTitle(props.activeMenu);
  7142. if (menu) return menu;
  7143. }
  7144. const firstItem = menuListComputed.value[0]; //功能 by xu 20251222
  7145. if (!firstItem) return null;
  7146. //功能: 默认选中第一个一级菜单(不默认跳到第一个二级)by xu 20251224
  7147. return firstItem;
  7148. });
  7149. const currentMenu = ref(defaultActiveMenu.value);
  7150. // 监听外部activeMenu变化
  7151. watch(
  7152. () => props.activeMenu,
  7153. (newTitle) => {
  7154. if (newTitle) {
  7155. const menu = findMenuByTitle(newTitle);
  7156. if (menu) {
  7157. currentMenu.value = menu;
  7158. }
  7159. }
  7160. }
  7161. );
  7162. // 初始化:默认选中项加入已加载集合
  7163. watch(currentMenu, (menu) => {
  7164. if (menu?.name) {
  7165. loadedMenus.value.add(menu.name);
  7166. }
  7167. }, { immediate: true });
  7168. // 选择菜单项时触发 menu-change 钩子
  7169. const selectItem = (item) => {
  7170. currentMenu.value = item;
  7171. // 标记为已加载
  7172. if (item.name) {
  7173. loadedMenus.value.add(item.name);
  7174. }
  7175. emit("menu-change", item);
  7176. };
  7177. // 处理底部按钮点击
  7178. const handleFooterClick = (button, index) => {
  7179. emit("footer-click", { button, index });
  7180. };
  7181. return {
  7182. menuListComputed, //功能 by xu 20251222
  7183. currentMenu,
  7184. selectItem,
  7185. handleFooterClick,
  7186. getFooterIcon, //功能: SsSubTab 底部按钮支持 icon+文字(icon-base)by xu 20251224
  7187. menuMode,
  7188. isHovering,
  7189. isExpanded,
  7190. toggleMenuMode,
  7191. onMouseEnter,
  7192. onMouseLeave,
  7193. isMenuLoaded,
  7194. getMenuIcon,
  7195. isGroupOpen, //功能 by xu 20251222
  7196. toggleGroupOpen, //功能 by xu 20251222
  7197. getLevelClass, //功能 by xu 20251222
  7198. };
  7199. },
  7200. template: `
  7201. <div class="project-edit-container">
  7202. <div class="left-side"
  7203. v-if="leftDisplay"
  7204. :data-mode="menuMode"
  7205. :class="{ 'is-expanded': isExpanded }"
  7206. @mouseenter="onMouseEnter"
  7207. @mouseleave="onMouseLeave">
  7208. <!-- 菜单内容 -->
  7209. <div class="menu-content">
  7210. <div class="scroll-view">
  7211. <template v-for="(menuItem, i) in menuListComputed" :key="i">
  7212. <!-- 分组菜单 -->
  7213. <div v-if="menuItem.children?.length > 0" class="group">
  7214. <!-- 功能: 一级(pobj)可点击进入,箭头仅控制展开/收起;二级点击不影响一级选中状态 by xu 20251223 -->
  7215. <div class="menu-item"
  7216. :class="[getLevelClass(menuItem, 1), { active: menuItem.name === currentMenu?.name }]"
  7217. @click="selectItem(menuItem)">
  7218. <ss-icon :class="getMenuIcon(menuItem, i)" />
  7219. <span class="menu-label">{{ menuItem.title }}</span>
  7220. <!-- 功能: 一级菜单有子项时显示 dot(参考全局左侧菜单)by xu 20251224 -->
  7221. <div class="has-children-dot"></div>
  7222. <div class="menu-tooltip">{{ menuItem.title }}</div>
  7223. </div>
  7224. <!-- 功能: 二级菜单始终展示,不做收缩展开 by xu 20251223 -->
  7225. <div class="group-detail">
  7226. <div v-for="(item, j) in menuItem.children"
  7227. :key="j"
  7228. class="menu-item"
  7229. :class="[getLevelClass(item, 2), { active: item.name === currentMenu?.name }]"
  7230. @click.stop="selectItem(item)">
  7231. <ss-icon :class="getMenuIcon(item, j)" />
  7232. <span class="menu-label">{{ item.title }}</span>
  7233. </div>
  7234. </div>
  7235. </div>
  7236. <!-- 普通菜单项 -->
  7237. <div v-else
  7238. class="menu-item"
  7239. :class="[getLevelClass(menuItem, 1), { active: menuItem.name === currentMenu?.name }]"
  7240. @click="selectItem(menuItem)">
  7241. <ss-icon :class="getMenuIcon(menuItem, i)" />
  7242. <span class="menu-label">{{ menuItem.title }}</span>
  7243. <div class="menu-tooltip">{{ menuItem.title }}</div>
  7244. </div>
  7245. </template>
  7246. </div>
  7247. </div>
  7248. <!-- 底部按钮 -->
  7249. <div v-if="footerButtons.length > 0"
  7250. class="sub-tab-menu-footer"
  7251. :class="{ 'has-text': !!footerButtons[0].text }"
  7252. @click="footerButtons[0].onclick">
  7253. <ss-icon :class="getFooterIcon(footerButtons[0])" />
  7254. <div class="footer-label" v-if="footerButtons[0].text">{{ footerButtons[0].text }}</div>
  7255. <ss-icon v-if="footerButtons.length > 1" class="footer-arrow" name="arrow-up" size="24px" />
  7256. <div v-if="footerButtons.length > 1" class="sub-tab-menu-popup">
  7257. <div v-for="(button, index) in footerButtons.slice(1)"
  7258. :key="index"
  7259. @click.stop="button.onclick">
  7260. {{ button.text }}
  7261. </div>
  7262. </div>
  7263. </div>
  7264. </div>
  7265. <!-- 右侧内容区域 - 懒加载 iframe -->
  7266. <div class="content-area fit-height-content" style="overflow: hidden;" :style="!leftDisplay ? { width: '100%' } : {}">
  7267. <template v-for="(menuItem, i) in menuList" :key="i">
  7268. <iframe
  7269. v-if="isMenuLoaded(menuItem.name)"
  7270. :src="menuItem.url"
  7271. style="height: 100%;width: 100%;"
  7272. frameborder="0"
  7273. class="sub-tab-iframe"
  7274. :id="i === 0 ? 'sub-tab-iframe' : ''"
  7275. v-show="currentMenu?.name === menuItem.name"
  7276. />
  7277. </template>
  7278. </div>
  7279. </div>
  7280. `,
  7281. };
  7282. // <iframe
  7283. // v-if="currentMenu?.url"
  7284. // :src="currentMenu.url"
  7285. // style="height: 100%;width: 100%;"
  7286. // frameborder="0"
  7287. // id="sub-tab-iframe"
  7288. // />
  7289. // ss-photo-upload 通用图片上传组件
  7290. const SsImgUpload = {
  7291. name: "SsImgUpload",
  7292. props: {
  7293. name: {
  7294. type: String,
  7295. required: true,
  7296. },
  7297. // 图片URL,用于回显
  7298. // url: {
  7299. // type: String,
  7300. // default: "",
  7301. // },
  7302. // 样式类名
  7303. class: {
  7304. type: String,
  7305. required: true,
  7306. },
  7307. // 裁剪配置
  7308. cropperOpt: {
  7309. type: Object,
  7310. default: () => ({
  7311. width: 360,
  7312. height: 360,
  7313. aspectRatio: 1,
  7314. }),
  7315. },
  7316. //上传图片url(未加图片名参数之前的部分)
  7317. ulUrl: {
  7318. type: String,
  7319. required: true,
  7320. },
  7321. //下载图片url(未加图片名参数之前的部分)
  7322. dlUrl: {
  7323. type: String,
  7324. required: true,
  7325. },
  7326. modelValue: [String, Number],
  7327. },
  7328. emits: ["update:modelValue"],
  7329. setup(props, { emit }) {
  7330. const inputId = Vue.computed(
  7331. () => `file_${Vue.getCurrentInstance().uid}`
  7332. );
  7333. //修改图片初始显示路径
  7334. let pathVal = ref(props.modelValue);
  7335. let picUrl = ref("");
  7336. if (props.modelValue) {
  7337. picUrl.value = props.dlUrl + "&path=" + props.modelValue;
  7338. }
  7339. Vue.onMounted(() => {
  7340. window.SS.cropper.init({
  7341. el: $(`#${inputId.value}`),
  7342. photoSize: {
  7343. width: props.cropperOpt.width,
  7344. height: props.cropperOpt.height,
  7345. },
  7346. aspectRatio: props.cropperOpt.aspectRatio,
  7347. uploadUrl: props.ulUrl,
  7348. success: (path) => {
  7349. pathVal.value = path;
  7350. picUrl.value = props.dlUrl + "&path=" + path;
  7351. emit("update:modelValue", path);
  7352. },
  7353. });
  7354. });
  7355. return () =>
  7356. h("div", { class: [props.class] }, [
  7357. h("input", {
  7358. type: "file",
  7359. accept: "image/*",
  7360. id: inputId.value,
  7361. style: { display: "none" },
  7362. }),
  7363. h("input", {
  7364. type: "hidden",
  7365. name: props.name,
  7366. value: pathVal.value,
  7367. }),
  7368. h(
  7369. "div",
  7370. {
  7371. style: {
  7372. width: "100%",
  7373. height: "100%",
  7374. },
  7375. onClick: () => $(`#${inputId.value}`).click(),
  7376. },
  7377. [
  7378. picUrl.value &&
  7379. h("img", {
  7380. src: picUrl.value,
  7381. style:
  7382. "width: 100%; height: 100%;object-fit: inherit;position: relative;z-index: 11;",
  7383. }),
  7384. ]
  7385. ),
  7386. ]);
  7387. },
  7388. };
  7389. // 初始化函数,负责创建和挂载 Vue 应用
  7390. // window.SS = { dom: {} };
  7391. /**
  7392. * 获取当前窗口的父窗口
  7393. * @returns {Window} 父窗口对象
  7394. */
  7395. window.SS.topWin = (function (p, c) {
  7396. while (p != c) {
  7397. c = p;
  7398. p = p.parent;
  7399. }
  7400. return c;
  7401. })(window.parent, window);
  7402. window.SS.createSsDialogInstance = createSsDialogInstance;
  7403. /**
  7404. * 创建弹窗
  7405. * @param {Object} setting
  7406. * @param {Function} callbackEvent
  7407. */
  7408. window.SS.openDialog = function (setting, callbackEvent) {
  7409. if (setting.params) {
  7410. const encodedParams = encodeURIComponent(JSON.stringify(setting.params));
  7411. setting.src +=
  7412. (setting.src.includes("?") ? "&" : "?") + "params=" + encodedParams;
  7413. }
  7414. if (window.parent && window.parent !== window) {
  7415. window.parent.SS.createSsDialogInstance(setting, callbackEvent);
  7416. } else {
  7417. createSsDialogInstance(setting, callbackEvent);
  7418. }
  7419. };
  7420. //关闭弹窗
  7421. window.SS.closeDialog = function () {
  7422. console.log("关闭弹窗");
  7423. if (topWindow.dialogInstances.length > 0) {
  7424. const instance = topWindow.dialogInstances.pop();
  7425. console.log("instance", instance);
  7426. console.log("instance.callbackEvent", instance.callbackEvent);
  7427. console.log(
  7428. "instance.callbackEvent.end",
  7429. typeof instance.callbackEvent === "function"
  7430. );
  7431. if (instance.callbackEvent) {
  7432. // 判断是否有end回调并执行
  7433. if (typeof instance.callbackEvent === "function") {
  7434. instance.callbackEvent();
  7435. }
  7436. if (typeof instance.callbackEvent.end === "function") {
  7437. instance.callbackEvent.end();
  7438. }
  7439. }
  7440. instance.app.unmount(); // 卸载最后一个实例
  7441. if (instance.container && instance.container.parentNode) {
  7442. instance.container.parentNode.removeChild(instance.container); // 移除容器
  7443. }
  7444. }
  7445. };
  7446. /**
  7447. * 裁剪插件
  7448. */
  7449. window.SS.cropper = {
  7450. init: function (setting) {
  7451. if (!window.top.SS) window.top.SS = {};
  7452. // 重要:确保 cropper 对象的完整初始化
  7453. if (!window.top.SS.cropper) {
  7454. window.top.SS.cropper = {
  7455. settings: new Map(),
  7456. _backupSettings: {},
  7457. getSetting: this.getSetting,
  7458. clearSetting: this.clearSetting,
  7459. debug: this.debug,
  7460. };
  7461. } else if (!window.top.SS.cropper.settings) {
  7462. // 如果 cropper 存在但 settings 不存在,重新初始化 settings
  7463. window.top.SS.cropper.settings = new Map();
  7464. window.top.SS.cropper._backupSettings = {};
  7465. }
  7466. const uploaderId = `uploader_${Date.now()}_${Math.random()
  7467. .toString(36)
  7468. .substr(2, 9)}`;
  7469. window.top.SS.cropper.settings.set(uploaderId, setting);
  7470. window.top.SS.cropper._backupSettings[uploaderId] = setting;
  7471. setting.box = setting.box || "1";
  7472. var winSetting = {
  7473. headerTitle: "图片裁剪",
  7474. src: "/js/cropper/cropper.jsp",//原来在"/newUI/page/cropper.jsp" Ben(20251205)
  7475. width: "900",
  7476. height: "500",
  7477. };
  7478. $(setting.el).change(function () {
  7479. if (!window.SS.cropper.verify(setting)) {
  7480. $(setting.el).val(""); // 清空文件选择
  7481. return false;
  7482. }
  7483. var files = this.files;
  7484. if (files && files.length) {
  7485. if (!window.SS.cropper.verifySize($(setting.el)[0], 5)) {
  7486. $(setting.el).val(""); // 清空文件选择
  7487. alert("文件大小不能超过5M,请重新选择");
  7488. return false;
  7489. }
  7490. var URL = window.URL || window.webkitURL;
  7491. var file = files[0];
  7492. setting.file = file;
  7493. if (
  7494. /^image\/\w+$/.test(file.type) &&
  7495. /\.(jpg|jpeg|png|)$/i.test(file.name)
  7496. ) {
  7497. var uploadedImageURL = URL.createObjectURL(file);
  7498. setting.data = uploadedImageURL;
  7499. setting.fileName = file.name;
  7500. // console.log()
  7501. winSetting.params = {
  7502. ...setting,
  7503. uploaderId,
  7504. };
  7505. console.log("ss-componets中change之后的winSetting", winSetting);
  7506. SS.openDialog(winSetting, {
  7507. success: function (win) {
  7508. console.log("裁剪插件成功");
  7509. // win.cropperSetting = setting;
  7510. },
  7511. end: function () {
  7512. console.log("裁剪插件结束");
  7513. $(setting.el).val(""); // 清空文件选择
  7514. },
  7515. });
  7516. } else {
  7517. alert("请选择图片文件,支持jpg、jpeg、png格式");
  7518. }
  7519. }
  7520. });
  7521. return uploaderId;
  7522. },
  7523. verify: function (setting) {
  7524. if (!setting) {
  7525. console.error(" cropper setting is not undefined! ");
  7526. return false;
  7527. }
  7528. if (!setting.el) {
  7529. console.error(" cropper setting.el is not undefined! ");
  7530. return false;
  7531. }
  7532. if (setting.photoSize) {
  7533. if (
  7534. (!setting.photoSize.width && setting.photoSize.height) ||
  7535. (!setting.photoSize.height && setting.photoSize.width)
  7536. ) {
  7537. console.error(
  7538. " cropper setting.photoSize { width, height } is not undefined! "
  7539. );
  7540. return false;
  7541. }
  7542. }
  7543. if (!setting.box) {
  7544. setting.box = "1";
  7545. }
  7546. if (!setting.aspectRatio) {
  7547. setting.aspectRatio = 1 / 1;
  7548. }
  7549. return true;
  7550. },
  7551. verifySize: function (fileEl, maxSize) {
  7552. // 判断是否为IE浏览器: /msie/i.test(navigator.userAgent) 为一个简单正则
  7553. var isIE = /msie/i.test(navigator.userAgent) && !window.opera;
  7554. var fileSize = 0;
  7555. if (isIE && !fileEl.files) {
  7556. // IE浏览器
  7557. var filePath = fileEl.value; // 获得上传文件的绝对路径
  7558. var fileSystem = new ActiveXObject("Scripting.FileSystemObject");
  7559. var file = fileSystem.GetFile(filePath);
  7560. fileSize = file.Size; // 文件大小,单位:b
  7561. } else {
  7562. // 非IE浏览器
  7563. fileSize = fileEl.files[0].size;
  7564. }
  7565. var size = fileSize / 1024 / 1024;
  7566. return !(size > maxSize);
  7567. },
  7568. // 获取特定上传组件的setting
  7569. getSetting: function (uploaderId) {
  7570. if (!window.top.SS?.cropper) {
  7571. console.warn("顶层窗口中未找到 SS.cropper");
  7572. return null;
  7573. }
  7574. // 优先从 Map 中获取
  7575. let setting = window.top.SS.cropper.settings.get(uploaderId);
  7576. // 如果 Map 中没有,尝试从备份中获取
  7577. if (!setting && window.top.SS.cropper._backupSettings[uploaderId]) {
  7578. console.log("从备份中恢复 setting");
  7579. setting = window.top.SS.cropper._backupSettings[uploaderId];
  7580. // 恢复到 Map 中
  7581. window.top.SS.cropper.settings.set(uploaderId, setting);
  7582. }
  7583. return setting;
  7584. },
  7585. // 清理特定上传组件的setting
  7586. clearSetting: function (uploaderId) {
  7587. if (!window.top.SS?.cropper) return;
  7588. window.top.SS.cropper.settings.delete(uploaderId);
  7589. delete window.top.SS.cropper._backupSettings[uploaderId];
  7590. console.log(
  7591. "清理设置后的 Map size:",
  7592. window.top.SS.cropper.settings.size
  7593. );
  7594. },
  7595. };
  7596. /**
  7597. * 获取url中的参数
  7598. * @returns {Object}
  7599. */
  7600. window.SS.getQueryParams = function () {
  7601. const params = {};
  7602. const queryString = window.location.search.substring(1);
  7603. const pairs = queryString.split("&");
  7604. for (let i = 0; i < pairs.length; i++) {
  7605. const pair = pairs[i].split("=");
  7606. params[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1]);
  7607. }
  7608. if (params.params) {
  7609. try {
  7610. params.params = JSON.parse(params.params);
  7611. } catch (e) {
  7612. console.error("Failed to parse params:", e);
  7613. }
  7614. }
  7615. return params;
  7616. };
  7617. /**
  7618. * 创建vue应用
  7619. * @param {Object} config 配置项
  7620. * @values {String} config.el 挂载的元素
  7621. * @values {Boolean} config.isDialogPage 是否是弹窗页面 决定了是否可以使用顶天立地
  7622. * @values {Object} config.vueOptions vue配置项
  7623. * @returns {Object} vue实例
  7624. */
  7625. window.SS.dom.initializeFormApp = function (config) {
  7626. const { el, isDialogPage = false, ...vueOptions } = config;
  7627. const app = createApp({
  7628. ...vueOptions,
  7629. });
  7630. // 如果是弹窗iframe里面的html的话 给当前的页面挂上事件 实现顶天立地的效果
  7631. if (isDialogPage) {
  7632. function checkScroll() {
  7633. // 选出所有fit-height-content的元素 如果有滚动条
  7634. const elements = document.querySelectorAll(".fit-height-content");
  7635. let hasScrollBar = false;
  7636. // 检查元素是否有滚动条 检查当前窗口的所有元素
  7637. // 如果有滚动条,则将结果设置为true
  7638. elements.forEach((el) => {
  7639. if (el.scrollHeight > el.clientHeight) {
  7640. hasScrollBar = true;
  7641. }
  7642. });
  7643. // 将结果发送给父窗口
  7644. window.parent.postMessage({ hasScrollBar }, "*");
  7645. }
  7646. function addScrollListeners() {
  7647. const elements = document.querySelectorAll("div");
  7648. elements.forEach((el) => {
  7649. el.addEventListener("scroll", checkScroll);
  7650. });
  7651. }
  7652. const observer = new MutationObserver((mutations) => {
  7653. addScrollListeners();
  7654. checkScroll();
  7655. });
  7656. observer.observe(document.body, {
  7657. childList: true,
  7658. subtree: true,
  7659. });
  7660. window.addEventListener("resize", checkScroll);
  7661. }
  7662. // 注册组件
  7663. app.component("SsLoginIcon", SsLoginIcon);
  7664. app.component("SsMark", SsMark);
  7665. app.component("SsFullStyleHeader", SsFullStyleHeader);
  7666. app.component("SsDialog", SsDialog);
  7667. app.component("SsInp", SsInput);//把SsInput改为SsInp Ben(20251225)
  7668. app.component("SsObjp", SsObjp);
  7669. app.component("SsHidden", SsHidden);
  7670. app.component("SsCcp", SsCcp);
  7671. app.component("SsDatePicker", SsDatePicker);
  7672. app.component("SsIcon", SsIcon);
  7673. app.component("SsCommonIcon", SsCommonIcon);
  7674. app.component("SsBreadcrumb", SsBreadcrumb);
  7675. app.component("SsEditor", SsEditor);
  7676. app.component("SsDialogIcon", SsDialogIcon);
  7677. app.component("SsBottomButton", SsBottomButton);
  7678. app.component("SsNavIcon", SsNavIcon);
  7679. app.component("SsHeaderIcon", SsHeaderIcon);
  7680. app.component("SsGolbalMenuIcon", SsGolbalMenuIcon);
  7681. app.component("SsCartListIcon", SsCartListIcon);
  7682. app.component("SsQuickIcon", SsQuickIcon);
  7683. app.component("SsFormIcon", SsFormIcon);
  7684. app.component("SsBottomDivIcon", SsBottomDivIcon);
  7685. app.component("SsEditorIcon", SsEditorIcon);
  7686. app.component("SsValidate", SsValidate);
  7687. app.component("SsOnoff", Ssonoff);
  7688. app.component("SsonoffArray", SsonoffArray);
  7689. app.component("SsTextarea", SsTextarea);
  7690. app.component("SsLoginInput", SsLoginInput);
  7691. app.component("SsLoginButton", SsLoginButton);
  7692. app.component("SsSearch", SsSearch);
  7693. app.component("SsCartItem", SsCartItem);
  7694. app.component("SsCartItem2", SsCartItem2);
  7695. app.component("SsListCard", SsListCard);
  7696. app.component("SsFolderCard", SsFolderCard);
  7697. // 注册右侧边栏组件(ss-sidebar) by xu 20260106
  7698. app.component("ss-sidebar", SsSidebar);
  7699. app.component("ss-sidebar-buttons", SsSidebarButtons);
  7700. app.component("ss-sidebar-chart", SsSidebarChart);
  7701. app.component("ss-sidebar-chart-hover", SsSidebarChartHover);
  7702. app.component("ss-sidebar-list", SsSidebarList);
  7703. app.component("SsFolderCartView", SsFolderCartView);
  7704. app.component("SsPage", SsPage);
  7705. app.component("SsRightInfo", SSRightInfo);
  7706. app.component("SsSuccessPopup", SsSuccessPopup);
  7707. app.component("SsErrorDialog", SsErrorDialog);
  7708. app.component("SsVerify", SsVerify);
  7709. app.component("SsVerifyNode", SsVerifyNode);
  7710. app.component("SsOrcImgBox", SsOrcImgBox);
  7711. app.component("ss-search-input", SsSearchInput);
  7712. app.component("ss-search-date-picker", SsSearchDatePicker);
  7713. app.component("ss-search-button", SsSearchButton);
  7714. app.component("ss-drop-button", SsDropButton);
  7715. app.component("ss-sub-tab", SsSubTab);
  7716. app.component("ss-img", SsImgUpload);
  7717. // 设置为中文
  7718. app.use(ElementPlus, {
  7719. locale: ElementPlusLocaleZhCn,
  7720. });
  7721. // console.log(ElementPlus);
  7722. // 确保 ElementPlusIconsVue
  7723. // if (window.ElementPlusIconsVue) {
  7724. // // 注册 Element Plus 图标组件
  7725. // for (const [key, component] of Object.entries(
  7726. // window.ElementPlusIconsVue
  7727. // )) {
  7728. // console.log(key, component);
  7729. // app.component(key, component);
  7730. // }
  7731. // }
  7732. // 挂载首页的组件
  7733. for (const componentName in IndexComponents) {
  7734. app.component(componentName, IndexComponents[componentName]);
  7735. }
  7736. // 挂载echarts的组件
  7737. for (const componentName in EchartComponents) {
  7738. app.component(componentName, EchartComponents[componentName]);
  7739. }
  7740. // 挂载 Vue 应用
  7741. let vm ;
  7742. try {
  7743. vm = app.mount(el);
  7744. vm.data = vueOptions.data();
  7745. console.log("vm:",vm)
  7746. console.log("vueOptions:",vueOptions)
  7747. } catch (error) {
  7748. alert('Mount failed:'+ error);//vue Mount失败报错 Ben(20251206)
  7749. }
  7750. return vm;
  7751. };
  7752. })();