display.js 200 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310
  1. if (typeof window.wd == "undefined") {
  2. window.wd = {};
  3. }
  4. if (!wd.display) {
  5. wd.display = {};
  6. }
  7. (function () {
  8. if (wd.topWindow) return;
  9. var currParent = window;
  10. var i = 1;
  11. while (currParent != top) {
  12. try {
  13. currParent.parent[new Date().getMilliseconds()] = 1; // 如果这行不报“没权限错误”,才执行下一行。
  14. currParent = currParent.parent;
  15. } catch (e) {
  16. break;
  17. }
  18. }
  19. /**
  20. * 得到同域的顶层窗口,不直接用top,是因为有把WD的页面嵌入到OA的作子页面的情形 如果顶层窗口直接用top,当顶层窗口是另一网站时,就会报错。
  21. */
  22. wd.topWindow = currParent;
  23. })();
  24. if (!wd.topWindow.wd) {
  25. wd.topWindow.wd = {};
  26. }
  27. if (!wd.topWindow.wd.display) {
  28. wd.topWindow.wd.display = {};
  29. }
  30. /*
  31. * Change log:
  32. *
  33. * --02-14-2014-- function name wd.display.showComponent from title = '<span
  34. * style="font:14px \'宋体\'\;line-height:30px;" >'+title+'</span>'; to title = '<span>'+title+'</span>';
  35. *
  36. *
  37. */
  38. // 初始化滚动条,by SPACE 2019-01-07
  39. // 关闭鼠标加载动画, by SPACE 2019-04-02
  40. $(document).ready(function () {
  41. // waitThenInitNiceScorll(); 不再使用NiceScorll滚动条 Ben(20260106)
  42. try {
  43. wd.display.closeLoad();
  44. } catch (e) {}
  45. });
  46. function waitThenInitNiceScorll() {
  47. try {
  48. document.onreadystatechange = function () {
  49. if (document.readyState == "complete")
  50. setTimeout("initNiceScorll()", 200);
  51. else setTimeout("waitThenInitNiceScorll()", 10);
  52. };
  53. } catch (e) {
  54. console.log(e);
  55. }
  56. }
  57. /**
  58. * 初始化滚动条
  59. */
  60. var flag = false;
  61. var resizeScrollIv;
  62. function initNiceScroll() {
  63. try {
  64. // 流程设计器
  65. if (
  66. $("#draw_demo").html() != undefined ||
  67. $("#draw_demo").html() != null ||
  68. $("#workFlowDesigner").html() != null
  69. ) {
  70. return;
  71. }
  72. // 网站设计页
  73. if ($("#updateDesignWebpageUrl").val() != null) {
  74. return;
  75. }
  76. // 内容播放器
  77. if ($("#fileProperty").val() != null) {
  78. return;
  79. }
  80. // 大滚动条
  81. var b = $("body");
  82. if ($(b).attr("nicescroll")) {
  83. if ($(b).attr("nicescroll") == "true") {
  84. loadScorll(b);
  85. }
  86. } else {
  87. loadScorll(b);
  88. }
  89. loadScorll($("iframe[name='ssTabIframe']")); // [name='wdTabFrame']。Lin
  90. loadScorll($(".scrollbar"));
  91. loadScorll($(".mainDiv"));
  92. loadScorll($(".content-div"));
  93. loadScorll(parent.$(".content-div"));
  94. loadScorll($(".CodeMirror-vscrollbar"));
  95. var iframe = window.parent.getIframeByElement(document.body);
  96. var iframeObj = $(iframe);
  97. // loadScorll(iframeObj);
  98. // 小滚动条
  99. loadSmallScorll($(".smallScrollbar"));
  100. // 0.5秒定时监听滚动条变化
  101. clearInterval(resizeScrollIv);
  102. resizeScrollIv = setInterval(function () {
  103. try {
  104. $("body").getNiceScroll().resize();
  105. $("iframe[name='ssTabIframe']").getNiceScroll().resize(); // [name='wdTabFrame']。Lin
  106. $(".mainDiv").getNiceScroll().resize();
  107. $(".scrollbar").getNiceScroll().resize();
  108. $(".content-div").getNiceScroll().resize();
  109. $(parent.$(".content-div")).getNiceScroll().resize(); // $(iframeObj).getNiceScroll().resize();
  110. $(".CodeMirror-vscrollbar").getNiceScroll().resize();
  111. $(".smallScrollbar").getNiceScroll().resize();
  112. } catch (e) {
  113. console.error(e);
  114. }
  115. }, 500);
  116. } catch (e) {
  117. if (!flag) {
  118. flag = true;
  119. // 解决页面引入多个 Jquery 导致 not function 的问题
  120. /* 改。Lin
  121. $("head").append("<script src=\"/wd/js/nicescroll376/jquery.nicescroll.js\"></script>")
  122. */
  123. // $("head").append("<script src=\"/ss/nicescroll/jquery.nicescroll.js\"></script>")
  124. /* 改。Lin
  125. $("head").append("<script src=\"/wd/js/nicescroll376/jquery.nicescroll.iframehelper.min.js\"></script>")
  126. */
  127. // $("head").append("<script src=\"/ss/nicescroll/jquery.nicescroll.iframehelper.min.js\"></script>")
  128. clearInterval(resizeScrollIv);
  129. initNiceScorll();
  130. }
  131. }
  132. }
  133. function getIframeByElement(element) {
  134. var iframe;
  135. $("iframe").each(function () {
  136. if (element.ownerDocument === this.contentWindow.document) {
  137. iframe = this;
  138. }
  139. return !iframe;
  140. });
  141. return iframe;
  142. }
  143. // 大滚动条
  144. function loadScroll(dom) {
  145. try {
  146. if ($(dom).attr("wdScroll") == "false") return;
  147. var hori = $(dom).attr("wdScroll") == "XY";
  148. $(dom).niceScroll({
  149. cursorcolor: "#C4C4C4", // 改变滚动条颜色,使用16进制颜色值
  150. cursorwidth: "6px", // 滚动条的宽度,单位:便素
  151. cursorborder: "1px solid #C4C4C4", // CSS方式定义滚动条边框
  152. cursorborderradius: "6px", // 滚动条圆角(像素)
  153. mousescrollstep: 60, // 鼠标滚轮的滚动速度 (像素)
  154. touchbehavior: false, // 激活拖拽滚动
  155. hwacceleration: false, // 激活硬件加速
  156. autohidemode: "true",
  157. background: "transparent", // 轨道的背景颜色
  158. iframeautoresize: true, // 在加载事件时自动重置iframe大小
  159. spacebarenabled: true, // 当按下空格时使页面向下滚动
  160. railpadding: {
  161. top: 0,
  162. right: 4,
  163. left: 4,
  164. bottom: 0,
  165. }, // 设置轨道的内间距
  166. horizrailenabled: hori || false, // nicescroll可以管理水平滚动
  167. railalign: "right", // 对齐垂直轨道
  168. railvalign: "bottom", // 对齐水平轨道
  169. preservenativescrolling: true,
  170. enabletranslate3d: true, // nicescroll 可以使用CSS变型来滚动内容
  171. enablemousewheel: true, // nicescroll可以管理鼠标滚轮事件
  172. nativeparentscrolling: false, //检测内容底部,并让父节点来滚动,作为原生滚动
  173. });
  174. } catch (e) {
  175. throw e;
  176. }
  177. }
  178. //初始化小滚动条
  179. function loadScrollXY(dom) {
  180. try {
  181. if ($(dom).attr("wdScroll") == "false") return;
  182. $(dom).niceScroll({
  183. cursorcolor: "#C4C4C4", // 改变滚动条颜色,使用16进制颜色值
  184. cursorwidth: "6px", // 滚动条的宽度,单位:便素
  185. cursorborder: "1px solid #C4C4C4", // CSS方式定义滚动条边框
  186. cursorborderradius: "6px", // 滚动条圆角(像素)
  187. mousescrollstep: 60, // 鼠标滚轮的滚动速度 (像素)
  188. touchbehavior: false, // 激活拖拽滚动
  189. hwacceleration: false, // 激活硬件加速
  190. autohidemode: "true",
  191. background: "transparent", // 轨道的背景颜色
  192. iframeautoresize: true, // 在加载事件时自动重置iframe大小
  193. spacebarenabled: true, // 当按下空格时使页面向下滚动
  194. railpadding: {
  195. top: 0,
  196. right: 4,
  197. left: 4,
  198. bottom: 0,
  199. }, // 设置轨道的内间距
  200. horizrailenabled: true, // nicescroll可以管理水平滚动
  201. railalign: "right", // 对齐垂直轨道
  202. railvalign: "bottom", // 对齐水平轨道
  203. preservenativescrolling: true,
  204. enabletranslate3d: true, // nicescroll 可以使用CSS变型来滚动内容
  205. enablemousewheel: true, // nicescroll可以管理鼠标滚轮事件
  206. nativeparentscrolling: false, //检测内容底部,并让父节点来滚动,作为原生滚动
  207. });
  208. } catch (e) {
  209. throw e;
  210. }
  211. }
  212. // 小滚动条
  213. function loadSmallScroll(dom) {
  214. try {
  215. $(dom).niceScroll({
  216. cursorcolor: "#C4C4C4", // 改变滚动条颜色,使用16进制颜色值
  217. cursorwidth: "1px", // 滚动条的宽度,单位:便素
  218. cursorborder: "1px solid #C4C4C4", // CSS方式定义滚动条边框
  219. cursorborderradius: "1px", // 滚动条圆角(像素)
  220. mousescrollstep: 60, // 鼠标滚轮的滚动速度 (像素)
  221. touchbehavior: false, // 激活拖拽滚动
  222. hwacceleration: false, // 激活硬件加速
  223. background: "transparent", // 轨道的背景颜色
  224. iframeautoresize: true, // 在加载事件时自动重置iframe大小
  225. spacebarenabled: true, // 当按下空格时使页面向下滚动
  226. autohidemode: "true", // leave
  227. railpadding: {
  228. top: 0,
  229. right: 2,
  230. left: 2,
  231. bottom: 0,
  232. }, // 设置轨道的内间距
  233. horizrailenabled: false, // nicescroll可以管理水平滚动
  234. railalign: "right", // 对齐垂直轨道
  235. railvalign: "bottom", // 对齐水平轨道
  236. enabletranslate3d: true, // nicescroll 可以使用CSS变型来滚动内容
  237. nativeparentscrolling: false, //检测内容底部,并让父节点来滚动,作为原生滚动
  238. zindex: "999999",
  239. });
  240. } catch (e) {
  241. console.log(e);
  242. }
  243. }
  244. //原来拼写错误,兼容处理
  245. var initNiceScorll = initNiceScroll;
  246. var loadScorll = loadScroll;
  247. var loadScorllXY = loadScrollXY;
  248. var loadSmallScorll = loadSmallScroll;
  249. /*
  250. * 设置HTML元素属性 @param object o 要设置属性的HTML元素 @param string a 要设置的属性名 @param string
  251. * v 要设置的属性值
  252. */
  253. function setAttribute(o, a, v) {
  254. if (typeof o != "object" || typeof a != "string") return;
  255. a == "class" ? (o.className = v) : o.setAttribute(a, v);
  256. }
  257. /*
  258. * 获取HTML元素属性值 @param object o 要获取属性的HTML元素 @param string a 要获取的属性名 @return
  259. * 返回要获取的属性值
  260. */
  261. function getAttribute(o, a) {
  262. if (typeof o != "object" || typeof a != "string") return;
  263. return a == "class" ? o.className : o.getAttribute(a);
  264. }
  265. /*
  266. * 移除HTML元素属性 @param object o 要移除属性的HTML元素 @param string a 要移除的属性名
  267. */
  268. function removeAttribute(o, a) {
  269. if (typeof o != "object" || typeof a != "string") return;
  270. o.removeAttribute(a);
  271. if (a == "class") o.removeAttribute("className");
  272. }
  273. /**
  274. * 去掉所有的html代码
  275. */
  276. wd.display.removeHTMLTag = wd.display.toPlainText = function (str) {
  277. str = str.replace(/<\/?[^>]*>/g, ""); // 去除HTML tag
  278. str = str.replace(/[ | ]*\n/g, "\n"); // 去除行尾空白
  279. // str = str.replace(/\n[\s| | ]*\r/g,'\n'); //去除多余空行
  280. str = str.replace(/&nbsp;/gi, ""); // 去掉&nbsp;
  281. str = str.replace(/\s/g, ""); // 将空格去掉
  282. return str;
  283. };
  284. /**
  285. * 初始化tr的显示样式
  286. */
  287. wd.display.initTrDisplay = function (
  288. trContainerNameOrId, // tr标签的直接父级标签的name或id
  289. oddClassName, // 奇数行的tr应用的class类名
  290. evenClassName, // 偶数行的tr应用的class类名
  291. onMouseOverClassName
  292. ) {
  293. // 鼠标放在tr上时,tr应用的css样式
  294. var container = wd.c.g(trContainerNameOrId);
  295. // container 可能为 undefined
  296. if (!container) return;
  297. var trs = container.childNodes;
  298. if (!trs) return;
  299. var trIndex = 0;
  300. for (var i = 0; i < trs.length; i++) {
  301. var oneTr = trs[i];
  302. if (
  303. !oneTr.tagName ||
  304. oneTr.tagName != "TR" ||
  305. oneTr.style.display == "none"
  306. )
  307. continue;
  308. trIndex++;
  309. if (trIndex % 2 == 1) {
  310. // 奇数行的tr应用的class类名
  311. oneTr.className += " " + oddClassName;
  312. } else {
  313. oneTr.className += " " + evenClassName;
  314. }
  315. oneTr.oriClassName = oneTr.className;
  316. var omocn = new RegExp(" " + onMouseOverClassName);
  317. // console.log(omocn);
  318. oneTr.onmouseover = function () {
  319. this.className =
  320. this.className.replace(omocn, "") + " " + onMouseOverClassName;
  321. };
  322. oneTr.onmouseout = function () {
  323. this.className = this.className.replace(omocn, "");
  324. };
  325. }
  326. };
  327. wd.display.showDynamicParamDialog = function (url, datas) {
  328. eval(wd.display.replaceDynamicParam(url.toString(), datas));
  329. };
  330. wd.display.createMaskDiv = function (containerObj, currWindow, zIndex) {
  331. // 创建遮罩层
  332. var ele = currWindow.document.getElementsByTagName("BODY")[0];
  333. var newID = new Date().getTime();
  334. if (!(typeof zIndex != "undefined" && zIndex)) {
  335. zIndex = 100001;
  336. }
  337. var coverDiv = document.createElement("div");
  338. coverDiv.id = newID;
  339. // coverDiv.style.cssText = 'display: none;' + 'position: absolute;' +
  340. // 'top: 0%;' + 'left: 0%;' + 'width: 100%;' + 'height: 100%;' +
  341. // 'background-color: #EEEEEE;' + '-moz-opacity: 0.5;' +
  342. // 'opacity: .50;' + 'filter: alpha(opacity=50);';
  343. coverDiv.setAttribute("class", "wdMaskDiv dialog-mask");
  344. coverDiv.style.zIndex = zIndex - 1;
  345. ele.appendChild(coverDiv);
  346. // coverDiv.style.display = 'block';
  347. var W =
  348. currWindow.document.body.scrollLeft +
  349. currWindow.document.body.scrollWidth ||
  350. currWindow.document.documentElement.scrollLeft +
  351. currWindow.document.documentElement.scrollWidth;
  352. var H =
  353. currWindow.document.body.scrollTop +
  354. currWindow.document.body.scrollHeight ||
  355. currWindow.document.documentElement.scrollTop +
  356. currWindow.document.documentElement.scrollHeight;
  357. coverDiv.style.width = W + "px";
  358. coverDiv.style.height = H + "px";
  359. var maskContainer = containerObj.mask;
  360. if (!maskContainer) {
  361. containerObj.mask = [];
  362. }
  363. containerObj.mask.push(newID);
  364. };
  365. //按钮 [id,pos,title,label,className]
  366. wd.display.wdButtons = [
  367. //功能: 旧UI弹窗右上角按钮图标升级为 icon-base(先改 help/lock/close)by xu 20251223
  368. ["wdHelp", 3, "帮助", "帮助", "dialog-toolbar-icon icon-help"],
  369. ["CMS_download", 3, "下载", "下载", "icon-download"],
  370. ["wdShare", 3, "收藏", "收藏", "icon-favorite"],
  371. ["wdShared", 3, "已收藏", "已收藏", "icon-favoriteOn"],
  372. ["editWdHelp", 3, "编辑帮助", "编辑帮助", "icon-setHelp"],
  373. ["editWdHelp_save", 3, "编辑帮助保存", "编辑帮助保存", "invertIcon-save"],
  374. //功能: icon-base 图标名调整:编辑选项卡 icon-ptab(弹窗顶部用细体)by xu 20251224
  375. ["wdTab", 3, "编辑选项卡", "编辑选项卡", "dialog-toolbar-icon icon-ptab"],
  376. //功能: icon-base 图标名调整:保存选项卡使用 icon-save(不再用 invertIcon-save)by xu 20251225
  377. [
  378. "wdTab_save",
  379. 3,
  380. "保存选项卡",
  381. "保存选项卡",
  382. "invertIcon-save dialog-toolbar-icon icon-save",
  383. ],
  384. //功能: icon-base 图标名调整:个人选值 icon-pval(弹窗顶部用细体)by xu 20251224
  385. ["wdRecord", 3, "个人选值", "个人选值", "dialog-toolbar-icon icon-pval"],
  386. //功能: icon-base 图标名调整:个人选值保存使用 icon-save(不再用 invertIcon-save)by xu 20251225
  387. [
  388. "wdRecord_save",
  389. 3,
  390. "个人选值保存",
  391. "个人选值保存",
  392. "invertIcon-save dialog-toolbar-icon icon-save",
  393. ],
  394. ["CMS_fullscreen", 3, "全屏", "全屏", "dialog-restoreButton"],
  395. ["CMS_nrProperty", 3, "内容属性", "内容属性", "icon-property"],
  396. ["change_on", 3, "变动查看-开", "变动查看-开", "dialog-changeOnButton"],
  397. ["change_off", 3, "变动查看-关", "变动查看-关", "dialog-changeButton"],
  398. ["lockScreen", 3, "锁定", "锁定", "dialog-toolbar-icon icon-lock"],
  399. ["wdPrint", 3, "打印", "打印", "icon-print"],
  400. ["wdBatchPrint", 3, "批量打印", "批量打印", "icon-print"],
  401. ["wdHelpCopyhexcode", 3, "复制帮助代码", "复制帮助代码", "icon-key"],
  402. //功能: SsSubTab 菜单模式切换按钮改为按需创建,避免所有弹窗都出现 by xu 20251224
  403. ];
  404. wd.display.initStyleWdButtons = function () {
  405. for (var i = 0; i < wd.display.wdButtons.length; i++) {
  406. var className = "dhtmlx_button_" + wd.display.wdButtons[i][0] + "_default";
  407. wd.topWindow
  408. .$("div.dhtmlx_button_" + wd.display.wdButtons[i][0] + "_default")
  409. .addClass(wd.display.wdButtons[i][4]);
  410. }
  411. // 特殊处理close,因为如果close和dhtmlx的close冲突,会隐藏原生,新增一个按钮
  412. var className = "dhtmlx_button_close_default";
  413. //功能: 弹窗关闭按钮使用 icon-base(避免依赖 svg/png)by xu 20251223
  414. wd.topWindow
  415. .$("div.dhtmlx_button_close_default")
  416. .removeClass(className)
  417. .addClass("dialog-toolbar-close-icon icon-close");
  418. };
  419. /**
  420. * 添加隐藏按钮
  421. * @param {Object} w
  422. */
  423. wd.display.addWdUserButton = function (w) {
  424. var buttonType = wd.display.wdButtons;
  425. for (var i = 0; i < buttonType.length; i++) {
  426. //添加按钮
  427. w.addUserButton(
  428. buttonType[i][0],
  429. buttonType[i][1],
  430. buttonType[i][2],
  431. buttonType[i][3],
  432. buttonType[i][4]
  433. );
  434. //隐藏按钮
  435. w.button(buttonType[i][0]).hide();
  436. // console.log(buttonType[i][0]+":"+w.button(buttonType[i][0]).isHidden())
  437. }
  438. wd.display.initStyleWdButtons();
  439. };
  440. wd.display.showAllWdUserButton = function (w, nolimit) {
  441. //解除限制
  442. if (nolimit) {
  443. w.unAllowButton = false;
  444. } else {
  445. w.unAllowButton = true;
  446. }
  447. var buttonType = wd.display.wdButtons;
  448. for (var i = 0; i < buttonType.length; i++) {
  449. if (w.button(buttonType[i][0]).isHidden() == false) {
  450. w.button(buttonType[i][0]).show();
  451. }
  452. }
  453. };
  454. wd.display.hideAllWdUserButton = function (w) {
  455. w.unAllowButton = true;
  456. var buttonType = wd.display.wdButtons;
  457. for (var i = 0; i < buttonType.length; i++) {
  458. w.button(buttonType[i][0]).style.display = "none";
  459. }
  460. };
  461. /**
  462. * 添加弹窗事件
  463. * @param {Object} w
  464. */
  465. wd.display.addComponentEvent = function (w) {
  466. // 按钮:设置wdRecord
  467. w.getFrame().addEventListener(
  468. "load",
  469. function () {
  470. var iframeWindow = w.getFrame().contentWindow;
  471. if ("0" == iframeWindow.loginStatus) return;
  472. //wdShare
  473. var wdShare = function () {
  474. this.win = null;
  475. this.button;
  476. this.init = function (w) {
  477. this.win = w;
  478. // var wdDialogWin = iframeWindow.document.querySelector("wdDialog[collect=true]")
  479. // if (!wdDialogWin)
  480. // return;
  481. this.sendRequest(
  482. "query",
  483. (function () {
  484. return function (data) {
  485. if (data == 1) {
  486. //已分享
  487. this.addButton("wdShared");
  488. } else if (data == 0) {
  489. //未分享
  490. this.addButton("wdShare");
  491. }
  492. };
  493. })()
  494. );
  495. };
  496. this.addButton = function (buttontype) {
  497. var THIS = this;
  498. //恢复隐藏按钮
  499. if (
  500. this.win.button(buttontype) &&
  501. this.win.button(buttontype) != null
  502. ) {
  503. this.win.button(buttontype).show();
  504. } else {
  505. // if (buttontype == "wdShared") {
  506. // this.win.addUserButton(buttontype, 3, "已收藏", "已收藏")
  507. // } else if (buttontype == "wdShare") {
  508. // this.win.addUserButton(buttontype, 3, "未收藏", "未收藏")
  509. // }
  510. }
  511. this.win.button(buttontype).onclick = function () {
  512. THIS.wdshareClick(buttontype);
  513. };
  514. };
  515. this.wdshareClick = function (buttontype) {
  516. var type;
  517. //已收藏点击:取消收藏
  518. //未收藏点击:
  519. if (buttontype == "wdShared") {
  520. type = "delete";
  521. } else if (buttontype == "wdShare") {
  522. type = "add";
  523. }
  524. this.sendRequest(type, function (data) {
  525. if (data == 1) {
  526. this.win.button(buttontype).hide();
  527. this.addButton(buttontype == "wdShared" ? "wdShare" : "wdShared");
  528. } else if (data == 0) {
  529. console.log(data);
  530. } else {
  531. console.log(data);
  532. }
  533. });
  534. };
  535. this.sendRequest = function (type, callback) {
  536. var wdsharetype;
  537. if (type == "query") {
  538. wdsharetype = "";
  539. } else if (type == "add") {
  540. wdsharetype = 1;
  541. } else if (type == "delete") {
  542. wdsharetype = 0;
  543. } else {
  544. alert("type 值超出范围:" + type); // ("我是不可能出现的!")。Lin
  545. }
  546. var THIS = this;
  547. $.post(
  548. "/service?ssServ=wdShare",
  549. {
  550. wdsharetype: wdsharetype,
  551. wdshareurl: iframeWindow.window.location.href,
  552. },
  553. function (data) {
  554. if (callback) {
  555. callback.call(THIS, data);
  556. }
  557. }
  558. );
  559. };
  560. };
  561. new wdShare().init(w);
  562. },
  563. false
  564. );
  565. };
  566. //功能: SsSubTab 菜单模式切换按钮启用(由页面主动调用)by xu 20251223
  567. wd.display.enableSsSubTabMenuModeButton = function () {
  568. try {
  569. var wdDialogId = wd.display.getwdDialogId();
  570. if (!wdDialogId) return false;
  571. if (!wd.topWindow || !wd.topWindow.dhxWins) return false;
  572. var w = wd.topWindow.dhxWins.window(wdDialogId);
  573. if (!w) return false;
  574. //功能: 打印调试信息(定位点击无反应问题)by xu 20251224
  575. try {
  576. console.log("[SsSubTabMenuMode] enable start, wdDialogId=", wdDialogId);
  577. } catch (e) {}
  578. //功能: 获取当前弹窗的 DOM 容器(用于精准定位按钮,避免多弹窗 querySelector 选错)by xu 20251224
  579. var iframeEl = null;
  580. //功能: 优先通过 wdDialogId 精确定位 iframe(避免误拿到 SsSubTab 内部 iframe)by xu 20251224
  581. try {
  582. var ifs = wd.topWindow.document.getElementsByTagName("IFRAME");
  583. for (var ii = 0; ii < ifs.length; ii++) {
  584. var iframeObj = ifs[ii];
  585. var tempId = iframeObj.getAttribute("wdDialogId");
  586. if (!tempId && iframeObj.dataset) {
  587. tempId = iframeObj.dataset["wdDialogId"];
  588. }
  589. if (tempId && tempId + "" === wdDialogId + "") {
  590. iframeEl = iframeObj;
  591. break;
  592. }
  593. }
  594. } catch (e) {}
  595. if (!iframeEl) {
  596. try {
  597. iframeEl = w.getFrame && w.getFrame();
  598. } catch (e) {}
  599. }
  600. if (!iframeEl) {
  601. try {
  602. console.log("[SsSubTabMenuMode] fail: no iframeEl");
  603. } catch (e) {}
  604. return false;
  605. }
  606. var winEl = null;
  607. try {
  608. winEl =
  609. iframeEl.closest &&
  610. iframeEl.closest("div.dhtmlx_window_active,div.dhtmlx_window_inactive");
  611. } catch (e) {}
  612. if (!winEl) {
  613. try {
  614. console.log("[SsSubTabMenuMode] fail: no winEl");
  615. } catch (e) {}
  616. return false;
  617. }
  618. //功能: 精准获取当前弹窗的按钮 DOM(dhtmlx 会切换 _default/_over_default 等)by xu 20251224
  619. var btnEl = null;
  620. try {
  621. btnEl = winEl.querySelector(
  622. "div[class*='dhtmlx_button_ssSubTabMenuMode_']"
  623. );
  624. } catch (e) {}
  625. if (!btnEl) {
  626. //功能: 仅在使用 SsSubTab 的页面按需创建按钮,避免所有弹窗默认带出 by xu 20251224
  627. //功能: icon-base 图标名调整:弹窗顶部菜单模式按钮使用细体 icon-autoTxt / icon-fix by xu 20251224
  628. try {
  629. w.addUserButton(
  630. "ssSubTabMenuMode",
  631. 3,
  632. "菜单模式",
  633. "菜单模式",
  634. "dialog-toolbar-icon icon-autoTxt"
  635. );
  636. } catch (e) {}
  637. try {
  638. wd.display.initStyleWdButtons && wd.display.initStyleWdButtons();
  639. } catch (e) {}
  640. try {
  641. btnEl = winEl.querySelector(
  642. "div[class*='dhtmlx_button_ssSubTabMenuMode_']"
  643. );
  644. } catch (e) {}
  645. if (!btnEl) {
  646. // 页面可能还没创建完成,交给调用方重试 by xu 20251224
  647. try {
  648. console.log("[SsSubTabMenuMode] fail: button dom not found");
  649. } catch (e) {}
  650. return false;
  651. }
  652. //功能: 打印调试信息(按钮按需创建成功)by xu 20251224
  653. try {
  654. console.log("[SsSubTabMenuMode] button created");
  655. } catch (e) {}
  656. }
  657. var btn = null;
  658. try {
  659. btn = w.button && w.button("ssSubTabMenuMode");
  660. } catch (e) {}
  661. //功能: 弹窗右上角切换按钮放到最左边(flex 顺序)by xu 20251223
  662. try {
  663. var btnContainer = btnEl.parentNode;
  664. if (
  665. btnContainer &&
  666. btnContainer.firstElementChild &&
  667. btnContainer.firstElementChild !== btnEl
  668. ) {
  669. btnContainer.insertBefore(btnEl, btnContainer.firstElementChild);
  670. }
  671. } catch (e) {}
  672. //功能: 旧UI弹窗中使用顶部按钮控制 SsSubTab,隐藏组件内置切换按钮 by xu 20251223
  673. try {
  674. document.documentElement &&
  675. document.documentElement.classList &&
  676. document.documentElement.classList.add("ss-sub-tab-dialog");
  677. } catch (e) {}
  678. // 确保组类存在 by xu 20251223
  679. try {
  680. btnEl.classList && btnEl.classList.add("dialog-toolbar-icon");
  681. } catch (e) {}
  682. //功能: 获取 iframeWindow(用于 click 时动态拿 API,避免 enable 时机问题)by xu 20251224
  683. var iframeWindow = null;
  684. try {
  685. iframeWindow = iframeEl && iframeEl.contentWindow;
  686. } catch (e) {}
  687. if (!iframeWindow) {
  688. try {
  689. console.log("[SsSubTabMenuMode] fail: no iframeWindow");
  690. } catch (e) {}
  691. return false;
  692. }
  693. //功能: 递归在多层 iframe 中查找 SsSubTab API(objPlay -> objInfo -> ss-sub-tab)by xu 20251224
  694. var findSsSubTabCtx = function (win, depth) {
  695. //功能 by xu 20251224
  696. if (!win) return null;
  697. if (depth > 6) return null;
  698. try {
  699. var api =
  700. (win.SS && win.SS.dom && win.SS.dom.ssSubTabApi) ||
  701. (win.ss && win.ss.dom && win.ss.dom.ssSubTabApi);
  702. var left =
  703. win.document &&
  704. win.document.querySelector &&
  705. win.document.querySelector(".project-edit-container .left-side");
  706. if (api && api.toggleMenuMode && left) {
  707. return { win: win, api: api, leftSide: left };
  708. }
  709. } catch (e) {}
  710. try {
  711. var ifs =
  712. win.document && win.document.getElementsByTagName
  713. ? win.document.getElementsByTagName("IFRAME")
  714. : [];
  715. if (!ifs || !ifs.length) return null;
  716. // 限制扫描数量,避免极端页面卡顿 by xu 20251224
  717. var maxScan = Math.min(ifs.length, 30);
  718. for (var i = 0; i < maxScan; i++) {
  719. var cw = null;
  720. try {
  721. cw = ifs[i].contentWindow;
  722. } catch (e) {
  723. cw = null;
  724. }
  725. if (!cw) continue;
  726. var r = findSsSubTabCtx(cw, depth + 1);
  727. if (r) return r;
  728. }
  729. } catch (e) {}
  730. return null;
  731. };
  732. var updateIcon = function () {
  733. //功能 by xu 20251224
  734. // dhtmlx hover/active 会切换 class(_default/_over_default 等),这里每次取当前节点 by xu 20251224
  735. var currentBtnEl = null;
  736. try {
  737. currentBtnEl = winEl.querySelector(
  738. "div[class*='dhtmlx_button_ssSubTabMenuMode_']"
  739. );
  740. } catch (e) {}
  741. if (!currentBtnEl || !currentBtnEl.classList) return;
  742. //功能: 优先从 topWindow 的 apiMap 取(解决 objPlay->objInfo 这种多层iframe拿不到 SS 的问题)by xu 20251224
  743. var ctx = null;
  744. try {
  745. var apiFromTop =
  746. wd.topWindow &&
  747. wd.topWindow.__ssSubTabApiMap &&
  748. wd.topWindow.__ssSubTabApiMap[wdDialogId];
  749. if (apiFromTop && apiFromTop.toggleMenuMode) {
  750. ctx = { api: apiFromTop, leftSide: null };
  751. }
  752. } catch (e) {}
  753. if (!ctx) {
  754. ctx = findSsSubTabCtx(iframeWindow, 0);
  755. }
  756. var mode = "collapse";
  757. try {
  758. mode =
  759. (ctx && ctx.api && ctx.api.getMenuMode && ctx.api.getMenuMode()) ||
  760. (ctx && ctx.leftSide && ctx.leftSide.getAttribute("data-mode")) ||
  761. "collapse";
  762. } catch (e) {}
  763. currentBtnEl.classList.add("dialog-toolbar-icon");
  764. //功能: icon-base 图标名调整:弹窗顶部菜单模式按钮 icon-autoTxt / icon-fix by xu 20251224
  765. currentBtnEl.classList.remove("icon-autoTxt", "icon-fix");
  766. if (mode === "fixed") {
  767. currentBtnEl.classList.add("icon-fix");
  768. currentBtnEl.setAttribute("title", "固定菜单");
  769. } else {
  770. currentBtnEl.classList.add("icon-autoTxt");
  771. currentBtnEl.setAttribute("title", "悬浮菜单");
  772. }
  773. };
  774. //功能: 用事件委托绑定点击(避免 dhtmlx 切换 class/替换节点导致点击失效)by xu 20251224
  775. try {
  776. var btnsEl = winEl.querySelector("div.dhtmlx_wins_btns");
  777. if (btnsEl && btnsEl.getAttribute("data-ss-sub-tab-menu-bound") !== "1") {
  778. btnsEl.setAttribute("data-ss-sub-tab-menu-bound", "1");
  779. btnsEl.addEventListener(
  780. "click",
  781. function (e) {
  782. try {
  783. var t = e && e.target;
  784. var hit =
  785. t && t.closest
  786. ? t.closest("div[class*='dhtmlx_button_ssSubTabMenuMode_']")
  787. : null;
  788. if (!hit) return;
  789. //功能: 优先从 topWindow 的 apiMap 取(解决 objPlay->objInfo)by xu 20251224
  790. var ctx = null;
  791. var ssSubTabApi = null;
  792. try {
  793. ssSubTabApi =
  794. wd.topWindow &&
  795. wd.topWindow.__ssSubTabApiMap &&
  796. wd.topWindow.__ssSubTabApiMap[wdDialogId];
  797. } catch (ee) {
  798. ssSubTabApi = null;
  799. }
  800. if (ssSubTabApi && ssSubTabApi.toggleMenuMode) {
  801. ctx = { api: ssSubTabApi };
  802. } else {
  803. ctx = findSsSubTabCtx(iframeWindow, 0);
  804. ssSubTabApi = ctx && ctx.api;
  805. }
  806. if (!ssSubTabApi || !ssSubTabApi.toggleMenuMode) {
  807. try {
  808. console.log(
  809. "[SsSubTabMenuMode] click but api not ready",
  810. "href=",
  811. iframeWindow.location && iframeWindow.location.href,
  812. "foundCtx=",
  813. !!ctx
  814. );
  815. } catch (ee) {}
  816. return;
  817. }
  818. //功能: 打印调试信息(点击事件触发)by xu 20251224
  819. try {
  820. console.log(
  821. "[SsSubTabMenuMode] click, before=",
  822. ssSubTabApi.getMenuMode && ssSubTabApi.getMenuMode()
  823. );
  824. } catch (ee) {}
  825. try {
  826. ssSubTabApi.toggleMenuMode();
  827. } catch (ee) {
  828. console.log(ee);
  829. }
  830. try {
  831. console.log(
  832. "[SsSubTabMenuMode] click, after=",
  833. ssSubTabApi.getMenuMode && ssSubTabApi.getMenuMode()
  834. );
  835. } catch (ee) {}
  836. setTimeout(updateIcon, 0);
  837. } catch (ee) {
  838. console.log(ee);
  839. }
  840. },
  841. false
  842. );
  843. }
  844. } catch (e) {}
  845. updateIcon();
  846. try {
  847. btn && btn.show && btn.show();
  848. } catch (e) {}
  849. return true;
  850. } catch (e) {
  851. console.log(e);
  852. return false;
  853. }
  854. };
  855. /**
  856. * 将url中的动态参数替换成指定的值
  857. * 如果param为空,则参数的值在html元素中寻找,如果param的值不为空,则在param中获取
  858. * 对于现在的服务调用,采用匹配进行
  859. * @service{name:"xxx",dest:"xxx",param:{"xxx":"xxx","data":"wdVal{data}"}}@
  860. * 中的"data":"wdVal{data}"
  861. * 如果要添加额外变量参数,有两种方法
  862. * 1.在html中 添加 input标签 name对应 data,把需要的值传入value(即是用element获取) <input name="data">
  863. * 2.如果是js变量,通过传入json变量覆盖,例:
  864. * var json = JSON.parse('{"data":"' + encodeURI(obj) + '"}');
  865. * var url = '@service{name:"cd_ydck",dest:"cd_ydck",show:"wdDialog",param:{"cdydid":"wdVal{data}"}}@';
  866. * url = wd.display.replaceDynamicParam(url, json);
  867. * eval(url);
  868. */
  869. wd.display.replaceDynamicParam = function (url, param) {
  870. /* 再改,规范 wdVal{ 命名。Lin
  871. var reg = /wdVal\{\s*[A-Za-z0-9_]*\s*\}/g;
  872. */ var reg = /ssVal\{\s*[A-Za-z0-9_]*\s*\}/g;
  873. //如果没有匹配的动态参数
  874. if (!reg.test(url)) {
  875. return url;
  876. } else {
  877. var result = url.match(reg);
  878. for (var i = 0; i < result.length; i++) {
  879. var source = result[i];
  880. //获取动态参数的name
  881. var name = source.trim().substring(6, source.trim().length - 1);
  882. //增加空字符串的可能性
  883. if (param && param[name] != undefined) {
  884. url = url.replace(source, param[name]);
  885. } else {
  886. var value = document.getElementsByName(name)[0].value;
  887. url = url.replace(source, value);
  888. }
  889. }
  890. return url;
  891. }
  892. };
  893. wd.display.Yi = 49;
  894. wd.display.Xi = 23;
  895. wd.display.addDialogLine = function (w) {
  896. if (!w) {
  897. var wdDialogId = wd.display.getwdDialogId();
  898. w = wd.topWindow.dhxWins.window(wdDialogId);
  899. }
  900. $(w)
  901. .find(".dhtmlx_wins_body_inner")
  902. .removeClass("dhtmlx_wins_body_inner_noborder")
  903. .addClass("dhtmlx_wins_body_inner_border");
  904. };
  905. wd.display.removeDialogLine = function (w) {
  906. if (!w) {
  907. var wdDialogId = wd.display.getwdDialogId();
  908. w = wd.topWindow.dhxWins.window(wdDialogId);
  909. }
  910. $(w)
  911. .find(".dhtmlx_wins_body_inner")
  912. .removeClass("dhtmlx_wins_body_inner_border")
  913. .addClass("dhtmlx_wins_body_inner_noborder");
  914. };
  915. /**
  916. * 方法中文名:切换DOM元素显示 显示第二个参数数组指定的所有DOM元素,隐藏第三个参数数组指定的所有DOM元素,
  917. * 第四个参数为选填,如果填了,则第二个参数中的第一个iframe将加载此参数(url)指定的页面
  918. *
  919. *
  920. * demo:
  921. * wd.display.showComponent({show:[{"name":"wdDialog","size":"450*380"}],hide:[],url:"/service?wdApplication=jw&wdService=ty_gg_ck&wdOutputComponent=44786&wdtest=false&ggid=44000059",dest:"gg.ty_gg_ck",title:"查看",width:450,high:380,wdDialogId:44786,form:""})
  922. * wd.display.showComponent({show:["wdDialog"],hide:[],url:"/service?wdApplication=wd&wdService=grxx_shlist&wdToken=689&wdOutputComponent=44983&wdtest=false&sqid=44438",dest:"shqk",title:"审核情况件",width:500,high:300,wdDialogId:44983,form:""})
  923. *
  924. */
  925. wd.display.showComponent = function (params) {
  926. if (
  927. typeof beacon != "undefined" &&
  928. beacon.shouldOpenOtherBrowser &&
  929. beacon.shouldOpenOtherBrowser()
  930. ) {
  931. var url = params.url;
  932. if (url.startsWith("/")) {
  933. url = window.location.origin + url;
  934. }
  935. beacon.openWindow(params.title, params.width, params.height, url);
  936. return;
  937. }
  938. // 加载鼠标动画 by SPACE 2019-04-02
  939. wd.display.showLoad();
  940. //alert(top.window.document.querySelector('iframe[name="win2"]'));
  941. if (window.event) {
  942. if (window.event.stopPropagation) {
  943. window.event.stopPropagation();
  944. } else {
  945. window.event.cancelBubble = true;
  946. }
  947. }
  948. var fullScreenLimitHeight = true; // 全屏时窗口的高度与window.innerHeight一致
  949. var showNameOrId = params.show; // 由需要显示的DOM元素的NAME或ID组成的数组或字符串,注意:
  950. // 如果含有值’wdDialog’,则弹出dhtmlxWindows窗口,否则只是切换部件显示
  951. var hideNameOrId = params.hide; // 由需要隐藏的DOM元素的NAME或ID组成的数组或字符串(可选参数,可以不填)
  952. if (!params["getSize"]) {
  953. params["getSize"] = "1";
  954. params["wdDialogId"] = new Date().getTime();
  955. /* 再改,规范 &token= 命名。Lin
  956. * IDEA = Redundant character escape '\=' in RegExp
  957. * IDEA = Redundant character escape '\&' in RegExp
  958. var exec = /token\=([^\&]*)/.exec(params.url)
  959. */ var exec = /ssToken=([^&]*)/.exec(params.url);
  960. if (exec) {
  961. $.ajax({
  962. url: "/service?ssServ=loadPageParm",
  963. data: {
  964. tokenstring: exec[1],
  965. },
  966. async: true,
  967. timeout: 10000,
  968. type: "POST",
  969. dataType: "json",
  970. error: function (data) {
  971. console.log(arguments);
  972. wd.display.showComponent(params);
  973. },
  974. success: function (result) {
  975. params = $.extend(params, result, { title: params.title });
  976. wd.display.showComponent(params);
  977. },
  978. });
  979. return params["wdDialogId"];
  980. }
  981. }
  982. var url = wd.display.replaceDynamicParam(params.url); // 参数showElemNameOrIdArr中的第一个iframe将加载此URL的页面(可选参数,可以不填)
  983. var width = (parseInt(params.width) || 100) + this.Xi; // 当要弹出窗口宽度,单位为px
  984. ///??? 有空再去掉参数 high -- 统一用 height???Lin ///
  985. var high =
  986. (parseInt(params.high) || parseInt(params.height) || 100) + this.Yi; // 当要弹出窗口宽度,单位为px
  987. var showTitle = params.showTitle || false;
  988. //弹出窗口自适应高度
  989. if (!!params.minHeight && !!params.maxHeight) {
  990. params.minHeight = parseInt(params.minHeight);
  991. params.maxHeight = parseInt(params.maxHeight);
  992. if (params.minHeight + this.Yi > wd.topWindow.innerHeight) {
  993. high = params.minHeight + this.Yi;
  994. showNameOrId = "wdFullScreen";
  995. fullScreenLimitHeight = false;
  996. } else if (params.maxHeight + this.Yi < wd.topWindow.innerHeight) {
  997. high = params.maxHeight + this.Yi;
  998. } else {
  999. /* 母体里的,showTitle="false" -- if(showTitle) 成立。Lin
  1000. * PMS 里的 showTitle=false -- if(showTitle) 不成立
  1001. * 先改为 high = wd.topWindow.innerHeight;
  1002. * 先不改 */
  1003. if (showTitle) high = wd.topWindow.innerHeight;
  1004. else showNameOrId = "wdFullScreen";
  1005. }
  1006. }
  1007. url = wd.base.setRowCountPerPage(url, high - this.Yi, width);
  1008. var title = params.title || "无题,可能没找到部件"; // 窗口标题,(可选参数,可以不填)
  1009. var form = params.form; // 需要提交的form名字
  1010. // var wdDialogId = params.wdDialogId;//部件ID
  1011. var wdDialogId = params.wdDialogId || new Date().getTime(); // 部件ID
  1012. wd.display.winWidth = width;
  1013. wd.display.winHeight = high;
  1014. if (form) {
  1015. wd.topWindow.wd.display.targetForm =
  1016. window.document.getElementsByName(form)[0];
  1017. wd.topWindow.wd.display.targetUrl = url;
  1018. url = "/wd/js/cloneForm/cloneForm.jsp";
  1019. }
  1020. if (title) {
  1021. // title = '<span style="font:14px
  1022. // \'宋体\'\;line-height:30px;" >'+title+'</span>';
  1023. title =
  1024. '<span style="padding:5px;">' +
  1025. '<a class="dialog-title" target="_blank" onclick="return false;" href="' +
  1026. url +
  1027. "&wdTitle=" +
  1028. title +
  1029. '">' +
  1030. title +
  1031. "</a>" +
  1032. '<a class="secondTitle" target="_blank" onclick="return false;" href="javascript:void(0);"></a>' +
  1033. "</span>";
  1034. }
  1035. if (showNameOrId) {
  1036. // 如果需要显示部件
  1037. if (typeof showNameOrId != "object") {
  1038. // 如果传入的不是数组
  1039. var arr = [];
  1040. arr.push(showNameOrId);
  1041. showNameOrId = arr; // 统一为数组
  1042. }
  1043. var useUrl = true;
  1044. var hasWdDialog = false;
  1045. for (var i = 0; i < showNameOrId.length; i++) {
  1046. var oneNameOrId = showNameOrId[i];
  1047. if (oneNameOrId == "wdDialog") {
  1048. // 这里应该不是 <wdDialog。Lin
  1049. hasWdDialog = true;
  1050. break;
  1051. }
  1052. }
  1053. for (var i = 0; i < showNameOrId.length; i++) {
  1054. var oneNameOrId = showNameOrId[i];
  1055. var selfParam = oneNameOrId.self;
  1056. var titleParam = oneNameOrId.title;
  1057. var nameParam = oneNameOrId.name;
  1058. var sizeParam = oneNameOrId.size;
  1059. var positionParam = oneNameOrId.position;
  1060. var btnParam = oneNameOrId.button;
  1061. // wd.display.showComponent({show:[{"name":"wdDialog","size":"450*380"}],hide:[],url:"/service?wdApplication=jw&wdService=ty_gg_ck&wdOutputComponent=44786&wdtest=false&ggid=44000059",dest:"gg.ty_gg_ck",title:"查看",width:450,high:380,wdDialogId:44786,form:""})
  1062. if (typeof oneNameOrId == "object") {
  1063. if (oneNameOrId.size) {
  1064. var arr = oneNameOrId.size.split("*");
  1065. var width = parseInt(arr[0]) + 15; // 当要弹出窗口宽度,单位为px
  1066. var high = parseInt(arr[1]) + 38; // 当要弹出窗口宽度,单位为px
  1067. }
  1068. oneNameOrId = oneNameOrId.name;
  1069. }
  1070. var storage = window.localStorage;
  1071. if (oneNameOrId == "wdDialog") {
  1072. // "如果要弹出窗口"。这里应该不是 <wdDialog。Lin
  1073. // 把当前窗口的window对象,保存到wd.topWindow窗口中,以便关闭窗口时使用
  1074. if (!wd.topWindow.wd.display.wdDialogOpeners)
  1075. wd.topWindow.wd.display.wdDialogOpeners = {};
  1076. wd.topWindow.wd.display.wdDialogOpeners[wdDialogId] = window;
  1077. var windowId = wdDialogId;
  1078. // /当前可视区域
  1079. var sw = wd.topWindow.screen.availWidth;
  1080. var sh = wd.topWindow.screen.availHeight;
  1081. // 根据可是区域调整窗口
  1082. var cenFlag = false; // 超过时不居中
  1083. if (width > sw - 20) {
  1084. width = sw - 20;
  1085. }
  1086. if (high > sh - 20) high = sh - 20;
  1087. if (width > sw || high > sh) cenFlag = true;
  1088. // /
  1089. if (!wd.topWindow.dhxWins)
  1090. wd.topWindow.dhxWins = new wd.topWindow.dhtmlXWindows();
  1091. var w = wd.topWindow.dhxWins.createWindow(windowId, 0, 0, width, high);
  1092. w.keepInViewport(true); // 保持在窗口内
  1093. if (!cenFlag) w.center(); // 居中
  1094. w.setText(title); // 设置窗口标题
  1095. //2021-09-06 新增,当url超长时候,改成form提交
  1096. var hasInvalidUrlChar = false;
  1097. var invalidUrlChar = ["{", "}", "[", "]", "|"];
  1098. for (var _ici = 0; _ici < invalidUrlChar.length; _ici++) {
  1099. if (url.indexOf(invalidUrlChar[_ici]) > -1) {
  1100. hasInvalidUrlChar = true;
  1101. break;
  1102. }
  1103. }
  1104. if (hasInvalidUrlChar || (url && url.length > 1000)) {
  1105. hasInvalidUrlChar && console.log("url中有非法字符");
  1106. console.log("触发了form提交表单~,url长度:" + url.length);
  1107. w.attachEvent("onContentLoaded", function () {
  1108. try {
  1109. if (this.getFrame().getAttribute("formload")) {
  1110. return;
  1111. }
  1112. var myDoc = this.getFrame().contentDocument;
  1113. var index = url.indexOf("?");
  1114. index = index < 0 ? url.length - 1 : index;
  1115. var base = url.substring(0, index);
  1116. var params = url.substring(index + 1);
  1117. var paramarr = params.split("&");
  1118. var myform = myDoc.createElement("form");
  1119. myform.setAttribute("action", base);
  1120. myform.setAttribute("method", "post");
  1121. myDoc.body.appendChild(myform);
  1122. for (var pi = 0; pi < paramarr.length; pi++) {
  1123. var pstr = paramarr[pi];
  1124. var pei = pstr.indexOf("=");
  1125. pei = pei < 0 ? pstr.length : pei;
  1126. var k = pstr.substring(0, pei);
  1127. var v = pstr.substring(pei + 1);
  1128. var myInput = myDoc.createElement("input");
  1129. myInput.setAttribute("type", "hidden");
  1130. myInput.setAttribute("name", k);
  1131. myInput.value = decodeURIComponent(v); //可能会有url编码了的情况
  1132. myform.appendChild(myInput);
  1133. }
  1134. myform.submit();
  1135. this.getFrame().setAttribute("formload", "true");
  1136. } catch (e) {
  1137. console.error(e);
  1138. }
  1139. });
  1140. w.attachURL("javascript:false;");
  1141. } else {
  1142. w.attachURL(url); // 跳到此URL
  1143. }
  1144. useUrl = false;
  1145. w.setModal(true); // 设置模式窗口
  1146. w.bringToTop(); // 置顶
  1147. wd.display.addWdUserButton(w);
  1148. wd.display.addComponentEvent(w);
  1149. wd.display.addDialogLine(w);
  1150. // 改变按钮的类样式名
  1151. // var buttonType = wd.display.wdButtons;
  1152. // for (var i = 0; i < buttonType.length; i++) {
  1153. // w.button(buttonType[i][0]).className = "dhtmlx_wins_btns_button " + buttonType[i][4];
  1154. // }
  1155. // 隐藏不需要的按钮
  1156. w.clearIcon();
  1157. if (w.button("help")) w.button("help").hide();
  1158. if (w.button("stick")) w.button("stick").hide();
  1159. if (w.button("sticked")) w.button("sticked").hide();
  1160. if (w.button("park")) w.button("park").hide();
  1161. if (w.button("minmax1"))
  1162. // 隐藏最大化按钮
  1163. w.button("minmax1").hide();
  1164. w.denyResize(); // 不允许改变大小
  1165. // if(w.button('close'))
  1166. // w.button('close').hide();
  1167. // w.btns.help.title = "帮助";
  1168. w.button("close").setAttribute("title", "关闭"); // 修改关闭按钮提示
  1169. var containerObj = wd.topWindow.wd.display;
  1170. var currentDialogZIndex = w.zi; // 弹出窗口的z-index
  1171. wd.display.dxwindowsCreateMaskDiv(currentDialogZIndex);
  1172. w.attachEvent("onClose", function (win) {
  1173. wd.display.dxwindowsCloseMaskDiv();
  1174. /*
  1175. * var parentDialog =
  1176. * wd.topWindow.dhxWins.window(parentWdDialogId); if(typeof
  1177. * parentDialog != 'undefined' && parentDialog ){
  1178. * //parentDialog.button('close').enable(); }
  1179. */
  1180. // var iframeObj = $(win).find('iframe')[0];
  1181. function findIframe(dom) {
  1182. for (var i = 0; i < dom.childNodes.length; i++) {
  1183. var c = dom.childNodes[i];
  1184. if (c.tagName == "IFRAME") {
  1185. return c;
  1186. }
  1187. var temp = findIframe(c);
  1188. if (temp) return temp;
  1189. }
  1190. }
  1191. try {
  1192. var iframeObj = findIframe(win);
  1193. var popWindow = iframeObj.contentWindow;
  1194. // 调用关闭窗口时调用的回调方法
  1195. if (
  1196. typeof popWindow != "undefined" &&
  1197. popWindow.wd.display.closeDialogCallbackFun
  1198. ) {
  1199. popWindow.wd.display.closeDialogCallbackFun();
  1200. }
  1201. wd.display.onCloseDialog(win, popWindow);
  1202. } catch (e) {
  1203. console.log(e);
  1204. }
  1205. return true;
  1206. });
  1207. } else if (oneNameOrId == "wdFullScreen") {
  1208. // 如果只是显示功能部件
  1209. if (!wd.topWindow.dhxWins)
  1210. wd.topWindow.dhxWins = new wd.topWindow.dhtmlXWindows();
  1211. if (!wd.topWindow.wd.display.wdDialogOpeners)
  1212. wd.topWindow.wd.display.wdDialogOpeners = {};
  1213. wd.topWindow.wd.display.wdDialogOpeners[wdDialogId] = window;
  1214. var w = wd.topWindow.dhxWins.createWindow(
  1215. wdDialogId,
  1216. 0,
  1217. 0,
  1218. width,
  1219. high
  1220. );
  1221. w.keepInViewport(true); // 保持在窗口内
  1222. w.attachURL(url); // 跳到此URL
  1223. w.setModal(true); // 设置模式窗口
  1224. w.bringToTop(); // 置顶
  1225. w.setText(title);
  1226. w.clearIcon();
  1227. w.hideMenu();
  1228. w.hideToolbar();
  1229. w.center(); //窗口居中
  1230. wd.display.addWdUserButton(w);
  1231. wd.display.addComponentEvent(w);
  1232. wd.display.hideAllWdUserButton(w);
  1233. wd.display.addDialogLine(w);
  1234. var winbody;
  1235. var Pbtn = w.button("close").parentNode; //关闭按钮的父节点
  1236. var titleline = w.childNodes[0].childNodes[2]; //获取到标题元素
  1237. var btns = w.childNodes[0].childNodes[3];
  1238. var odiv = document.createElement("div"); //创建一个新的元素div,用于存放btn div以及标题的div
  1239. w.childNodes[0].appendChild(odiv);
  1240. odiv.style.height = 43 + "px"; //给新元素进行设置样式
  1241. odiv.style.position = "absolute";
  1242. // odiv.style.display = 'none';
  1243. odiv.id = "odiv";
  1244. odiv.style.top = 0;
  1245. odiv.style.width = "100%";
  1246. odiv.style.backgroundColor = "#ffffff";
  1247. odiv.style.zIndex = -1;
  1248. odiv.setAttribute("class", "hLine");
  1249. w.fullScreen = function () {
  1250. //初始化页面的函数
  1251. var dhwin = wd.topWindow.dhxWins;
  1252. if (fullScreenLimitHeight)
  1253. wd.topWindow.document.body.style.overflow = "hidden";
  1254. dhwin._engineGetWindowLabel(this).style.display = "none";
  1255. // alert(dhwin._engineFixWindowPosInViewport(this));
  1256. var vpw = _isIE ? document.body.offsetWidth : window.innerWidth;
  1257. var vph = _isIE ? document.body.offsetHeight : window.innerHeight;
  1258. // this.h = document.body.clientHeight;
  1259. if (fullScreenLimitHeight)
  1260. this.h = wd.topWindow.document.body.offsetHeight;
  1261. this.y = wd.topWindow.document.body.scrollTop;
  1262. // dhwin._engineFixWindowPosInViewport(this);
  1263. dhwin._engineRedrawWindowSize(this);
  1264. dhwin._engineRedrawWindowPos(this);
  1265. winbody = this.vs[this.av].dhxcont;
  1266. winbody.style.top = 0;
  1267. winbody.style.marginTop = 0;
  1268. winbody.style.height = this.h + "px";
  1269. winbody.childNodes[0].style.height = this.h + "px";
  1270. Pbtn.style.zIndex = 100;
  1271. };
  1272. w.fullScreen();
  1273. Pbtn.onmouseover = function () {
  1274. // console.log(w);
  1275. wd.display.showAllWdUserButton(w, true);
  1276. titleline.style.display = "block"; //把标题的display属性改成block,在初始化的时候全部设置成了none
  1277. odiv.style.zIndex = 99; //通过调整div的层数来对原有的信息进行覆盖
  1278. odiv.style.display = "block";
  1279. titleline.style.zIndex = 100;
  1280. };
  1281. odiv.onmouseover = function () {
  1282. this.style.display = "block";
  1283. this.style.zIndex = 99;
  1284. titleline.style.zIndex = 100;
  1285. };
  1286. titleline.onmouseover = function () {
  1287. odiv.style.zIndex = 99;
  1288. odiv.style.display = "block";
  1289. this.style.zIndex = 100;
  1290. };
  1291. Pbtn.onmouseout = function (e) {
  1292. if (!e) e = window.event;
  1293. var reltg = e.relatedTarget ? e.relatedTarget : e.toElement;
  1294. if (reltg.id != "odiv") {
  1295. odiv.style.zIndex = -1;
  1296. odiv.style.display = "none";
  1297. w.childNodes[0].childNodes[2].style.display = "none"; //鼠标离开时进行还原
  1298. wd.display.hideAllWdUserButton(w);
  1299. } else {
  1300. titleline.style.display = "block";
  1301. }
  1302. };
  1303. odiv.onmouseout = function (e) {
  1304. if (!e) e = window.event;
  1305. var reltg = e.relatedTarget ? e.relatedTarget : e.toElement;
  1306. // if (reltg.className == "dhtmlx_wins_btns_button dhtmlx_button_wdTab_default") { //判定离开新元素是否到了按钮
  1307. // titleline.style.display = "block"
  1308. // } else
  1309. if (reltg.className == "dhtmlx_wins_title") {
  1310. //判定离开了新元素是否到了title元素
  1311. titleline.style.display = "block";
  1312. } else {
  1313. odiv.style.zIndex = -1;
  1314. odiv.style.display = "none";
  1315. w.childNodes[0].childNodes[2].style.display = "none";
  1316. wd.display.hideAllWdUserButton(w);
  1317. }
  1318. };
  1319. titleline.onmouseout = function (e) {
  1320. if (!e) e = window.event;
  1321. var reltg = e.relatedTarget ? e.relatedTarget : e.toElement;
  1322. if (reltg.id == "odiv") {
  1323. titleline.style.display = "block";
  1324. } else {
  1325. odiv.style.zIndex = -1;
  1326. odiv.style.display = "none";
  1327. w.childNodes[0].childNodes[2].style.display = "none"; //鼠标离开时进行还原
  1328. wd.display.hideAllWdUserButton(w);
  1329. }
  1330. };
  1331. wd.display.hideAllWdUserButton(w);
  1332. w.button("close").setAttribute("title", "关闭");
  1333. //以上是对鼠标的走向进行判定
  1334. w.attachEvent("onClose", function (win) {
  1335. wd.topWindow.document.body.style.overflow = "auto";
  1336. wd.display.dxwindowsCloseMaskDiv();
  1337. function findIframe(dom) {
  1338. for (var i = 0; i < dom.childNodes.length; i++) {
  1339. var c = dom.childNodes[i];
  1340. if (c.tagName == "IFRAME") {
  1341. return c;
  1342. }
  1343. var temp = findIframe(c);
  1344. if (temp) return temp;
  1345. }
  1346. }
  1347. try {
  1348. var iframeObj = findIframe(win);
  1349. var popWindow = iframeObj.contentWindow;
  1350. // 调用关闭窗口时调用的回调方法
  1351. if (
  1352. typeof popWindow != "undefined" &&
  1353. popWindow.wd.display.closeDialogCallbackFun
  1354. ) {
  1355. popWindow.wd.display.closeDialogCallbackFun();
  1356. }
  1357. wd.display.onCloseDialog(win, popWindow);
  1358. } catch (e) {
  1359. console.log(e);
  1360. }
  1361. return true;
  1362. });
  1363. var currentDialogZIndex = w.zi;
  1364. wd.display.dxwindowsCreateMaskDiv(currentDialogZIndex);
  1365. } else if (showNameOrId == "wdhelpdialog") {
  1366. console.log("wdhelpdialog");
  1367. if (!wd.topWindow.dhxWins)
  1368. wd.topWindow.dhxWins = new wd.topWindow.dhtmlXWindows();
  1369. if (!wd.topWindow.wd.display.wdDialogOpeners)
  1370. wd.topWindow.wd.display.wdDialogOpeners = {};
  1371. wd.topWindow.wd.display.wdDialogOpeners[wdDialogId] = window;
  1372. var w;
  1373. //判断窗口是否已关闭
  1374. if (wd.topWindow.wdhelpdialog && wd.topWindow.wdhelpdialog.id) {
  1375. w = wd.topWindow.wdhelpdialog;
  1376. } else {
  1377. // x,y控制弹窗口位置
  1378. w = wd.topWindow.dhxWins.createWindow(
  1379. wdDialogId,
  1380. params.x,
  1381. params.y,
  1382. width,
  1383. high
  1384. );
  1385. wd.topWindow.wdhelpdialog = w;
  1386. }
  1387. if (params.center) {
  1388. w.center(); //窗口居中
  1389. }
  1390. w.attachHTMLString(url); // 跳到此URL
  1391. w.keepInViewport(true); // 保持在窗口内
  1392. // w.setModal(true); // 设置模式窗口
  1393. w.bringToTop(); // 置顶
  1394. w.setText(title);
  1395. w.clearIcon();
  1396. // w.denyResize()
  1397. // w.hideMenu();
  1398. // w.hideToolbar();
  1399. wd.display.addWdUserButton(w);
  1400. // w.addUserButton("wdHelp_copyhashcode", 3, "复制代码", "复制代码")
  1401. w.button("wdHelp_copyhashcode").onclick = function () {
  1402. var isRTL = document.documentElement.getAttribute("dir") == "rtl";
  1403. var fakeElem = document.createElement("textarea");
  1404. // Prevent zooming on iOS
  1405. fakeElem.style.fontSize = "12pt";
  1406. // Reset box model
  1407. fakeElem.style.border = "0";
  1408. fakeElem.style.padding = "0";
  1409. fakeElem.style.margin = "0";
  1410. // Move element out of screen horizontally
  1411. fakeElem.style.position = "absolute";
  1412. fakeElem.style[isRTL ? "right" : "left"] = "-9999px";
  1413. // Move element to the same position vertically
  1414. fakeElem.style.top =
  1415. (window.pageYOffset || document.documentElement.scrollTop) + "px";
  1416. fakeElem.setAttribute("readonly", "");
  1417. fakeElem.value = params.helpHaShCode;
  1418. document.body.appendChild(fakeElem);
  1419. fakeElem.select();
  1420. var succeeded;
  1421. try {
  1422. succeeded = document.execCommand("copy");
  1423. alert("复制成功");
  1424. } catch (err) {
  1425. succeeded = false;
  1426. alert("复制失败");
  1427. }
  1428. removeFake(fakeElem);
  1429. return succeeded;
  1430. };
  1431. if (params.pin) {
  1432. //已锁定
  1433. w.denyMove();
  1434. w.button("wdHelp_pin").hide();
  1435. w.button("close").show();
  1436. } else {
  1437. //未锁定
  1438. w.button("wdHelp_unpin").show();
  1439. w.button("close").hide();
  1440. w.allowMove();
  1441. wd.topWindow.setTimeout(function () {
  1442. if (w.isMovable()) {
  1443. w.close();
  1444. }
  1445. }, 3000);
  1446. }
  1447. w.button("wdHelp_unpin").onclick = function () {
  1448. w.button("close").show();
  1449. w.denyMove();
  1450. this.hide();
  1451. w.button("wdHelp_pin").hide();
  1452. };
  1453. w.button("wdHelp_pin").onclick = function () {
  1454. w.button("close").hide();
  1455. w.allowMove();
  1456. this.hide();
  1457. w.button("wdHelp_unpin").hide();
  1458. setTimeout(function () {
  1459. if (w.isMovable()) {
  1460. w.close();
  1461. }
  1462. }, 5000);
  1463. };
  1464. return w.getId();
  1465. }
  1466. }
  1467. } // end if
  1468. if (hideNameOrId) {
  1469. // 如果有需要隐藏的DOM元素
  1470. // 显示所有DOM元素
  1471. for (var i = 0; i < hideNameOrId.length; i++) {
  1472. var elem = wd.c.g(hideElemNameOrIdArr[i], windowObj);
  1473. elem.style.display = "none";
  1474. var p = elem.parentNode;
  1475. if (p && p.tagName == "DIV") {
  1476. p.style.display = "none";
  1477. }
  1478. }
  1479. }
  1480. //允许所有iframe全屏
  1481. var arr = wd.topWindow.document.getElementsByTagName("IFRAME");
  1482. for (var i = 0; i < arr.length; i++) {
  1483. var iframeObj = arr[i];
  1484. iframeObj.setAttribute("allowfullscreen", true);
  1485. }
  1486. // w.button("wdHelp").show()
  1487. // w.button("wdShare").show()
  1488. // w.button("wdRecord").show()
  1489. return wdDialogId;
  1490. };
  1491. /**
  1492. *
  1493. * 设置当前iframe部件的长宽
  1494. */
  1495. wd.display.changeDxwindowDimension = function (width, height) {
  1496. //wd.topWindow.dhxWins.
  1497. //刷新弹出本窗口的窗口
  1498. if (null != wd.display.getwdDialogOpener) wd.display.refreshOpener();
  1499. //获得弹出部件window对象,通过创建时的部件id
  1500. var wdDialogId = wd.display.getwdDialogId();
  1501. var win = wd.topWindow.dhxWins.window(wdDialogId);
  1502. //myWins.window(id).setDimension(int width, int height);
  1503. win.setDimension(width, height);
  1504. win.keepInViewport(true); // 保持在窗口内
  1505. win.center(); // 居中
  1506. };
  1507. /**
  1508. *
  1509. * @param {}
  1510. * currentDialogZIndex:当前弹出窗口的zIndex
  1511. */
  1512. wd.display.dxwindowsCreateMaskDiv = function (currentDialogZIndex) {
  1513. var containerObj = wd.topWindow.wd.display;
  1514. var topWindow = wd.topWindow;
  1515. wd.display.createMaskDiv(containerObj, topWindow, currentDialogZIndex);
  1516. };
  1517. // 关闭wddialog时,移除遮罩层
  1518. wd.display.dxwindowsCloseMaskDiv = function () {
  1519. var containerObj = wd.topWindow.wd.display.mask;
  1520. var currentMaskEleID = containerObj.pop();
  1521. var currMaskEle = wd.topWindow.document.getElementById(currentMaskEleID);
  1522. if (typeof currMaskEle != "undefined" && currMaskEle) {
  1523. if (typeof currMaskEle.remove != "undefined") {
  1524. currMaskEle.remove();
  1525. } else {
  1526. currMaskEle.parentNode.removeChild(currMaskEle);
  1527. }
  1528. }
  1529. };
  1530. //获取当前窗口对应的dhxWin对象
  1531. wd.display.getwdDialogWindows = function (dialogid) {
  1532. /**
  1533. * 根据是否找到wdDialogId判断当前页面在弹窗中或应用页面
  1534. *
  1535. */
  1536. var wdDialogId = wd.display.getwdDialogId();
  1537. if (dialogid) wdDialogId = dialogid;
  1538. var win = wd.topWindow.dhxWins.window(wdDialogId);
  1539. return win;
  1540. };
  1541. // 如果当前为通过wdDialog弹出的窗口页面,调用此方法返回包含本窗口的iframe
  1542. wd.display.getwdDialogId = function (winUnderIframe) {
  1543. if (!winUnderIframe) {
  1544. winUnderIframe = window;
  1545. }
  1546. var arr = wd.topWindow.document.getElementsByTagName("IFRAME");
  1547. var wdDialogId = null;
  1548. for (var i = 0; i < arr.length; i++) {
  1549. var iframeObj = arr[i];
  1550. var cw = iframeObj.contentWindow;
  1551. var tempId = iframeObj.getAttribute("wdDialogId");
  1552. if (cw == winUnderIframe) {
  1553. if (tempId != null) {
  1554. // 如果找到包含本窗口的iframe,ie走这里
  1555. wdDialogId = tempId;
  1556. break;
  1557. } else if (iframeObj.dataset) {
  1558. // chrome走这里
  1559. if (iframeObj.dataset["wdDialogId"]) {
  1560. wdDialogId = iframeObj.dataset["wdDialogId"];
  1561. break;
  1562. }
  1563. }
  1564. }
  1565. }
  1566. if (!wdDialogId) {
  1567. //最顶层页面跳出循环
  1568. if (winUnderIframe == wd.topWindow) return null;
  1569. wdDialogId = wd.display.getwdDialogId(winUnderIframe.parent);
  1570. }
  1571. return wdDialogId;
  1572. };
  1573. // 如果当前为通过wdDialog弹出的窗口页面,调用此方法返回弹出本窗口的原窗口window对象
  1574. wd.display.getwdDialogOpener = function () {
  1575. var wdDialogId = wd.display.getwdDialogId();
  1576. return wd.topWindow.wd.display.wdDialogOpeners[wdDialogId];
  1577. };
  1578. // 刷新弹出本窗口的窗口
  1579. wd.display.refreshOpener = function () {
  1580. // //全屏模式下,按确定按钮关闭全屏模式
  1581. // var fullFiv = wd.topWindow.document.querySelector("#wdfullscreen");
  1582. // if (fullFiv) {
  1583. // fullFiv.parentNode.removeChild(fullFiv);
  1584. // }
  1585. try {
  1586. // 刷新原窗口页面
  1587. var wdDialogOpener = wd.display.getwdDialogOpener(); // 获得原窗口window对象
  1588. if (wd.topWindow == wdDialogOpener) {
  1589. return;
  1590. }
  1591. //执行自定义刷新方法(需要打开窗口定义wdRefresh)
  1592. if (wdDialogOpener.wdRefresh) {
  1593. wdDialogOpener.wdRefresh();
  1594. return;
  1595. }
  1596. //执行默认刷新方法
  1597. var forms = wdDialogOpener.document.getElementsByTagName("FORM");
  1598. //提交表单
  1599. if (forms && forms.length > 0 && forms[0].action) {
  1600. if (forms.length == 1) {
  1601. var f = forms[0];
  1602. f.submit();
  1603. }
  1604. //刷新个人首页部件
  1605. } else {
  1606. if (
  1607. typeof wdDialogOpener.SYBJCTRL != "undefined" &&
  1608. wdDialogOpener.SYBJCTRL
  1609. ) {
  1610. // 个人首页分支 by Rd 2016-01-13
  1611. // 通过刷新调用窗口的部件来替代刷新整个调用窗口
  1612. wdDialogOpener.SYBJCTRL.EventCtrl.FlushBj();
  1613. } else {
  1614. wdDialogOpener.location.reload();
  1615. }
  1616. }
  1617. } catch (e) {
  1618. console.log(e);
  1619. }
  1620. };
  1621. // 关闭弹出窗口
  1622. wd.display.closeDialog = function () {
  1623. try {
  1624. if (typeof beacon != "undefined") beacon.beaconCloseWindow();
  1625. } catch (e) {
  1626. console.error(e);
  1627. }
  1628. var wdDialogId = wd.display.getwdDialogId();
  1629. // console.log(wdDialogId);
  1630. // console.log(wd.topWindow.dhxWins.window(wdDialogId));
  1631. // 关闭鼠标加载动画 by SPACE 2019-04-02
  1632. wd.display.closeLoad();
  1633. // 关闭本弹出窗口
  1634. wd.topWindow.dhxWins.window(wdDialogId).close();
  1635. };
  1636. /**
  1637. * 改变对象的样式
  1638. * event:监听事件的参数--{eventIds:['1','2'],styleName:{onclick:'样式名1',onmouseover:'样式名2',onmouseout:'样式名3'}}
  1639. * eventIds: 监听事件的id数组
  1640. * styleName:样式名(className),[0]是获得点击后样式名,[1]是鼠标移过时的样式名,[2]是对象默认的样式
  1641. */
  1642. wd.display.changeTabStyle = function (param) {
  1643. /**
  1644. * 绑定监听事件 eventIds:绑定事件的id数组, eventType:绑定的事件--onclick,onmouseout等,
  1645. * styleName:样式的类名
  1646. */
  1647. var objClick = new Object();
  1648. objClick.clickId = null;
  1649. objClick.mouseoverId = null;
  1650. function onEvent(tabIds, eventType, styleNames) {
  1651. // try{
  1652. if (eventType == "onclick") {
  1653. for (var key in tabIds) {
  1654. var tagId = document.getElementById(tabIds[key]);
  1655. (function (key) {
  1656. wd.c.addEventListener(tagId, eventType, function () {
  1657. setTabCssToNormal();
  1658. var objById = this;
  1659. var objFocus = document.activeElement;
  1660. objById.className = styleNames.onclick;
  1661. objClick.clickId = tabIds[key];
  1662. });
  1663. })(key);
  1664. }
  1665. } else if (eventType == "onmouseover") {
  1666. for (var key in tabIds) {
  1667. var tagId = document.getElementById(tabIds[key]);
  1668. (function (key) {
  1669. wd.c.addEventListener(tagId, eventType, function () {
  1670. var objById = document.getElementById(tabIds[key]);
  1671. if (tabIds[key] == objClick.clickId) {
  1672. return;
  1673. }
  1674. objById.className = styleNames.onmouseover;
  1675. objClick.mouseoverId = tabIds[key];
  1676. });
  1677. })(key);
  1678. }
  1679. } else if (eventType == "onmouseout") {
  1680. for (var key in tabIds) {
  1681. var tagId = document.getElementById(tabIds[key]);
  1682. (function (key) {
  1683. wd.c.addEventListener(tagId, eventType, function () {
  1684. var objById = document.getElementById(tabIds[key]);
  1685. if (tabIds[key] == objClick.clickId) {
  1686. return;
  1687. }
  1688. objById.className = styleNames.normal;
  1689. });
  1690. })(key);
  1691. }
  1692. }
  1693. /**
  1694. * }catch(e){ alert("创建监听事件错误:"+e.message+" Type:"+e.name); }
  1695. */
  1696. }
  1697. // -----------------------
  1698. var tabIds = param.tabIds;
  1699. var styleNames = param.styleNames;
  1700. onEvent(tabIds, "onclick", styleNames);
  1701. onEvent(tabIds, "onmouseover", styleNames);
  1702. onEvent(tabIds, "onmouseout", styleNames);
  1703. function setTabCssToNormal() {
  1704. for (var i = 0; i < tabIds.length; i++) {
  1705. var tabId = tabIds[i];
  1706. document.getElementById(tabId).className = styleNames.normal;
  1707. }
  1708. }
  1709. // 设置默认对象
  1710. function setTabCssToNormalDefault() {
  1711. for (var i = 0; i < tabIds.length; i++) {
  1712. var tabId = tabIds[i];
  1713. if (i == 0) {
  1714. document.getElementById(tabId).className = styleNames.onclick;
  1715. objClick.clickId = tabId;
  1716. // objClick.clickId = tabId;
  1717. } else {
  1718. document.getElementById(tabId).className = styleNames.normal;
  1719. }
  1720. }
  1721. }
  1722. setTabCssToNormalDefault();
  1723. };
  1724. // 把当前窗口的window对象,保存到指定的窗口中,以便关闭窗口时使用
  1725. wd.display.windowToObj = function (Ele) {
  1726. if (!Ele.dom.wdDialogOpeners) Ele.dom.wdDialogOpeners = {};
  1727. Ele.dom.wdDialogOpeners[Ele.wdDialogId] = window;
  1728. };
  1729. // 为dhtmlXWindows设置参数,创建窗口
  1730. wd.display.setDhtmlXWinParam = function (winParam) {
  1731. var windowId = winParam.wdDialogId;
  1732. // /当前可视区域
  1733. var sw = winParam.dom.document.body.offsetWidth;
  1734. var sh = winParam.dom.document.body.offsetHeight;
  1735. var positionParam = winParam.positionParam;
  1736. var btnParam = winParam.btnParam;
  1737. var sizeParam = winParam.sizeParam;
  1738. var winWid;
  1739. var winHeg;
  1740. // 根据可是区域调整窗口
  1741. var cenFlag = false; // 超过时不居中
  1742. // 处理x,y
  1743. if (positionParam) {
  1744. var win_X = positionParam.split(",")[0];
  1745. var win_Y = positionParam.split(",")[1];
  1746. } else {
  1747. cenFlag = true; // 居中
  1748. }
  1749. // 处理size属性
  1750. if (!sizeParam) {
  1751. // 用户不填写size属性
  1752. winWid = wd.display.getDialogWidAndHei(wd.display.winWidth);
  1753. winHeg = wd.display.getDialogWidAndHei(wd.display.winHeight);
  1754. } else if ("max" == sizeParam) {
  1755. // 这里设置的win
  1756. // size是还原状态下的窗口大小,后面会直接调用控件的最大化方法
  1757. if (wd.topWindow == winParam.dom) {
  1758. winWidth = wd.topWindow.document.body.offsetWidth;
  1759. winHeight = wd.topWindow.document.body.offsetHeight;
  1760. } else {
  1761. winWidth = document.body.offsetWidth;
  1762. winHeight = document.body.offsetHeight;
  1763. }
  1764. winWid = wd.display.getDialogWidAndHei(winWidth);
  1765. winHeg = wd.display.getDialogWidAndHei(winHeight);
  1766. } else {
  1767. winWid = wd.display.getDialogWidAndHei(
  1768. sizeParam.split("*")[0],
  1769. document.body.offsetWidth
  1770. );
  1771. winHeg = wd.display.getDialogWidAndHei(
  1772. sizeParam.split("*")[1],
  1773. document.body.offsetHeight
  1774. );
  1775. }
  1776. // if(winParam.dom.width < winWid || winParam.dom.heigh < winHeg)
  1777. // cenFlag=true;
  1778. if (positionParam) {
  1779. var w = winParam.dom.dhxWins.createWindow(
  1780. windowId,
  1781. parseInt(win_X),
  1782. parseInt(win_Y),
  1783. winWid,
  1784. winHeg
  1785. );
  1786. } else {
  1787. var w = winParam.dom.dhxWins.createWindow(windowId, 0, 0, winWid, winHeg);
  1788. }
  1789. w.keepInViewport(true); // 保持在窗口内
  1790. if (cenFlag) w.center(); // 居中
  1791. if (winParam.title) w.setText(winParam.title); // 设置窗口标题
  1792. w.attachURL(winParam.url); // 跳到此URL
  1793. useUrl = false;
  1794. w.setModal(true); // 设置模式窗口
  1795. w.bringToTop(); // 置顶
  1796. // 隐藏不需要的按钮
  1797. wd.display.showDialogBtn(w, btnParam);
  1798. if ("max" == sizeParam) {
  1799. w.maximize();
  1800. }
  1801. // if(w.button('help'))
  1802. // w.button('help').hide();
  1803. // if(w.button('stick'))
  1804. // w.button('stick').hide();
  1805. // if(w.button('sticked'))
  1806. // w.button('sticked').hide();
  1807. // if(w.button('park'))
  1808. // w.button('park').hide();
  1809. };
  1810. // 处理弹出窗口的大小
  1811. // 分为3中情况:数字*数字;max*数字;max
  1812. wd.display.getDialogWidAndHei = function (p, wp) {
  1813. if (p == "max") {
  1814. p = wp;
  1815. }
  1816. return parseInt(p);
  1817. };
  1818. // 处理弹出窗口的按钮
  1819. wd.display.showDialogBtn = function (w, btnParam) {
  1820. if (w.button("help")) w.button("help").hide();
  1821. if (w.button("stick")) w.button("stick").hide();
  1822. if (w.button("sticked")) w.button("sticked").hide();
  1823. if (w.button("park")) w.button("park").hide();
  1824. if (w.button("minmax1")) w.button("minmax1").hide();
  1825. w.button("minmax2").hide();
  1826. if (w.button("close")) w.button("close").hide();
  1827. if (btnParam) {
  1828. if (btnParam.indexOf("min") >= 0) {
  1829. w.button("park").show();
  1830. }
  1831. if (btnParam.indexOf("max") >= 0) {
  1832. if (w.isMaximized()) w.button("minmax2").show();
  1833. else w.button("minmax1").show();
  1834. }
  1835. if (btnParam.indexOf("close") >= 0) {
  1836. w.button("close").show();
  1837. }
  1838. } else {
  1839. // 用户没填写的话,默认值为“max,close”
  1840. if (w.isMaximized()) w.button("minmax2").show();
  1841. else w.button("minmax1").show();
  1842. w.button("close").show();
  1843. }
  1844. };
  1845. /**
  1846. * 把名为frameName的frame的src属性置为url
  1847. */
  1848. wd.display.changeFrameSrc = function (frameName, url) {
  1849. document.getElementsByName(frameName)[0].src = url;
  1850. };
  1851. wd.display.wdTabNo = wd.display.defaultTabNo = 1; //默认的tab索引值
  1852. // 初始化tab的总方法
  1853. wd.display.initTab = function () {
  1854. (function () {
  1855. var tab = function () {
  1856. this.dom = null;
  1857. this.wdTabFrame = null;
  1858. this.wdTabList = [];
  1859. this.wdSecondaryTab = [];
  1860. this.styles = {
  1861. wdNormalClass: null,
  1862. wdSelectedClass: null,
  1863. wdNormalMoreClass: null,
  1864. wdSelectedMoreClass: null,
  1865. };
  1866. this.selectTab = null;
  1867. this.mouseoutid = null;
  1868. var li = function () {
  1869. this.topSide = null;
  1870. this.dom = null;
  1871. this.type = null; //1:普通,2,显示隐藏开关,3,二级选项
  1872. this.parent = null;
  1873. this.ul = null;
  1874. this.url; //点击刷新iframe的地址
  1875. this.secondaryTabList = [];
  1876. //独立
  1877. this.init = function (ele, type, topside, styles) {
  1878. //二级的顶层
  1879. this.dom = ele;
  1880. this.url = this.dom.getAttribute("ssTabClick"); // ("wdTabClick")。Lin
  1881. this.setTopSide(topside);
  1882. this.type = type;
  1883. this.setStyle(styles);
  1884. // this.dom.setAttribute("class", this.wdNormalClass)
  1885. this.initEvent();
  1886. return this;
  1887. };
  1888. //初始化样式属性
  1889. this.setStyle = function (styles) {
  1890. this.styles = styles;
  1891. if (this.type == 1) {
  1892. } else if (this.type == 2) {
  1893. //初始二级的选项
  1894. this.initSecondaryTap();
  1895. $(this.dom).children("ul").addClass("popup-div").css({
  1896. position: "absolute",
  1897. });
  1898. } else if (this.type == 3) {
  1899. this.dom.style.list_style_type = "none";
  1900. $(this.dom).attr("class", "");
  1901. $(this.dom).addClass(styles.wdNormalMoreClass);
  1902. }
  1903. $(this.dom)
  1904. .removeClass(styles.wdSelectedClass)
  1905. .addClass(styles.wdNormalClass);
  1906. return this;
  1907. };
  1908. //绑定事件初始化
  1909. this.initEvent = function () {
  1910. this.dom.addEventListener("click", this.mouseClickEvent(), false);
  1911. this.dom.addEventListener("mouseover", this.mouseOverEvent(), false);
  1912. this.dom.addEventListener("mouseout", this.mouseOutEvent(), false);
  1913. };
  1914. this.initSecondaryTap = function () {
  1915. var newStyles = $.extend({}, this.styles);
  1916. newStyles.wdNormalClass = this.styles.wdNormalMoreClass;
  1917. newStyles.wdSelectedClass = this.styles.wdSelectedMoreClass;
  1918. var result = [];
  1919. //显示隐藏的位置
  1920. var ul = this.dom.getElementsByTagName("ul")[0];
  1921. if (ul == null) return;
  1922. this.ul = ul;
  1923. ul.style.display = "none";
  1924. var childNodes = ul.childNodes;
  1925. for (var i = 0; i < childNodes.length; i++) {
  1926. var nod = childNodes[i];
  1927. if (nod.nodeType == 1) {
  1928. if (nod.hasAttribute("ssTabClick")) {
  1929. // ("wdtabclick"))。先改,是 wdtabclick,不是 wdTabClick。Lin
  1930. var liobj = new li();
  1931. liobj.init(nod, 3, this.topSide, newStyles);
  1932. result.push(nod);
  1933. }
  1934. }
  1935. }
  1936. this.secondaryTabList = result;
  1937. };
  1938. //设置根
  1939. this.setTopSide = function (obj) {
  1940. this.topSide = obj;
  1941. };
  1942. this.mouseClickEvent = function () {
  1943. var THIS = this;
  1944. return function () {
  1945. //编辑选项卡状态
  1946. if ("1" == THIS.topSide.dom.getAttribute("editing")) {
  1947. return true;
  1948. }
  1949. //清除上次点击
  1950. if (THIS.type != 2 && THIS.topSide.selectTab) {
  1951. $(THIS.topSide.selectTab.dom)
  1952. .removeClass(THIS.topSide.selectTab.styles.wdSelectedClass)
  1953. .addClass(THIS.topSide.selectTab.styles.wdNormalClass);
  1954. // THIS.topSide.selectTab.dom.setAttribute("class", THIS.topSide.selectTab.wdNormalClass)
  1955. THIS.topSide.selectTab = null;
  1956. }
  1957. THIS.topSide.selectTab = THIS;
  1958. THIS.url = THIS.dom.getAttribute("ssTabClick"); // ("wdTabClick")。Lin
  1959. if (THIS.type == 1 || THIS.type == 3) {
  1960. // THIS.topSide.wdTabFrame.src = THIS.url;
  1961. THIS.topSide.wdTabFrame.src = wd.base.setRowCountPerPage(
  1962. THIS.url,
  1963. THIS.topSide.wdTabFrame.offsetHeight
  1964. );
  1965. $(THIS.dom)
  1966. .removeClass(THIS.styles.wdNormalClass)
  1967. .addClass(THIS.styles.wdSelectedClass);
  1968. // THIS.dom.setAttribute("class", THIS.wdSelectedClass);
  1969. } else if (THIS.type == 2) {
  1970. if (THIS.ul) {
  1971. if (THIS.ul.style.display == "none") {
  1972. THIS.ul.style.display = "";
  1973. } else {
  1974. THIS.ul.style.display = "none";
  1975. }
  1976. }
  1977. }
  1978. /**
  1979. * 找不到原来说的点击tab之后更多变成tab对应的名字
  1980. */
  1981. var secondarytab = document.querySelector(
  1982. '[wdsecondarytab="true"]'
  1983. );
  1984. if (secondarytab) {
  1985. var type = THIS.type;
  1986. if (type != 2) {
  1987. $(secondarytab).children(":not(ul)").remove();
  1988. $(secondarytab)
  1989. .contents()
  1990. .filter(function () {
  1991. if (this.nodeType == 3) return true;
  1992. })
  1993. .remove();
  1994. }
  1995. var firstNode = secondarytab.firstChild;
  1996. switch (type) {
  1997. case 1:
  1998. var moreNode = document.createTextNode("更多");
  1999. if (firstNode.nodeType == 3) {
  2000. secondarytab.replaceChild(moreNode, firstNode);
  2001. } else {
  2002. secondarytab.insertBefore(moreNode, firstNode);
  2003. }
  2004. secondarytab.currentSelectedItem = null;
  2005. //删除小黄点
  2006. $(secondarytab).children(".statePoint").remove();
  2007. break;
  2008. case 2:
  2009. //“更多”被点击
  2010. if (secondarytab.currentSelectedItem) {
  2011. secondarytab.currentSelectedItem.dom.click();
  2012. }
  2013. break;
  2014. case 3:
  2015. //复制小黄点
  2016. if ($(THIS.dom).find(".statePoint").length > 0) {
  2017. $(secondarytab).prepend(
  2018. $(THIS.dom).find(".statePoint").clone()
  2019. );
  2020. }
  2021. $(secondarytab).prepend(
  2022. document.createTextNode(
  2023. $(THIS.dom).contents().text() + "..."
  2024. )
  2025. );
  2026. secondarytab.currentSelectedItem = THIS;
  2027. break;
  2028. }
  2029. }
  2030. };
  2031. };
  2032. this.mouseOverEvent = function () {
  2033. var THIS = this;
  2034. return function () {
  2035. if ("1" == THIS.topSide.dom.getAttribute("editing")) {
  2036. return true;
  2037. }
  2038. if (THIS.type == 2) {
  2039. if (THIS.ul) THIS.ul.style.display = "block";
  2040. //THIS.dom.getElementsByTagName("ul")[0]
  2041. if (THIS.topSide.mouseoutid)
  2042. clearTimeout(THIS.topSide.mouseoutid);
  2043. THIS.topSide.mouseoutid = null;
  2044. }
  2045. };
  2046. };
  2047. this.mouseOutEvent = function () {
  2048. var THIS = this;
  2049. return function () {
  2050. if ("1" == THIS.topSide.dom.getAttribute("editing")) {
  2051. return true;
  2052. }
  2053. if (THIS.topSide.selectTab != THIS) {
  2054. $(THIS.dom)
  2055. .removeClass(THIS.styles.wdSelectedClass)
  2056. .addClass(THIS.styles.wdNormalClass);
  2057. }
  2058. // if (THIS.type == 2 && THIS.ul && THIS.ul.style.display == "") {
  2059. // THIS.ul.style.display = "none"
  2060. // }
  2061. if (THIS.type == 2) {
  2062. var pos = THIS.dom.compareDocumentPosition(
  2063. window.event.relatedTarget
  2064. );
  2065. if (pos == 10 || pos == 4) {
  2066. if ("true" == THIS.dom.getAttribute("wdSecondaryTab")) {
  2067. if (THIS.topSide.mouseoutid)
  2068. clearTimeout(THIS.topSide.mouseoutid);
  2069. THIS.topSide.mouseoutid = null;
  2070. THIS.topSide.mouseoutid = setTimeout(function () {
  2071. THIS.ul.style.display = "none";
  2072. }, 800);
  2073. }
  2074. }
  2075. }
  2076. };
  2077. };
  2078. };
  2079. this.init = function (dom) {
  2080. this.dom = dom;
  2081. //原为 this.wdTabFrame = document.getElementsByTagName("iframe")[0]
  2082. this.wdTabFrame =
  2083. document.querySelector('iframe[name="ssTabIframe"]') || // [name="wdTabFrame"]。Lin
  2084. document.getElementsByTagName("iframe")[0];
  2085. this.wdTabFrame.tabObj = this; //为了获取当前选中的tab来刷新当前的iframe
  2086. /* 改,规范命名。Lin
  2087. * wdNormalClass > ssNormClazz
  2088. * 去掉 wdNomalClass
  2089. * wdSelectedClass > ssSelClazz
  2090. this.styles.wdNormalClass = this.dom.getAttribute("wdNormalClass") || this.dom.getAttribute("wdNomalClass");
  2091. this.styles.wdSelectedClass = this.dom.getAttribute("wdSelectedClass");
  2092. */
  2093. this.styles.wdNormalClass = this.dom.getAttribute("ssNormClazz");
  2094. this.styles.wdSelectedClass = this.dom.getAttribute("ssSelClazz");
  2095. var parentiframe = window.parent.document.querySelector("iframe");
  2096. if (parentiframe.tabObj) {
  2097. //双层选项卡
  2098. if (this.styles.wdSelectedClass != "lightTab-selected")
  2099. this.styles.wdSelectedClass += " lightTab-selected";
  2100. if (this.styles.wdNormalClass != "lightTab")
  2101. this.styles.wdNormalClass += " lightTab";
  2102. this.dom.style =
  2103. "height:33px;padding-left: 14px;box-sizing:border-box";
  2104. } else {
  2105. if (this.styles.wdSelectedClass != "tab-selected")
  2106. this.styles.wdSelectedClass += " tab-selected";
  2107. if (this.styles.wdNormalClass != "tab")
  2108. this.styles.wdNormalClass += " tab";
  2109. }
  2110. this.styles.wdNormalMoreClass = "popupList";
  2111. this.styles.wdSelectedMoreClass = "popupList";
  2112. //初始化
  2113. var child = this.findChildLi();
  2114. var secondLi;
  2115. for (var i = 0; i < child.length; i++) {
  2116. var type = 1;
  2117. if (child[i].hasAttribute("wdSecondaryTab")) {
  2118. type = 2;
  2119. }
  2120. var liobj = new li();
  2121. liobj.init(child[i], type, this, this.styles);
  2122. if (type == 2) {
  2123. secondLi = liobj;
  2124. }
  2125. this.wdTabList.push(liobj);
  2126. }
  2127. //超出显示范围,就显示出更多选项卡 start
  2128. var wholewidth = 0;
  2129. var domwidth = $(dom).width();
  2130. for (var i = 0; i < this.wdTabList.length; i++) {
  2131. var w = this.wdTabList[i].dom.offsetWidth;
  2132. wholewidth += w;
  2133. }
  2134. if (wholewidth > domwidth) {
  2135. secondLi.dom.style.display = "";
  2136. domwidth -= secondLi.dom.offsetWidth * 2;
  2137. var fistgroup = [];
  2138. var secondgroup = [];
  2139. var thirdgroup = [];
  2140. wholewidth = 0;
  2141. for (var i = 0; i < this.wdTabList.length; i++) {
  2142. wholewidth += this.wdTabList[i].dom.offsetWidth;
  2143. var t = this.wdTabList[i].type;
  2144. if (t == 2) {
  2145. secondgroup.push(this.wdTabList[i]);
  2146. continue;
  2147. }
  2148. if (wholewidth > domwidth) {
  2149. thirdgroup.push(this.wdTabList[i]);
  2150. this.wdTabList[i].type = 3;
  2151. var oo = $.extend({}, this.wdTabList[i].styles, {
  2152. wdNormalClass: this.wdTabList[i].styles.wdNormalMoreClass,
  2153. wdSelectedClass: this.wdTabList[i].styles.wdNormalMoreClass,
  2154. });
  2155. this.wdTabList[i].setStyle(oo);
  2156. $(this.wdTabList[i].dom).prependTo(secondLi.ul);
  2157. } else {
  2158. fistgroup.push(this.wdTabList[i]);
  2159. }
  2160. }
  2161. this.wdTabList = fistgroup.concat(secondgroup);
  2162. secondLi.secondaryTabList = thirdgroup.concat(
  2163. secondLi.secondaryTabList
  2164. );
  2165. }
  2166. //超出显示范围,就显示出更多选项卡 end
  2167. this.selectClick(wd.display.wdTabNo);
  2168. return this;
  2169. };
  2170. this.findChildLi = function () {
  2171. var result = [];
  2172. var childNodes = this.dom.childNodes;
  2173. for (var i = 0; i < childNodes.length; i++) {
  2174. var nod = childNodes[i];
  2175. if (nod.nodeType == 1) {
  2176. /* 再改,规范 <li wdTabClick= 命名。Lin
  2177. * 先改,是 wdtabclick,不是 wdTabClick
  2178. * wdSecondaryTab,应该没有了 -- 没有 更多...
  2179. if (nod.hasAttribute("wdtabclick") || nod.hasAttribute("wdSecondaryTab")) {
  2180. */ if (nod.hasAttribute("ssTabClick") || nod.hasAttribute("wdSecondaryTab")) {
  2181. result.push(nod);
  2182. }
  2183. }
  2184. }
  2185. return result;
  2186. };
  2187. //指定第几个tab点击
  2188. this.selectClick = function (no) {
  2189. var num = no || 1;
  2190. var childLength = 0;
  2191. var child = this.findChildLi();
  2192. if (child.length == 0) return;
  2193. for (var i = 0; i < child.length; i++) {
  2194. if (child[i].hasAttribute("wdSecondaryTab")) {
  2195. } else {
  2196. childLength++;
  2197. }
  2198. }
  2199. num = isNaN(num) || num > childLength ? wd.display.defaultTabNo : num;
  2200. if (childLength == 0) {
  2201. var cc = $(child[0])
  2202. .find("li")
  2203. .filter(function () {
  2204. return this.style != "none";
  2205. })
  2206. .first();
  2207. if (cc.length == 1) cc[0].click();
  2208. //隐藏更多
  2209. $(child[0]).find("#tabOption").hide();
  2210. } else if (num > childLength) {
  2211. child[0].click();
  2212. } else {
  2213. child[num - 1].click();
  2214. }
  2215. };
  2216. };
  2217. //从wdTabClick的元素顶层初始化
  2218. var initList = document.querySelectorAll("[ssTabClick]"); // ("[wdTabClick]")。Lin
  2219. var tabobj;
  2220. if (initList.length > 0) {
  2221. if ("tabOption" == initList[0].parentNode.getAttribute("id")) {
  2222. tabobj = new tab().init(initList[0].parentNode.parentNode.parentNode);
  2223. } else {
  2224. tabobj = new tab().init(initList[0].parentNode);
  2225. }
  2226. }
  2227. window.tabobj = tabobj;
  2228. })();
  2229. };
  2230. wd.display.getTabInstance = function () {
  2231. return window.tabobj;
  2232. };
  2233. /**
  2234. * 打印指定div等内容,可多个selector
  2235. */
  2236. wd.display.printArea = function (selector, noscroll, options) {
  2237. var jqsrc = "/wd/js/jquery/jquery.js";
  2238. var printsrc = "/wd/js/print/jquery.PrintArea.js";
  2239. if (typeof $ + "" == "undefined") {
  2240. loadScript(jqsrc, "jquery", function () {
  2241. loadAndPrint();
  2242. });
  2243. } else {
  2244. loadAndPrint();
  2245. }
  2246. function loadAndPrint() {
  2247. if (typeof $.PrintArea + "" == "undefined") {
  2248. loadScript(printsrc, "print", function () {
  2249. options = options || {
  2250. mode: "iframe",
  2251. popClose: false,
  2252. extraCss: "",
  2253. retainAttr: ["class", "id", "style", "on"],
  2254. extraHead:
  2255. '<meta charset="utf-8" />,<meta http-equiv="X-UA-Compatible" content="IE=edge"/>',
  2256. };
  2257. if (noscroll) $(selector).css("overflow", "");
  2258. $(selector).append($("link").clone());
  2259. $(selector).append($("style").clone());
  2260. try {
  2261. $(selector).printArea(options);
  2262. } catch (e) {
  2263. alert("打印出错,检查打印窗是否被拦截");
  2264. console.error(e);
  2265. }
  2266. });
  2267. } else {
  2268. if (noscroll) $(selector).css("overflow", "");
  2269. $(selector).append($("link").clone());
  2270. $(selector).append($("style").clone());
  2271. try {
  2272. $(selector).printArea(options);
  2273. } catch (e) {
  2274. alert("打印出错,检查打印窗是否被拦截");
  2275. console.error(e);
  2276. }
  2277. }
  2278. }
  2279. };
  2280. /**
  2281. *
  2282. * @param {Object}
  2283. * output
  2284. * @param {Object}
  2285. * wdurl
  2286. */
  2287. wd.display.qrcode = function (output, wdurl, width, height, render) {
  2288. // console.log($().qrcode);
  2289. // if (typeof $ + "" == "undefined") {
  2290. // loadScript("/wd/js/jquery/jquery.js", "jquery~", function() {
  2291. // wd.display.qrcode(output, wdurl, width, height, render);
  2292. // });
  2293. // } else {
  2294. // if (!$().qrcode)
  2295. // loadScript("/wd/js/qrcode/jquery.qrcode.js", "qrcode1", function() {
  2296. // loadScript("/wd/js/qrcode/qrcode.js", "qrcode2", function() {
  2297. // wd.display.qrcode(output, wdurl, width, height, render);
  2298. // });
  2299. // });
  2300. // else {
  2301. var option = {
  2302. render: render || "table",
  2303. text: wdurl.toString(),
  2304. width: width || "200",
  2305. height: height || "200",
  2306. };
  2307. $(output).find(".qrcode").remove();
  2308. $(output).append("<div class='qrcode'></div>");
  2309. $(output).find(".qrcode").qrcode(option);
  2310. // }
  2311. // }
  2312. };
  2313. /**
  2314. * 改变dom元素的背景图片
  2315. * 但css中的背景图片的url必须如下:url(./img/background.jpg?wdHelpImage=changebg.jpg)
  2316. *
  2317. * @param domId
  2318. * 需要改变背景图片的dom元素id
  2319. */
  2320. wd.display.changeBackgroundImage = function (domId) {
  2321. var domElement = document.getElementById(domId);
  2322. var cssStr = getClass(domElement, "backgroundImage");
  2323. cssStr = cssStr.substring(4, cssStr.length - 1);
  2324. cssStr = cssStr.replace(/http:\/\/([^\s\/])+/, "");
  2325. var imgPath = cssStr.substring(0, cssStr.lastIndexOf("?"));
  2326. if (cssStr.lastIndexOf("?") != -1) {
  2327. imgPath = imgPath.substring(0, imgPath.lastIndexOf("/") + 1); // 图片所在的文件位置
  2328. var changeImgStartIndex = cssStr.lastIndexOf("=") + 1;
  2329. var changeImg = cssStr.substring(
  2330. parseInt(changeImgStartIndex),
  2331. parseInt(cssStr.length)
  2332. );
  2333. var oldUrl = cssStr.substring(0, cssStr.lastIndexOf("?"));
  2334. var oldImg = oldUrl.substring(oldUrl.lastIndexOf("/") + 1);
  2335. changeImg = imgPath + changeImg;
  2336. changeImg = changeImg.replace(/\"/g, "");
  2337. var imgUrl = "url(" + changeImg + "?background=" + oldImg + ")"; // 图片URL
  2338. domElement.style.backgroundImage = imgUrl;
  2339. }
  2340. function getClass(obj, attr) {
  2341. if (obj.currentStyle) {
  2342. if (attr == "backgroundPosition") {
  2343. return (
  2344. obj.currentStyle.backgroundPositionX +
  2345. " " +
  2346. obj.currentStyle.backgroundPositionY
  2347. );
  2348. } else {
  2349. return obj.currentStyle[attr];
  2350. }
  2351. } else {
  2352. return document.defaultView.getComputedStyle(obj, null)[attr];
  2353. }
  2354. }
  2355. };
  2356. /**
  2357. * 改变dom元素的背景图片
  2358. * 但css中的背景图片的url必须如下:url(./img/background.jpg?wdHelpImage=changebg.jpg)
  2359. *
  2360. * @param domId
  2361. * 需要改变背景图片的dom元素id
  2362. */
  2363. wd.display.changeBackgroundImage = function (domId) {
  2364. var domElement = document.getElementById(domId);
  2365. var cssStr = getClass(domElement, "backgroundImage");
  2366. cssStr = cssStr.substring(4, cssStr.length - 1);
  2367. cssStr = cssStr.replace(/http:\/\/([^\s\/])+/, "");
  2368. var imgPath = cssStr.substring(0, cssStr.lastIndexOf("?"));
  2369. if (cssStr.lastIndexOf("?") != -1) {
  2370. imgPath = imgPath.substring(0, imgPath.lastIndexOf("/") + 1); // 图片所在的文件位置
  2371. var changeImgStartIndex = cssStr.lastIndexOf("=") + 1;
  2372. var changeImg = cssStr.substring(
  2373. parseInt(changeImgStartIndex),
  2374. parseInt(cssStr.length)
  2375. );
  2376. var oldUrl = cssStr.substring(0, cssStr.lastIndexOf("?"));
  2377. var oldImg = oldUrl.substring(oldUrl.lastIndexOf("/") + 1);
  2378. changeImg = imgPath + changeImg;
  2379. changeImg = changeImg.replace(/\"/g, "");
  2380. var imgUrl = "url(" + changeImg + "?background=" + oldImg + ")"; // 图片URL
  2381. domElement.style.backgroundImage = imgUrl;
  2382. }
  2383. function getClass(obj, attr) {
  2384. if (obj.currentStyle) {
  2385. if (attr == "backgroundPosition") {
  2386. return (
  2387. obj.currentStyle.backgroundPositionX +
  2388. " " +
  2389. obj.currentStyle.backgroundPositionY
  2390. );
  2391. } else {
  2392. return obj.currentStyle[attr];
  2393. }
  2394. } else {
  2395. return document.defaultView.getComputedStyle(obj, null)[attr];
  2396. }
  2397. }
  2398. };
  2399. // table列表自适应宽度
  2400. // ;(function($){
  2401. //但是每个部件都要加载一次
  2402. if (typeof $ + "" == "undefined") {
  2403. loadScript("/wd/js/jquery.js", "Jquery", function () {
  2404. setTimeout(tabFoo, 200);
  2405. });
  2406. }
  2407. // 这个延迟执行在于加载时比dom元素先加载 而且该js文件在页面被加载多次消耗性能望后来者去解决这些问题
  2408. function tabFoo() {
  2409. var oTh = $("table.list th"),
  2410. oTr = $("table.list tr"),
  2411. arr_oth = Array.prototype.slice.apply(oTh),
  2412. font_size = parseInt($(arr_oth[0]).css("fontSize")),
  2413. style_h = $("style"),
  2414. str_sheet =
  2415. " white-space: nowrap;overflow: hidden;text-overflow: ellipsis;padding-left:10px;";
  2416. if (oTh.length <= 5) {
  2417. if (style_h.length) {
  2418. var first_style = style_h[0],
  2419. sheet = first_style.sheet ? first_style.sheet : first_style.styleSheet;
  2420. if (sheet.insertRule) {
  2421. sheet.insertRule("table.list td,table.list th{" + str_sheet + "}", 1);
  2422. } else {
  2423. sheet.addRule("table.list td,table.list th", str_sheet, 0);
  2424. }
  2425. } else {
  2426. $("head").append(
  2427. '<style type="text/css">table.list td,table.list th{' +
  2428. str_sheet +
  2429. "}</style>"
  2430. );
  2431. }
  2432. for (var i = 0; i < arr_oth.length - 1; i++) {
  2433. // console.log($(arr_oth[i]).text().length, '222');
  2434. var thW = $(arr_oth[i]).text().length;
  2435. thW = thW < 5 ? thW : 5; // 限定th的最大字数是5个字符
  2436. if (i == 0) {
  2437. $(arr_oth[i]).css({
  2438. "min-width": (thW + 10) * font_size + "px", // max-width and
  2439. // min-width
  2440. // 根据th字符数上下浮动一个
  2441. "max-width": (thW + 12) * font_size + "px",
  2442. });
  2443. // console.log($('table.list tr td:nth-child(' + (i + 1) + ')'))
  2444. $("table.list tr td:nth-child(" + (i + 1) + ")").css({
  2445. "min-width": (thW + 10) * font_size + "px",
  2446. "max-width": (thW + 12) * font_size + "px",
  2447. });
  2448. } else {
  2449. $(arr_oth[i]).css({
  2450. "min-width": (thW + 6) * font_size + "px", // max-width and
  2451. // min-width
  2452. // 根据th字符数上下浮动一个
  2453. "max-width": (thW + 8) * font_size + "px",
  2454. });
  2455. // console.log($('table.list tr td:nth-child(' + (i + 1) + ')'))
  2456. $("table.list tr td:nth-child(" + (i + 1) + ")").css({
  2457. "min-width": (thW + 6) * font_size + "px",
  2458. "max-width": (thW + 8) * font_size + "px",
  2459. });
  2460. }
  2461. }
  2462. $("table.list tr td:nth-child(" + arr_oth.length + ")").css({
  2463. "white-space": "inherit",
  2464. overflow: "inherit",
  2465. "text-overflow": "inherit",
  2466. });
  2467. $(".img1").parents("td").css("cssText", "width:90px !important");
  2468. return;
  2469. }
  2470. if (style_h.length) {
  2471. var first_style = style_h[0],
  2472. sheet = first_style.sheet ? first_style.sheet : first_style.styleSheet;
  2473. if (sheet.insertRule) {
  2474. sheet.insertRule("table.list td,table.list th{" + str_sheet + "}", 1);
  2475. } else {
  2476. sheet.addRule("table.list td,table.list th", str_sheet, 0);
  2477. }
  2478. } else {
  2479. $("head").append(
  2480. '<style type="text/css">table.list td,table.list th{' +
  2481. str_sheet +
  2482. "}</style>"
  2483. );
  2484. }
  2485. // console.log(arr_oth.length)
  2486. for (var i = 0; i < arr_oth.length - 1; i++) {
  2487. var thW = $(arr_oth[i]).text().length;
  2488. thW = thW < 5 ? thW : 5; // 限定th的最大字数是5个字符
  2489. $(arr_oth[i]).css({
  2490. "min-width": (thW - 1) * font_size + "px", // max-width and
  2491. // min-width
  2492. // 根据th字符数上下浮动一个
  2493. "max-width": (thW + 1) * font_size + "px",
  2494. });
  2495. // console.log($('table.list tr td:nth-child(' + (i + 1) + ')'))
  2496. $("table.list tr td:nth-child(" + (i + 1) + ")").css({
  2497. "min-width": (thW - 1) * font_size + "px",
  2498. "max-width": (thW + 1) * font_size + "px",
  2499. });
  2500. }
  2501. $("table.list tr td:nth-child(1)").css({
  2502. "min-width": (thW + 1) * font_size + "px",
  2503. "max-width": (thW + 3) * font_size + "px",
  2504. });
  2505. $("table.list tr td:nth-child(" + arr_oth.length + ")").css({
  2506. "white-space": "inherit",
  2507. overflow: "inherit",
  2508. "text-overflow": "inherit",
  2509. });
  2510. $(".img1").parents("td").css("cssText", "width:90px !important");
  2511. // console.log($('.img1').parents('td').css('width'));
  2512. }
  2513. function loadScript(src, id, callback) {
  2514. if (!document.getElementById(id)) {
  2515. var head = document.getElementsByTagName("head")[0];
  2516. var script = document.createElement("script");
  2517. script.id = id;
  2518. script.type = "text/javascript";
  2519. script.onreadystatechange = function () {
  2520. if (this.readyState == "complete") {
  2521. callback();
  2522. }
  2523. };
  2524. script.onload = function () {
  2525. callback();
  2526. };
  2527. script.src = src;
  2528. head.appendChild(script);
  2529. } else {
  2530. callback();
  2531. }
  2532. }
  2533. // })($);
  2534. //下拉改变irame
  2535. wd.display.initWdSelectFrame = function () {
  2536. (function () {
  2537. // 查找所有的option
  2538. var optionAll = document.querySelectorAll("option[wdSelectClick]");
  2539. // 遍历option
  2540. for (var i = 0; i < optionAll.length; i++) {
  2541. var options = optionAll[i];
  2542. // 找出匹配的option
  2543. if (typeof options.getAttribute("wdSelectClick") != "undefined") {
  2544. // 为其父元素绑定一个id
  2545. options.parentNode.setAttribute("id", "wdSelect");
  2546. // 为其父元素绑定一个事件
  2547. options.parentNode.onchange = function () {
  2548. iframeSrc();
  2549. };
  2550. }
  2551. }
  2552. // 下拉默认值
  2553. function iframeSrc() {
  2554. var mySelect = document.getElementById("wdSelect");
  2555. var myOption =
  2556. mySelect.options[mySelect.selectedIndex].getAttribute("wdSelectClick");
  2557. document.getElementById("wdIframe").setAttribute("src", myOption);
  2558. }
  2559. if (optionAll.length > 0) iframeSrc();
  2560. })();
  2561. };
  2562. wd.display.home = function () {
  2563. //显示个人首页
  2564. // if (document.getElementById("mbwzbj")) {
  2565. // document.getElementById("mbwzbj").innerHTML = "个人首页";
  2566. // } else {
  2567. // var div = top.window.document.querySelector("div[name='mbwz']");
  2568. // if (!div)
  2569. try {
  2570. // wd.topWindow.window.document.querySelector("span[id='mbwzbj']").innerHTML = "个人首页";
  2571. wd.display.setHomeIconName("个人首页");
  2572. } catch (e) {
  2573. console.log(e);
  2574. }
  2575. // }
  2576. var iframe = wd.topWindow.window.document.querySelector("iframe[oriSrc]");
  2577. // console.log(iframe);
  2578. iframe.src = iframe.getAttribute("oriSrc");
  2579. //处理菜单项
  2580. /*
  2581. var menu = new dhtmlXMenuObject("menuObj440141088","dhx_black");
  2582. var casState = new Object({
  2583. ctrl: false,
  2584. alt: false,
  2585. shift: false
  2586. });
  2587. menu._clearAndHide();
  2588. if(document.getElementById("mbwzbj")!=null){ //该文字部件可能不存在
  2589. menu.dqlm=menu.itemPull[menu.idPrefix + id]["title"]; //改变当前栏目
  2590. //document.getElementById("mbwzbj").innerHTML=this.itemPull[this.idPrefix + id]["title"]; //系统菜单下项目
  2591. }
  2592. if (menu._isContextMenuVisible() && menu.contextAutoHide) menu._hideContextMenu();
  2593. menu.callEvent("onClick", ["shortcutMenu", false, casState]);
  2594. */
  2595. //
  2596. // var bjsy = document.getElementById('i440163264').contentWindow.document.querySelector('.bjsy');
  2597. // if (bjsy != null && (bjsy.style.display == '' || bjsy.style.display == 'none'))
  2598. // bjsy.style.display = 'inline';
  2599. //
  2600. // var bjsymb = document.getElementById('i440163264').contentWindow.document.querySelector('.bjsymb');
  2601. // if (bjsymb != null && (bjsymb.style.display == '' || bjsymb.style.display == 'none'))
  2602. // bjsymb.style.display = 'inline';
  2603. if (wd.topWindow.userEditButton_official) {
  2604. wd.topWindow.userEditButton_official.style.display = "inline";
  2605. }
  2606. if (wd.topWindow.userEditButton_personal) {
  2607. wd.topWindow.userEditButton_personal.style.display = "inline";
  2608. }
  2609. //自动调整win2的iframe大小
  2610. if (wd.topWindow.wd.base.refreshApplyIframeHeight) {
  2611. wd.topWindow.wd.base.refreshApplyIframeHeight();
  2612. }
  2613. if (wd.topWindow.wdHelpIcon) wd.topWindow.wdHelpIcon.style.display = "none";
  2614. };
  2615. /**
  2616. 异步提交,试用 06-06 by david
  2617. config: {
  2618. param: {},
  2619. async: boolean,
  2620. contentType: string, 默认为application/x-www-form-urlencoded
  2621. dataType: string 默认为json
  2622. }
  2623. callback: success回调
  2624. error: error回调
  2625. **/
  2626. wd.display.ajaxSubmit = function (url, config, callback, error) {
  2627. var xhr = getXmlHttpRequest();
  2628. var callback = undefined == callback ? function () {} : callback;
  2629. var error =
  2630. undefined == error
  2631. ? function (err) {
  2632. console.log(err);
  2633. }
  2634. : error;
  2635. var async;
  2636. var method;
  2637. var contentType;
  2638. var dataType; //xmlhttprequest设置datatype
  2639. if (undefined == config.async || config.async == true) async = true;
  2640. else if (config.async == "false") async = false;
  2641. method = config.method;
  2642. if (method.toLocaleLowerCase() == "get") {
  2643. url += "&"; //一般都带token参数
  2644. url += params(config.param);
  2645. }
  2646. if (undefined == config.contentType)
  2647. contentType = "application/x-www-form-urlencoded";
  2648. else contentType = config.contentType;
  2649. if (undefined == config.dataType) dataType = "json";
  2650. else dataType = config.dataType;
  2651. xhr.responseType = dataType;
  2652. xhr.open(method, url, async);
  2653. xhr.setRequestHeader("Content-Type", contentType);
  2654. xhr.onreadystatechange = function () {
  2655. switch (xhr.readyState) {
  2656. case 1:
  2657. break;
  2658. case 2:
  2659. break;
  2660. case 3:
  2661. break;
  2662. case 4:
  2663. if (xhr.status == 200) {
  2664. /* var result = xhr.response;
  2665. if(window.JSON){
  2666. result = JSON.parse(result);
  2667. }else{
  2668. result = eval("(" + result + ")");
  2669. }
  2670. callback(result); */
  2671. callback(xhr.response);
  2672. } else {
  2673. error(xhr.response);
  2674. }
  2675. break;
  2676. }
  2677. };
  2678. if (method.toLocaleLowerCase() == "get") xhr.send();
  2679. else xhr.send(params(config.param));
  2680. function params(data) {
  2681. var arr = [];
  2682. for (var i in data) {
  2683. arr.push(encodeURIComponent(i) + "=" + encodeURIComponent(data[i]));
  2684. }
  2685. return arr.join("&");
  2686. }
  2687. function getXmlHttpRequest() {
  2688. var xmlHttpRequest = null;
  2689. if (typeof XMLHttpRequest != "undefined") {
  2690. xmlHttpRequest = new XMLHttpRequest();
  2691. } else {
  2692. xmlHttpRequest = new ActiveXObject("Microsoft.XMLHttp");
  2693. }
  2694. return xmlHttpRequest;
  2695. }
  2696. };
  2697. //表格批示使用,url带有单元格序号‘bgbj_xh’>0时全屏
  2698. wd.display.JumpTest = function (params) {
  2699. function FindParam(url, name) {
  2700. var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
  2701. var r = url.substr(1).match(reg);
  2702. if (r != null) return unescape(r[2]);
  2703. return null;
  2704. }
  2705. /**
  2706. function openScreenLayer(src) {
  2707. var topbody = $("body", wd.topWindow.document);
  2708. var wdfs = topbody.find("#wdfullscreen"); //弹层的div
  2709. if(wdfs.length < 1) {
  2710. topbody.append("<div id='wdfullscreen' style='display:none;top:-10;'></div>");
  2711. wdfs = topbody.find("#wdfullscreen");
  2712. }
  2713. wdfs.html("");
  2714. wdfs.append("<link rel='stylesheet' type='text/css' id='uefullscreenstyle' href='/wd/js/ueditor/ueFull.css'>").show()
  2715. wdfs.append('<div class="uefullscreen"><input type="button" style="z-index: 999999999;position: absolute;top:10px;right:10px" class="btn-list fulscrbtn fullButton" value="" state="1" /><div class="fullscreen fullscreenSrc" style="overflow:auto;-webkit-overflow-scrolling:touch!important;" ></div></div>');
  2716. wdfs.find(".fullscreen").html('<iframe id="myIframe" src="' + src + '" style="width:100%;height:100%;position: absolute;top: 0;left: 0;right: 0;bottom: 0;margin: auto;border: 1px solid #e4e4e4;overflow:auto;-webkit-overflow-scrolling:touch!important;"></iframe>');
  2717. wdfs.find(".fulscrbtn").click(function(e) {
  2718. wdfs.remove();
  2719. });
  2720. }
  2721. **/
  2722. /****/
  2723. function openScreenLayer(src) {
  2724. var topbody = $("body", wd.topWindow.document);
  2725. var wdfs = topbody.find("#wdfullscreen"); //弹层的div
  2726. if (wdfs.length < 1) {
  2727. topbody.append(
  2728. "<div id='wdfullscreen' style='display:none;width:100%;height:100%;margin:0;'></div>"
  2729. );
  2730. wdfs = topbody.find("#wdfullscreen");
  2731. }
  2732. wdfs.html("");
  2733. wdfs
  2734. .append(
  2735. "<link rel='stylesheet' type='text/css' id='uefullscreenstyle' href='/wd/js/ueditor/ueFull.css'>"
  2736. )
  2737. .show();
  2738. wdfs.append(
  2739. '<div class="uefullscreen" style="height:100%;margin:0;"><input type="button" style="z-index: 999999999;position: absolute;top:10px;right:14px" class="btn-list fulscrbtn fullButton" value="" state="1" /><div class="fullscreen fullscreenSrc" style="width:100%;height:1100px;-webkit-overflow-scrolling:touch; overflow:scroll;"></div></div>'
  2740. );
  2741. wdfs
  2742. .find(".fullscreen")
  2743. .html(
  2744. '<iframe id="myIframe" src="' +
  2745. src +
  2746. '" style="width:100%;height:96%;"></iframe>'
  2747. );
  2748. wdfs.find(".fulscrbtn").click(function (e) {
  2749. wdfs.remove();
  2750. });
  2751. }
  2752. var a = parseInt(FindParam(params.url, "bgbj_xh"));
  2753. if (a && a > 0) {
  2754. // openScreenLayer(params.url);
  2755. params.show = "wdFullScreen";
  2756. params.width = wd.topWindow.document.body.offsetWidth;
  2757. wd.display.showComponent(params);
  2758. } else {
  2759. wd.display.showComponent(params);
  2760. }
  2761. };
  2762. //使参数指定的滚动图片全屏
  2763. wd.display.fullgdtpScreen = function (element, bjid) {
  2764. // console.log(element);
  2765. // wd.display.CmsZNRFull(element);
  2766. $("#ydfull" + bjid).css("display", "-webkit-flex");
  2767. var index_img = 0;
  2768. var lastindex_img = 0;
  2769. var full_src;
  2770. full_src = $(element).children("img")[0].src;
  2771. // console.log(full_src);
  2772. $("#imgfull" + bjid).attr("src", full_src);
  2773. var items = $("#list" + bjid).find(".ydimg_item");
  2774. if (items != undefined && items.length != 0) {
  2775. lastindex_img = items.length - 1;
  2776. for (var ii = 0; ii < items.length; ii++) {
  2777. if ($(element).children("img")[0] == $(items[ii]).children("img")[0]) {
  2778. index_img = ii;
  2779. }
  2780. }
  2781. }
  2782. var marioVideo = $("#ydfull" + bjid)[0];
  2783. // wd.display.CmsZNRFull(element);
  2784. var fullscreenchange = function () {
  2785. if (document.webkitFullscreenElement != null) {
  2786. // element.style.width = "100%";
  2787. // element.style.height = "100%";
  2788. // element.style.overflowY = 'hidden';
  2789. //console.log("进入全屏函数");
  2790. // $('#mainDiv').append('<div id="pageClose" class=" dhtmlx_skin_dhx_skyblue"><div class="dhtmlx_window_active"><div class="dhtmlx_wins_btns" style="position:fixed;right:0px;"><div class="dhtmlx_wins_btns_button dhtmlx_button_close_default" onclick="wd.display.exitFullScreen()" title="Close"></div></div></div></div>');
  2791. } else {
  2792. //console.log("退出全屏函数");
  2793. $("#ydfull" + bjid).hide();
  2794. //添加监听器,监听用户进入全屏和退出全屏操作
  2795. marioVideo.removeEventListener(
  2796. "webkitfullscreenchange",
  2797. fullscreenchange
  2798. );
  2799. marioVideo.removeEventListener("fullscreenchange", fullscreenchange);
  2800. marioVideo.removeEventListener("mozfullscreenchange", fullscreenchange);
  2801. marioVideo.removeEventListener("msfullscreenchange", fullscreenchange);
  2802. }
  2803. };
  2804. // 判断各种浏览器,找到正确的方法
  2805. var elem = marioVideo;
  2806. elem.onmousemove = function (e) {
  2807. // console.log(e.offsetY);
  2808. e = e || window.event;
  2809. var newY = e.screenY;
  2810. //console.log(ismousedown+":"+scollY +":"+ oldY +":"+ e.screenY +":"+(scollY + (oldY - e.screenY) * 2))
  2811. if (newY < window.screen.height / 3 && index_img != 0) {
  2812. elem.style.cursor = 'url("./wd/image/top.cur"),default'; //上1/3区域
  2813. } else if (
  2814. newY > (window.screen.height / 3) * 2 &&
  2815. index_img != lastindex_img
  2816. ) {
  2817. elem.style.cursor = 'url("./wd/image/bottom.cur"),default'; //下1/3区域
  2818. } else {
  2819. elem.style.cursor = "default"; //中1/3区域
  2820. }
  2821. };
  2822. elem.onclick = function (e) {
  2823. e = e || window.event;
  2824. var newY = e.screenY;
  2825. //console.log(ismousedown+":"+scollY +":"+ oldY +":"+ e.screenY +":"+(scollY + (oldY - e.screenY) * 2))
  2826. if (newY < window.screen.height / 3 && index_img != 0) {
  2827. //上一张
  2828. index_img = index_img - 1;
  2829. if (items != undefined && items.length != 0) {
  2830. for (var ii = 0; ii < items.length; ii++) {
  2831. $(items[ii]).removeClass("selected");
  2832. }
  2833. full_src = $(items[index_img]).children("img")[0].src;
  2834. $("#imgfull" + bjid).attr("src", full_src);
  2835. $(items[index_img]).addClass("selected");
  2836. $("#img" + bjid).attr("src", full_src);
  2837. $("#bt" + bjid).html(
  2838. $(items[index_img]).children("img").eq(0).attr("alt")
  2839. );
  2840. }
  2841. } else if (
  2842. newY > (window.screen.height / 3) * 2 &&
  2843. index_img != lastindex_img
  2844. ) {
  2845. //下一张
  2846. index_img = index_img + 1;
  2847. if (items != undefined && items.length != 0) {
  2848. for (var ii = 0; ii < items.length; ii++) {
  2849. $(items[ii]).removeClass("selected");
  2850. }
  2851. full_src = $(items[index_img]).children("img")[0].src;
  2852. $("#imgfull" + bjid).attr("src", full_src);
  2853. $(items[index_img]).addClass("selected");
  2854. $("#img" + bjid).attr("src", full_src);
  2855. $("#bt" + bjid).html(
  2856. $(items[index_img]).children("img").eq(0).attr("alt")
  2857. );
  2858. }
  2859. } else {
  2860. //关闭
  2861. wd.display.exitFullScreen();
  2862. }
  2863. };
  2864. marioVideo.addEventListener("webkitfullscreenchange", fullscreenchange);
  2865. marioVideo.addEventListener("fullscreenchange", fullscreenchange);
  2866. marioVideo.addEventListener("mozfullscreenchange", fullscreenchange);
  2867. marioVideo.addEventListener("msfullscreenchange", fullscreenchange);
  2868. if (marioVideo.requestFullscreen) {
  2869. marioVideo.requestFullscreen(elem);
  2870. } else if (marioVideo.msRequestFullscreen) {
  2871. marioVideo.msRequestFullscreen(elem);
  2872. } else if (marioVideo.mozRequestFullScreen) {
  2873. marioVideo.mozRequestFullScreen(elem);
  2874. } else if (marioVideo.webkitRequestFullScreen) {
  2875. marioVideo.webkitRequestFullScreen(elem);
  2876. }
  2877. };
  2878. wd.display.fullsltScreen = function (bjid) {
  2879. $("#sltfull" + bjid).css("display", "-webkit-flex");
  2880. var index_img = 0;
  2881. var lastindex_img = 0;
  2882. var full_src;
  2883. var items_selected = $("#list" + bjid).find(".slximg_box.selected");
  2884. if (items_selected != undefined && items_selected.length != 0) {
  2885. for (var ii = 0; ii < items_selected.length; ii++) {
  2886. full_src = $(items_selected[ii]).find("img")[0].src;
  2887. // console.log(full_src);
  2888. $("#imgfull" + bjid).attr("src", full_src);
  2889. }
  2890. }
  2891. var items = $("#list" + bjid).find(".slximg_item");
  2892. if (items != undefined && items.length != 0) {
  2893. lastindex_img = items.length - 1;
  2894. for (var ii = 0; ii < items.length; ii++) {
  2895. if ($(items_selected[0]).find("img")[0] == $(items[ii]).find("img")[0]) {
  2896. index_img = ii;
  2897. }
  2898. }
  2899. }
  2900. var marioVideo = $("#sltfull" + bjid)[0];
  2901. // wd.display.CmsZNRFull(element);
  2902. var fullscreenchange = function () {
  2903. if (document.webkitFullscreenElement != null) {
  2904. // element.style.width = "100%";
  2905. // element.style.height = "100%";
  2906. // element.style.overflowY = 'hidden';
  2907. //console.log("进入全屏函数");
  2908. // $('#mainDiv').append('<div id="pageClose" class=" dhtmlx_skin_dhx_skyblue"><div class="dhtmlx_window_active"><div class="dhtmlx_wins_btns" style="position:fixed;right:0px;"><div class="dhtmlx_wins_btns_button dhtmlx_button_close_default" onclick="wd.display.exitFullScreen()" title="Close"></div></div></div></div>');
  2909. } else {
  2910. //console.log("退出全屏函数");
  2911. $("#sltfull" + bjid).hide();
  2912. //添加监听器,监听用户进入全屏和退出全屏操作
  2913. marioVideo.removeEventListener(
  2914. "webkitfullscreenchange",
  2915. fullscreenchange
  2916. );
  2917. marioVideo.removeEventListener("fullscreenchange", fullscreenchange);
  2918. marioVideo.removeEventListener("mozfullscreenchange", fullscreenchange);
  2919. marioVideo.removeEventListener("msfullscreenchange", fullscreenchange);
  2920. }
  2921. };
  2922. // 判断各种浏览器,找到正确的方法
  2923. var elem = marioVideo;
  2924. elem.onmousemove = function (e) {
  2925. // console.log(e.offsetY);
  2926. e = e || window.event;
  2927. var newY = e.screenY;
  2928. //console.log(ismousedown+":"+scollY +":"+ oldY +":"+ e.screenY +":"+(scollY + (oldY - e.screenY) * 2))
  2929. if (newY < window.screen.height / 3 && index_img != 0) {
  2930. elem.style.cursor =
  2931. "url(" + wd.common.loadFile("theme/meow/image/top.cur") + "),default"; //上1/3区域
  2932. } else if (
  2933. newY > (window.screen.height / 3) * 2 &&
  2934. index_img != lastindex_img
  2935. ) {
  2936. elem.style.cursor =
  2937. "url(" +
  2938. wd.common.loadFile("theme/meow/image/bottom.cur") +
  2939. "),default"; //下1/3区域
  2940. } else {
  2941. elem.style.cursor = "default"; //中1/3区域
  2942. }
  2943. };
  2944. elem.onclick = function (e) {
  2945. e = e || window.event;
  2946. var newY = e.screenY;
  2947. //console.log(ismousedown+":"+scollY +":"+ oldY +":"+ e.screenY +":"+(scollY + (oldY - e.screenY) * 2))
  2948. if (newY < window.screen.height / 3 && index_img != 0) {
  2949. //上一张
  2950. index_img = index_img - 1;
  2951. if (items != undefined && items.length != 0) {
  2952. for (var ii = 0; ii < items.length; ii++) {
  2953. $(items[ii]).removeClass("selected");
  2954. }
  2955. full_src = $(items[index_img]).find("img")[0].src;
  2956. $("#imgfull" + bjid).attr("src", full_src);
  2957. $(items[index_img]).addClass("selected");
  2958. $("#img" + bjid).attr("src", full_src);
  2959. $("#bt" + bjid).html($(items[index_img]).find("img").eq(0).attr("alt"));
  2960. }
  2961. } else if (
  2962. newY > (window.screen.height / 3) * 2 &&
  2963. index_img != lastindex_img
  2964. ) {
  2965. //下一张
  2966. index_img = index_img + 1;
  2967. if (items != undefined && items.length != 0) {
  2968. for (var ii = 0; ii < items.length; ii++) {
  2969. $(items[ii]).removeClass("selected");
  2970. }
  2971. full_src = $(items[index_img]).find("img")[0].src;
  2972. $("#imgfull" + bjid).attr("src", full_src);
  2973. $(items[index_img]).addClass("selected");
  2974. $("#img" + bjid).attr("src", full_src);
  2975. $("#bt" + bjid).html($(items[index_img]).find("img").eq(0).attr("alt"));
  2976. }
  2977. } else {
  2978. //关闭
  2979. wd.display.exitFullScreen();
  2980. }
  2981. };
  2982. marioVideo.addEventListener("webkitfullscreenchange", fullscreenchange);
  2983. marioVideo.addEventListener("fullscreenchange", fullscreenchange);
  2984. marioVideo.addEventListener("mozfullscreenchange", fullscreenchange);
  2985. marioVideo.addEventListener("msfullscreenchange", fullscreenchange);
  2986. if (marioVideo.requestFullscreen) {
  2987. marioVideo.requestFullscreen(elem);
  2988. } else if (marioVideo.msRequestFullscreen) {
  2989. marioVideo.msRequestFullscreen(elem);
  2990. } else if (marioVideo.mozRequestFullScreen) {
  2991. marioVideo.mozRequestFullScreen(elem);
  2992. } else if (marioVideo.webkitRequestFullScreen) {
  2993. marioVideo.webkitRequestFullScreen(elem);
  2994. }
  2995. };
  2996. //使参数指定的DOM元素全屏,如果不传参数则默认带个页面全屏
  2997. wd.display.fullScreen = function (element) {
  2998. element.sdasdasds = playlist;
  2999. // 判断各种浏览器,找到正确的方法
  3000. var requestMethod =
  3001. element.requestFullScreen || //W3C
  3002. element.webkitRequestFullScreen || //Chrome等
  3003. element.mozRequestFullScreen || //FireFox
  3004. element.msRequestFullScreen; //IE11
  3005. if (requestMethod) {
  3006. requestMethod.call(element);
  3007. } else if (typeof window.ActiveXObject !== "undefined") {
  3008. //for Internet Explorer
  3009. var wscript = new ActiveXObject("WScript.Shell");
  3010. if (wscript !== null) {
  3011. alert("f11");
  3012. wscript.SendKeys("{F11}");
  3013. }
  3014. }
  3015. };
  3016. //从全屏状态切换为普通状态
  3017. wd.display.exitFullScreen = function () {
  3018. // 判断各种浏览器,找到正确的方法
  3019. var exitMethod =
  3020. document.exitFullscreen || //W3C
  3021. document.mozCancelFullScreen || //Chrome等
  3022. document.webkitExitFullscreen || //FireFox
  3023. document.webkitExitFullscreen; //IE11
  3024. if (exitMethod) {
  3025. exitMethod.call(document);
  3026. } else if (typeof window.ActiveXObject !== "undefined") {
  3027. //for Internet Explorer
  3028. var wscript = new ActiveXObject("WScript.Shell");
  3029. if (wscript !== null) {
  3030. wscript.SendKeys("{F11}");
  3031. }
  3032. }
  3033. };
  3034. wd.display.CmsZNRFull = function (element) {
  3035. //目前对图片,视频,pdf,word,flash,全屏下特殊处理
  3036. var IMG_TYPE = "IMG";
  3037. var VIDEO_TYPE = "VIDEO";
  3038. var PDF_TYPE = "PDF";
  3039. var WORD_TYPE = "WORD";
  3040. var FLASH_TYPE = "FLASH";
  3041. var XLS_TYPE = "XLS";
  3042. var PPT_TYPE = "PPT";
  3043. function nrjsblmType(nrjslbm) {
  3044. var group = {
  3045. 300: IMG_TYPE,
  3046. 310: IMG_TYPE,
  3047. 320: IMG_TYPE,
  3048. 330: IMG_TYPE,
  3049. 340: IMG_TYPE,
  3050. 500: VIDEO_TYPE,
  3051. 510: VIDEO_TYPE,
  3052. 520: VIDEO_TYPE,
  3053. 1010: PDF_TYPE,
  3054. 810: PPT_TYPE,
  3055. 910: WORD_TYPE,
  3056. 1110: XLS_TYPE,
  3057. 710: FLASH_TYPE,
  3058. };
  3059. return group[nrjslbm];
  3060. }
  3061. var width; //定义宽度与高度
  3062. var height;
  3063. var dataList = [];
  3064. //查找出当前所有的所有播放器
  3065. var playlist = element.querySelectorAll("[data-init]");
  3066. console.log("555:" + playlist.length);
  3067. // var nrid = null;
  3068. for (var i = 0; i < playlist.length; i++) {
  3069. var playDiv = playlist[i];
  3070. var nrJson = JSON.parse(playDiv.getAttribute("data-init"));
  3071. // console.log(nrJson);
  3072. // nrid = nrJson.resDesign.ID;
  3073. var nrjslbm = nrJson.resDesign.nrjslbm;
  3074. var TYPE = nrjsblmType(nrjslbm);
  3075. if (!TYPE) continue;
  3076. // console.log("666:" + TYPE);
  3077. var exitFunction = null; //退出全屏回调方法
  3078. var data = {
  3079. type: TYPE,
  3080. nrjslbm: nrjslbm,
  3081. };
  3082. // console.log(TYPE);
  3083. if (TYPE == IMG_TYPE) {
  3084. var handle = playDiv.querySelector(".img");
  3085. width = handle.naturalWidth;
  3086. height = handle.naturalHeight;
  3087. //退出全屏用到的数据缓存
  3088. data.handle = handle;
  3089. data.width = handle.style.width;
  3090. data.height = handle.style.height;
  3091. data.exitFunction = function (data) {
  3092. // console.log(data)
  3093. data.handle.style.width = data.width;
  3094. data.handle.style.height = data.height;
  3095. };
  3096. var zzz = wd.display.CmscalZoomSize(width, height);
  3097. handle.style.width = zzz.width + "px";
  3098. handle.style.height = zzz.height + "px";
  3099. // console.log(handle.style.width)
  3100. // console.log(handle.style.height)
  3101. } else if (TYPE == VIDEO_TYPE) {
  3102. var handle = playDiv.querySelector(".video");
  3103. var handleparent = playDiv.querySelector(".videoparent");
  3104. width = handle.videoWidth;
  3105. height = handle.videoHeight;
  3106. //退出全屏还原
  3107. data.handleparent = handleparent;
  3108. data.width = handleparent.style.width;
  3109. data.height = handleparent.style.height;
  3110. data.exitFunction = function (data) {
  3111. // console.log(data)
  3112. data.handleparent.style.width = data.width;
  3113. data.handleparent.style.height = data.height;
  3114. };
  3115. var zzz = wd.display.CmscalZoomSize(width, height);
  3116. handleparent.style.width = zzz.width + "px";
  3117. handleparent.style.height = zzz.height + "px";
  3118. } else if (TYPE == PDF_TYPE || TYPE == WORD_TYPE || TYPE == XLS_TYPE) {
  3119. var handle = playDiv.querySelector(".show");
  3120. var son1 = handle.querySelector("#pf1");
  3121. if (son1 == null) return;
  3122. width = son1.clientWidth;
  3123. height = son1.clientHeight;
  3124. var zzz = wd.display.CmscalZoomSize(width, height);
  3125. data.handle = handle;
  3126. data.overflow = handle.style.overflow;
  3127. data.zoom = handle.style.zoom;
  3128. //特殊处理excel背景颜色变黑色
  3129. if (TYPE == XLS_TYPE) {
  3130. playDiv.style.background = "white";
  3131. }
  3132. data.exitFunction = function (data) {
  3133. if (zzz.zoom != null) {
  3134. element.scrollTop = element.scrollTop / zzz.zoom;
  3135. }
  3136. // console.log(data)
  3137. data.handle.style.zoom = data.zoom;
  3138. data.handle.style.overflow = data.overflow;
  3139. if (data.type == XLS_TYPE) {
  3140. data.handle.style.background = "";
  3141. }
  3142. };
  3143. handle.style.zoom = zzz.zoom;
  3144. element.scrollTop = element.scrollTop * zzz.zoom;
  3145. } else if (TYPE == FLASH_TYPE) {
  3146. var handle = playDiv.querySelector("#embed");
  3147. //退出全屏方法
  3148. data.handle = handle;
  3149. data.width = handle.style.width;
  3150. data.height = handle.style.height;
  3151. data.exitFunction = function (data) {
  3152. // console.log(data)
  3153. data.handle.style.width = $("#mainDiv").innerWidth();
  3154. data.handle.style.height = $("#mainDiv").innerHeight();
  3155. };
  3156. var zzz = wd.display.CmscalZoomSize();
  3157. handle.style.width = zzz.maxWidth + "px";
  3158. handle.style.height = zzz.maxHeight + "px";
  3159. }
  3160. dataList.push(data);
  3161. playlist[i].dataList = dataList;
  3162. }
  3163. };
  3164. /**
  3165. *
  3166. * 计算放大后width,height,zoom
  3167. * @param {Object} w
  3168. * @param {Object} h
  3169. */
  3170. wd.display.CmscalZoomSize = function (w, h) {
  3171. var maxWidth = screen.availWidth - 1;
  3172. var maxHeight = screen.availHeight - 1; //获取页面的高度与宽度
  3173. var xswidth = w;
  3174. var xsheight = h;
  3175. if (w && h) {
  3176. //显示的高度与宽度
  3177. var ratio1 = w / maxWidth;
  3178. var ratio2 = h / maxHeight;
  3179. //根据长度与宽度获取缩放比例
  3180. if (ratio1 > 1 || ratio2 > 1) {
  3181. if (ratio1 > ratio2) {
  3182. //选取较大的缩放比例
  3183. xswidth = w / ratio1;
  3184. xsheight = h / ratio1;
  3185. } else {
  3186. xswidth = w / ratio2;
  3187. xsheight = h / ratio2;
  3188. }
  3189. }
  3190. }
  3191. if (w) {
  3192. var zoom = maxWidth / w;
  3193. if (zoom >= 2) {
  3194. //确定zoom 用于word与pdf放缩
  3195. zoom = 2;
  3196. }
  3197. }
  3198. return {
  3199. width: xswidth,
  3200. height: xsheight,
  3201. zoom: zoom,
  3202. maxWidth: maxWidth,
  3203. maxHeight: maxHeight,
  3204. };
  3205. };
  3206. wd.display.CmsFullDiv = function (
  3207. element,
  3208. onFullscreen,
  3209. onExitfullscreen,
  3210. win
  3211. ) {
  3212. win = win || element.ownerDocument.defaultView;
  3213. // var video,photo,pdf,word,flash;
  3214. // console.log(element);
  3215. var marioVideo = element;
  3216. var fullscreenchange = function () {
  3217. if (win.document.webkitFullscreenElement != null) {
  3218. //$(element).addClass("scrollbar");
  3219. // $(element).css("padding","25px");
  3220. // $(element).css("box-sizing","border-box");
  3221. // element.style.overflowY = "auto";
  3222. // element.style.overflowX = "hidden";
  3223. // element.style.width = "100%";
  3224. // element.style.height = "100%";
  3225. // console.log("进入全屏函数");
  3226. // element.setAttribute("isCmsFullScreen", 'true');
  3227. win
  3228. .$(element)
  3229. .append(
  3230. '<div id="pageClose" class=" dhtmlx_skin_dhx_skyblue"><div class="dhtmlx_window_active"><div class="icon-restore" style="position: fixed;right: 10px;top: 10px;height:22px;width:22px;" onclick="wd.display.exitFullScreen()" ></div></div></div>'
  3231. );
  3232. onFullscreen && onFullscreen();
  3233. } else {
  3234. // console.log("退出全屏函数");
  3235. win.$(element).find("#pageClose").remove();
  3236. //$(element).removeClass("scrollbar");
  3237. // $(element).css("padding","0px");
  3238. // $(element).css("box-sizing","border-box");
  3239. // element.style.height = 'auto';
  3240. // element.style.width = 'auto';
  3241. // element.setAttribute("isCmsFullScreen", 'false');
  3242. // element.style.overflowY = 'auto';
  3243. // element.style.height = '100%';
  3244. // element.style.width = '750px';
  3245. //添加监听器,监听用户进入全屏和退出全屏操作
  3246. marioVideo.removeEventListener(
  3247. "webkitfullscreenchange",
  3248. fullscreenchange
  3249. );
  3250. marioVideo.removeEventListener("fullscreenchange", fullscreenchange);
  3251. marioVideo.removeEventListener("mozfullscreenchange", fullscreenchange);
  3252. marioVideo.removeEventListener("msfullscreenchange", fullscreenchange);
  3253. onExitfullscreen && onExitfullscreen();
  3254. }
  3255. };
  3256. var elem = marioVideo;
  3257. marioVideo.addEventListener("webkitfullscreenchange", fullscreenchange);
  3258. marioVideo.addEventListener("fullscreenchange", fullscreenchange);
  3259. marioVideo.addEventListener("mozfullscreenchange", fullscreenchange);
  3260. marioVideo.addEventListener("msfullscreenchange", fullscreenchange);
  3261. if (marioVideo.requestFullscreen) {
  3262. marioVideo.requestFullscreen(elem);
  3263. } else if (marioVideo.msRequestFullscreen) {
  3264. marioVideo.msRequestFullscreen(elem);
  3265. } else if (marioVideo.mozRequestFullScreen) {
  3266. marioVideo.mozRequestFullScreen(elem);
  3267. } else if (marioVideo.webkitRequestFullScreen) {
  3268. marioVideo.webkitRequestFullScreen(elem);
  3269. }
  3270. };
  3271. wd.display.CmsFullScreen = function (
  3272. element,
  3273. onFullscreen,
  3274. onExitfullscreen,
  3275. win
  3276. ) {
  3277. win = win || element.ownerDocument.defaultView;
  3278. // var video,photo,pdf,word,flash;
  3279. // console.log(element);
  3280. var marioVideo = element;
  3281. try {
  3282. win.wd.display.CmsZNRFull(element);
  3283. } catch (e) {}
  3284. var fullscreenchange = function () {
  3285. if (win.document.webkitFullscreenElement != null) {
  3286. //$(element).addClass("scrollbar");
  3287. // $(element).css("padding","25px");
  3288. // $(element).css("box-sizing","border-box");
  3289. element.style.overflowY = "auto";
  3290. element.style.overflowX = "hidden";
  3291. element.style.width = "100%";
  3292. element.style.height = "100%";
  3293. // console.log("进入全屏函数");
  3294. element.setAttribute("isCmsFullScreen", "true");
  3295. win
  3296. .$(element)
  3297. .append(
  3298. '<div id="pageClose" class=" dhtmlx_skin_dhx_skyblue"><div class="dhtmlx_window_active"><div class="largeIcon-restore" style="position: fixed;right: 10px;top: 10px;" onclick="wd.display.exitFullScreen()" ></div></div></div>'
  3299. );
  3300. onFullscreen && onFullscreen();
  3301. } else {
  3302. // console.log("退出全屏函数");
  3303. win.$(element).find("#pageClose").remove();
  3304. //$(element).removeClass("scrollbar");
  3305. // $(element).css("padding","0px");
  3306. // $(element).css("box-sizing","border-box");
  3307. // element.style.height = 'auto';
  3308. // element.style.width = 'auto';
  3309. element.setAttribute("isCmsFullScreen", "false");
  3310. // element.style.overflowY = 'auto';
  3311. element.style.height = "100%";
  3312. element.style.width = "750px";
  3313. //回调退出全屏方法
  3314. var playlist = element.querySelectorAll("[data-init]");
  3315. for (var i = 0; i < playlist.length; i++) {
  3316. dataList = playlist[i].dataList;
  3317. for (var j = 0; dataList != null && j < dataList.length; j++) {
  3318. var data = dataList[j];
  3319. if (data.exitFunction) {
  3320. data.exitFunction.call(this, data);
  3321. }
  3322. }
  3323. delete playlist[i].dataList;
  3324. }
  3325. //添加监听器,监听用户进入全屏和退出全屏操作
  3326. marioVideo.removeEventListener(
  3327. "webkitfullscreenchange",
  3328. fullscreenchange
  3329. );
  3330. marioVideo.removeEventListener("fullscreenchange", fullscreenchange);
  3331. marioVideo.removeEventListener("mozfullscreenchange", fullscreenchange);
  3332. marioVideo.removeEventListener("msfullscreenchange", fullscreenchange);
  3333. onExitfullscreen && onExitfullscreen();
  3334. }
  3335. };
  3336. var elem = marioVideo;
  3337. marioVideo.addEventListener("webkitfullscreenchange", fullscreenchange);
  3338. marioVideo.addEventListener("fullscreenchange", fullscreenchange);
  3339. marioVideo.addEventListener("mozfullscreenchange", fullscreenchange);
  3340. marioVideo.addEventListener("msfullscreenchange", fullscreenchange);
  3341. if (marioVideo.requestFullscreen) {
  3342. marioVideo.requestFullscreen(elem);
  3343. } else if (marioVideo.msRequestFullscreen) {
  3344. marioVideo.msRequestFullscreen(elem);
  3345. } else if (marioVideo.mozRequestFullScreen) {
  3346. marioVideo.mozRequestFullScreen(elem);
  3347. } else if (marioVideo.webkitRequestFullScreen) {
  3348. marioVideo.webkitRequestFullScreen(elem);
  3349. }
  3350. };
  3351. //附件滑动和上下项
  3352. wd.display.CmsNrscroll = function (element, currSubNrid) {
  3353. var ismousedown = false;
  3354. var oldY, scollY;
  3355. var nrid = currSubNrid;
  3356. element.onmousedown = function (e) {
  3357. oldscrollTop = element.scrollTop;
  3358. oldY = e.screenY;
  3359. scollY = element.scrollTop;
  3360. ismousedown = true;
  3361. };
  3362. element.onmouseup = function (e) {
  3363. ismousedown = false;
  3364. };
  3365. element.onmousemove = function (e) {
  3366. // console.log(e.offsetY);
  3367. e = e || window.event;
  3368. var newY = e.screenY;
  3369. //console.log(ismousedown+":"+scollY +":"+ oldY +":"+ e.screenY +":"+(scollY + (oldY - e.screenY) * 2))
  3370. if (ismousedown) {
  3371. //console.log(element.scrollTop + element.clientHeight+"###"+element.scrollHeight)
  3372. if (
  3373. oldY - newY >= 150 &&
  3374. element.scrollTop + element.clientHeight + 1 >= element.scrollHeight &&
  3375. oldscrollTop + element.clientHeight + 1 >= element.scrollHeight
  3376. ) {
  3377. ismousedown = false;
  3378. // console.log("鼠标向上移动");
  3379. nrid = nextitem(nrid);
  3380. // console.log(element.getAttribute("isCmsFullScreen"));
  3381. } else if (
  3382. newY - oldY >= 150 &&
  3383. element.scrollTop <= 0 &&
  3384. oldscrollTop == 0
  3385. ) {
  3386. ismousedown = false;
  3387. // console.log("鼠标向下移动");
  3388. nrid = lastitem(nrid);
  3389. // console.log(element.getAttribute("isCmsFullScreen"));
  3390. } else {
  3391. element.scrollTop = scollY + (oldY - e.screenY); //此处调节滚动速度
  3392. }
  3393. }
  3394. };
  3395. function nextitem(nrid) {
  3396. var items = $(".dragList").find(".item");
  3397. var i = 0;
  3398. var result = nrid;
  3399. items.each(function () {
  3400. if (nrid == $(items[i]).find(".nrid").text()) {
  3401. if (i < items.length - 1) {
  3402. // $(items[i])[0].style.border = "solid 1px #CCCCCC";//全部边框变黑 20170929
  3403. // $(items[i + 1])[0].style.border = "2px solid #FF0000";//点击变红 20170929
  3404. selectItem($(items[i + 1])[0]);
  3405. loadPlayer(
  3406. $(items[i + 1])
  3407. .find(".nrid")
  3408. .text(),
  3409. $(items[i + 1])
  3410. .find(".nrjslbm")
  3411. .text()
  3412. );
  3413. result = $(items[i + 1])
  3414. .find(".nrid")
  3415. .text();
  3416. }
  3417. return false; //跳出循环
  3418. } else {
  3419. i++;
  3420. }
  3421. });
  3422. return result;
  3423. }
  3424. function lastitem(nrid) {
  3425. var items = $(".dragList").find(".item");
  3426. var i = 0;
  3427. var result = nrid;
  3428. items.each(function () {
  3429. if (nrid == $(items[i]).find(".nrid").text()) {
  3430. if (i > 0) {
  3431. // $(items[i])[0].style.border = "solid 1px #CCCCCC";//全部边框变黑 20170929
  3432. // $(items[i - 1])[0].style.border = "2px solid #FF0000";//点击变红 20170929
  3433. selectItem($(items[i - 1])[0]);
  3434. loadPlayer(
  3435. $(items[i - 1])
  3436. .find(".nrid")
  3437. .text(),
  3438. $(items[i - 1])
  3439. .find(".nrjslbm")
  3440. .text()
  3441. );
  3442. //$(items[i - 1])[0].scrollTop( $(items[i - 1])[0].scrollHeight );
  3443. result = $(items[i - 1])
  3444. .find(".nrid")
  3445. .text();
  3446. }
  3447. return false; //跳出循环
  3448. } else {
  3449. i++;
  3450. }
  3451. });
  3452. return result;
  3453. }
  3454. };
  3455. /**
  3456. * 退出登录
  3457. */
  3458. wd.display.exit = function (param) {
  3459. // console.log("exit")
  3460. wd.display.showLoad();
  3461. var beaconLogin =
  3462. wd.display.beaconLogin("loginOut") || wd.display.getBeaconWhetherToOpen();
  3463. param = param || {};
  3464. var homepage = 1 == param.homepage ? "&homepage=" + param.homepage : "";
  3465. var urlparam = "" + homepage;
  3466. /* 改。Lin
  3467. $.post("/service?wdApplication=wd&wdService=ss.exitByA&wdtest=false", {}, function (result) {
  3468. */
  3469. /* 再改,规范命名。Lin
  3470. * 去掉 ?wdApplication=,不支持多个应用 -- 服务名可以写 ss.xxx
  3471. * &wdService= 改为 ssServ
  3472. $.post("/service?wdApplication=wd&wdService=exit", {}, function (result) {
  3473. */ $.post(
  3474. "/service?ssServ=ssExit",
  3475. {},
  3476. function (result) {
  3477. // =exit"。Lin
  3478. var newurl =
  3479. result.path + (result.path.indexOf("?") == -1 ? "?" : "") + urlparam;
  3480. if (beaconLogin) {
  3481. setTimeout(function () {
  3482. wd.topWindow.location.href = newurl;
  3483. }, 1000);
  3484. } else {
  3485. wd.topWindow.location.href = newurl;
  3486. }
  3487. },
  3488. "json"
  3489. );
  3490. };
  3491. /**
  3492. * 执行当前弹窗的wdfitheight调整事件
  3493. */
  3494. wd.display.initWdFitHeight = function (windowobj) {
  3495. var dialogid = wd.display.getwdDialogId();
  3496. if (!dialogid) return;
  3497. //弹窗对象
  3498. var win = wd.topWindow.dhxWins.window(dialogid);
  3499. if (!win) return;
  3500. var nextiframe = win.getFrame();
  3501. var count = 0;
  3502. while (nextiframe != null) {
  3503. if (count > 10) break; // 最多查找10层iframe,防止死循环
  3504. count++;
  3505. //执行页面所在的初始化iframe事件
  3506. if (nextiframe.contentWindow.window.initWdFitHeightFunction) {
  3507. if (nextiframe.contentWindow.window != windowobj) {
  3508. nextiframe.contentWindow.window.initWdFitHeightFunction();
  3509. }
  3510. }
  3511. // console.log(nextiframe)
  3512. nextiframe = nextiframe.contentWindow.document.querySelector("iframe[src]");
  3513. }
  3514. };
  3515. /**
  3516. *
  3517. */
  3518. wd.display.submitToTopTab = function (submitBtn) {
  3519. if (!submitBtn) console.error("请指定submit按钮");
  3520. var myform = submitBtn.form.cloneNode(true);
  3521. myform.style.display = "none";
  3522. submitBtn.form.parentNode.innerHTML = "";
  3523. var win = window,
  3524. topFrame = wd.display.getFrameOfWindow(win);
  3525. while (topFrame.tabObj) {
  3526. //找到不是tab为止
  3527. win = win.parent;
  3528. topFrame = wd.display.getFrameOfWindow(win);
  3529. }
  3530. topFrame.contentWindow.document.body.appendChild(myform);
  3531. myform.submit();
  3532. // submitBtn.click();
  3533. };
  3534. /**
  3535. * 获取window所在的iframe
  3536. *
  3537. */
  3538. wd.display.getFrameOfWindow = function (win) {
  3539. win = win || window;
  3540. if (
  3541. win != win.top &&
  3542. win.parent &&
  3543. win.parent.document.querySelectorAll("iframe").length > 0
  3544. ) {
  3545. var pfs = win.parent.document.querySelectorAll("iframe");
  3546. for (var i = 0; i < pfs.length; i++) {
  3547. if (pfs[i].contentWindow == win) {
  3548. return pfs[i];
  3549. }
  3550. }
  3551. console.error("没找到上级window所对应当前window的iframe");
  3552. } else {
  3553. console.warn("当前页面不存在任何iframe底下");
  3554. return null;
  3555. }
  3556. };
  3557. /**
  3558. * 刷新当前的tabframe
  3559. */
  3560. wd.display.refreshTabFrame = function (wdTabNo) {
  3561. var frame = wd.display.getFrameOfWindow();
  3562. if (frame) {
  3563. if (frame.tabObj) {
  3564. if (wdTabNo && /[0-9]*/.test(wdTabNo)) {
  3565. // frame.contentWindow.wd.display.wdTabNo=wdTabNo;
  3566. var num = parseInt(wdTabNo);
  3567. frame.tabObj.selectClick(num);
  3568. } else {
  3569. frame.tabObj.selectTab.dom.click();
  3570. }
  3571. } else {
  3572. console.error("当前iframe不是tabFrame");
  3573. }
  3574. }
  3575. };
  3576. wd.display.changeFormAction = function (
  3577. url,
  3578. element,
  3579. width,
  3580. height,
  3581. minHeight,
  3582. maxHeight
  3583. ) {
  3584. var a = $(element).parents("form:first").attr("action", url);
  3585. if (a.length != 1) {
  3586. alert("找不到form元素");
  3587. return false;
  3588. }
  3589. if (a[0].checkOnly) {
  3590. if (!a[0].checkOnly(true)) {
  3591. return;
  3592. }
  3593. }
  3594. if (width && height && minHeight && maxHeight) {
  3595. wd.display.resizeComponent(width, height, minHeight, maxHeight);
  3596. }
  3597. return true;
  3598. };
  3599. wd.display.MsgManager = function (timeout, minHeight, minWidth) {
  3600. if (wd.topWindow.popupPanel == null) {
  3601. // 动画小圈圈
  3602. //flashMessageDocument--fmd
  3603. $("body", wd.topWindow.document).append(
  3604. '<div id="fMD" style="position: fixed; display:none; pointer-events:none; z-index: 9999;" class="cursor-loading" /></div>'
  3605. );
  3606. this.element = wd.topWindow.popupPanel = $(
  3607. '<div id="flashmsgtipsId" class="flashMsg-div" style="display:none;position:fixed;z-index:999"><div class=\'flashMsg-down\' style=\'bottom: -10px;left: 7px\'></div></div>'
  3608. );
  3609. $("body", wd.topWindow.document).append(wd.topWindow.popupPanel);
  3610. timeout = timeout || 1300;
  3611. // minHeight = minHeight || "10px";
  3612. // minWidth = minWidth || "70px";
  3613. // this.element[0].className = "flashMsg-div";
  3614. // this.element[0].id = "flashmsgtipsId";
  3615. // $(".flashMsg-div").append("<div class='flashMsg-down' style='bottom: -10px;left: 7px'></div>");
  3616. // this.element.css({
  3617. // display: "none",
  3618. // position: "fixed",
  3619. // // minHeight: minHeight,
  3620. // // minWidth: minWidth,
  3621. // "z-index": "999"
  3622. // });
  3623. this.messages = [];
  3624. var this_ = this;
  3625. setInterval(function () {
  3626. // if (this_.messages.length > 1) {
  3627. // this_.removeMsg(this_.messages.shift());
  3628. // } else if (this_.messages.length == 1) {
  3629. // setTimeout(function () {
  3630. // this_.removeMsg(this_.messages.shift());
  3631. // }, 1700);
  3632. // }
  3633. if (this_.messages.length > 0) {
  3634. var span = this_.messages.shift();
  3635. setTimeout(function () {
  3636. this_.removeMsg(span);
  3637. }, span.data("timeout"));
  3638. }
  3639. }, timeout);
  3640. }
  3641. this.removeMsg = function (span) {
  3642. var $span = $(span);
  3643. $span.slideUp("normal", function () {
  3644. $span.trigger("onHide");
  3645. $span.remove();
  3646. });
  3647. this.messages.length == 0 && this.element.fadeOut("fast");
  3648. };
  3649. this.pushMsg = function (msg, options) {
  3650. if (msg == "" || msg == null) return;
  3651. var $span = $("<p>");
  3652. $span.text(msg);
  3653. $span.data("timeout", Math.max(300 * (msg.length / 3), 1700));
  3654. $span.bind("onShow", function () {
  3655. options && options.onShow && options.onShow.call(this);
  3656. });
  3657. $span.bind("onHide", function () {
  3658. options && options.onHide && options.onHide.call(this);
  3659. });
  3660. this.messages.push($span);
  3661. this.element.prepend($span).show();
  3662. $span.fadeIn("normal", function () {
  3663. $span.trigger("onShow");
  3664. });
  3665. };
  3666. };
  3667. //开启加载动画
  3668. wd.display.showLoad = function () {
  3669. wd.topWindow.$("#fMD").show();
  3670. };
  3671. //关闭加载动画
  3672. wd.display.closeLoad = function () {
  3673. wd.topWindow.$("#fMD").hide();
  3674. };
  3675. if (!window.flashmsgmousemove) {
  3676. window.flashmsgmousemove = 1;
  3677. document.addEventListener("mousemove", function () {
  3678. if (wd.topWindow.$("#flashmsgtipsId").is(":visible")) {
  3679. return;
  3680. }
  3681. if (wd.display.isFixation) {
  3682. return;
  3683. }
  3684. // 有弹出窗口且大于 1 时,MSG固定右下角
  3685. if (wd.topWindow.$(".wdMaskDiv").size() > 1) {
  3686. setFixation();
  3687. }
  3688. // 无弹出窗口或弹出窗口等于 1 时,MSG跟随鼠标
  3689. else {
  3690. var xy, x, y;
  3691. try {
  3692. xy = recursionIframe();
  3693. x = window.event.pageX += xy.left;
  3694. y = window.event.pageY += xy.top;
  3695. } catch (e) {
  3696. //console.log("xy err " + e)
  3697. x = window.event.pageX;
  3698. y = window.event.pageY;
  3699. }
  3700. if (wd.topWindow.$("#flashmsgtipsId").find("p").size() < 1) {
  3701. // wd.topWindow.$("#flashmsgtipsId").addClass("flashmsgtips").removeClass("flashmsgtips-submit");
  3702. wd.topWindow.$("#flashmsgtipsId").css({
  3703. top: y - 53 + "px",
  3704. left: x - 7 + "px",
  3705. bottom: "",
  3706. right: "",
  3707. });
  3708. }
  3709. wd.topWindow.$("#fMD").css("left", x - 10);
  3710. wd.topWindow.$("#fMD").css("top", y - 4);
  3711. }
  3712. });
  3713. }
  3714. wd.display.showMsgPopup = function (msg, options) {
  3715. if (window.location.href.indexOf("view.jsp") > 0) return;
  3716. var msgs = (wd.topWindow.wd.display.popupMsgMagager =
  3717. wd.topWindow.window.wd.display.popupMsgMagager ||
  3718. new wd.topWindow.window.wd.display.MsgManager());
  3719. msgs.pushMsg(msg, options);
  3720. if (wd.display.isFixation) {
  3721. setFixation();
  3722. }
  3723. };
  3724. var setFixation = function () {
  3725. // wd.topWindow.$("#flashmsgtipsId").addClass("flashmsgtips-submit").removeClass('flashmsgtips');
  3726. wd.topWindow.$("#flashmsgtipsId").css({
  3727. bottom: "50px",
  3728. right: "10px",
  3729. top: "",
  3730. left: "",
  3731. });
  3732. };
  3733. var recursionIframe = function (win) {
  3734. try {
  3735. win = win || window;
  3736. function getTop(e) {
  3737. var offset = e.offsetTop;
  3738. if (e.offsetParent != null) offset += getTop(e.offsetParent);
  3739. return offset;
  3740. }
  3741. function getLeft(e) {
  3742. var offset = e.offsetLeft;
  3743. if (e.offsetParent != null) offset += getLeft(e.offsetParent);
  3744. return offset;
  3745. }
  3746. if ((win.parent == top && win.parent == win) || win.document == undefined) {
  3747. return {
  3748. left: 0,
  3749. top: 0,
  3750. };
  3751. }
  3752. var winPar = win.parent;
  3753. var iframeArr = winPar.document.getElementsByTagName("IFRAME");
  3754. var targetIframe;
  3755. var iframeArr1 = win.document.getElementsByTagName("IFRAME");
  3756. for (var i = 0; i < iframeArr1.length; i++) {
  3757. var iframeElem = iframeArr1[i];
  3758. if (iframeElem.contentWindow == win) {
  3759. targetIframe = iframeElem;
  3760. break;
  3761. }
  3762. }
  3763. for (var i = 0; i < iframeArr.length; i++) {
  3764. var iframeElem = iframeArr[i];
  3765. if (iframeElem.contentWindow == win) {
  3766. targetIframe = iframeElem;
  3767. break;
  3768. }
  3769. }
  3770. var xy = {
  3771. left: getLeft(targetIframe),
  3772. top: getTop(targetIframe),
  3773. };
  3774. if (winPar.parent != winPar) {
  3775. var xy2 = recursionIframe(winPar);
  3776. xy.left += xy2.left;
  3777. xy.top += xy2.top;
  3778. }
  3779. return xy;
  3780. } catch (e) {
  3781. console.log("Point err " + e);
  3782. }
  3783. };
  3784. wd.display.resizeComponent = function (width, height, minHeight, maxHeight) {
  3785. if (parseInt(width) == "NaN" || parseInt(height) == "NaN") return;
  3786. var dialog = wd.display.getwdDialogWindows();
  3787. if (!dialog) return;
  3788. var changesize = true;
  3789. if (minHeight && !isNaN(minHeight) && maxHeight && !isNaN(maxHeight)) {
  3790. minHeight = parseInt(minHeight);
  3791. maxHeight = parseInt(maxHeight);
  3792. if (minHeight + this.Yi > wd.topWindow.innerHeight) {
  3793. height = minHeight + this.Yi;
  3794. // showNameOrId = 'wdFullScreen';
  3795. // fullScreenLimitHeight = false;
  3796. } else if (maxHeight + this.Yi < wd.topWindow.innerHeight) {
  3797. height = maxHeight + this.Yi;
  3798. } else {
  3799. height = wd.topWindow.innerHeight;
  3800. changesize = true;
  3801. // changesize = false;
  3802. // showNameOrId = 'wdFullScreen';
  3803. }
  3804. }
  3805. wd.display.addDialogLine();
  3806. if (changesize) {
  3807. dialog.setDimension(width, height);
  3808. dialog.keepInViewport(false);
  3809. dialog.center();
  3810. }
  3811. };
  3812. wd.display.reset = function (
  3813. type,
  3814. submitBtn,
  3815. url,
  3816. width,
  3817. height,
  3818. minHeight,
  3819. maxHeight
  3820. ) {
  3821. var canSubmit = false;
  3822. if (submitBtn.iscommit) {
  3823. canSubmit = true;
  3824. } else if (!submitBtn.form) {
  3825. console.warn("没找到元素所在form");
  3826. } else {
  3827. if (!submitBtn.form.checkOnly) {
  3828. //没有校验器
  3829. canSubmit = true;
  3830. } else if (submitBtn.form.checkOnly(true)) {
  3831. //验证通过
  3832. canSubmit = true;
  3833. } else {
  3834. //表单验证不通过
  3835. canSubmit = false;
  3836. }
  3837. }
  3838. if (canSubmit) {
  3839. wd.display.changeFormAction(url, submitBtn);
  3840. if (type == "dialog") {
  3841. wd.display.resizeComponent(width, height, minHeight, maxHeight);
  3842. wd.display.submitToTopTab(submitBtn);
  3843. return false;
  3844. }
  3845. // submitBtn.iscommit = true;
  3846. // submitBtn.click();
  3847. }
  3848. return canSubmit;
  3849. };
  3850. /**
  3851. * commwrite oneLine=true 限制宽度,结尾添加'...'
  3852. * @param {Object} ele
  3853. */
  3854. wd.display.initOneLine = function (ele) {
  3855. try {
  3856. var parent = ele.parentNode;
  3857. parent.removeChild(ele);
  3858. parent.setAttribute("title", parent.innerHTML);
  3859. parent.style.overflow = "hidden";
  3860. parent.style.textOverflow = "ellipsis";
  3861. parent.style.whiteSpace = "nowrap";
  3862. // 如果无效 table加样式 table-layout: fixed;
  3863. // var poffsetW = parent.offsetWidth;
  3864. // var pscrollW = parent.scrollWidth;
  3865. // console.log(poffsetW+" "+pscrollW)
  3866. // parent.setAttribute("aaa",poffsetW+"/"+pscrollW)
  3867. // if(poffsetW<pscrollW){
  3868. // parent.style.overflow="hidden";
  3869. // parent.style.textOverflow="ellipsis";
  3870. // parent.style.whiteSpace="nowrap";
  3871. // }
  3872. } catch (e) {
  3873. console.log(e);
  3874. }
  3875. };
  3876. wd.display.callback_suffix = "confirm_callback";
  3877. wd.display.cancelcallback_suffix = "cancel_callback";
  3878. wd.display.confirm = function (title, msg, callback, cancelCallback) {
  3879. var params = {
  3880. dialog: "dialog",
  3881. width: 400,
  3882. height: 180,
  3883. };
  3884. //第一个参数是对象参数 {title:title,msg:msg}
  3885. if (typeof title == "object") {
  3886. $.extend(params, title);
  3887. } else {
  3888. params.title = title;
  3889. params.msg = msg;
  3890. params.callback = callback;
  3891. params.cancelCallback = cancelCallback;
  3892. params.url = "/page/sure.jsp?msg=" + encodeURIComponent(msg);
  3893. }
  3894. /// 增加,来自 PMS下载。Lin
  3895. if (!params.url)
  3896. params.url = "/page/sure.jsp?msg=" + encodeURIComponent(params.msg);
  3897. ///
  3898. var dialogid = wd.display.showComponent({
  3899. show: ["wdDialog"],
  3900. hide: [],
  3901. url: params.url,
  3902. title: params.title || " ",
  3903. width: params.width,
  3904. height: params.height,
  3905. });
  3906. if (typeof params.callback == "string") {
  3907. // window[dialogid+wd.display.callback_suffix]=eval(callback);
  3908. window[dialogid + wd.display.callback_suffix] = function () {
  3909. var iframe = wd.display.getFrameOfWindow();
  3910. // console.log(this)
  3911. if (iframe.tabObj == null) {
  3912. this.location = params.callback;
  3913. } else {
  3914. this.parent.location = params.callback;
  3915. }
  3916. };
  3917. } else if (typeof params.callback == "function") {
  3918. window[dialogid + wd.display.callback_suffix] = params.callback;
  3919. }
  3920. if (params.cancelCallback) {
  3921. window[dialogid + wd.display.cancelcallback_suffix] = params.cancelCallback;
  3922. }
  3923. };
  3924. //window.confirm = wd.display.confirm;
  3925. //
  3926. wd.display.alert = function (message, options) {
  3927. wd.display.showMsgPopup(message, options);
  3928. };
  3929. // window.alert = wd.display.alert; // 再去掉,恢复 window.alert -- 需要使用不定时消失的对话框。Lin
  3930. // isFixation 为 true 时,弹窗将立刻固定在右下角
  3931. wd.display.isFixation = false;
  3932. wd.display.fixationAlert = function (message, options) {
  3933. wd.display.isFixation = true;
  3934. wd.display.showMsgPopup(message, options);
  3935. wd.display.isFixation = false;
  3936. };
  3937. // window.alert = wd.display.fixationAlert; // 再去掉,恢复 window.alert -- 需要使用不定时消失的对话框。Lin
  3938. /**
  3939. *
  3940. * 获取弹窗内所有window对象
  3941. *
  3942. */
  3943. wd.display.getwdDialogWindowObjects = function (wdDialogId) {
  3944. var contain = wd.display.getwdDialogWindows(wdDialogId);
  3945. if (!contain) return null;
  3946. var aaa = [];
  3947. var thisIframe = contain.getFrame();
  3948. var cc = 0;
  3949. do {
  3950. if (thisIframe.contentWindow.closed) break;
  3951. aaa.push(thisIframe.contentWindow.window);
  3952. thisIframe = thisIframe.contentWindow.document.querySelector("iframe");
  3953. cc++;
  3954. } while (thisIframe && cc <= 100);
  3955. return aaa;
  3956. };
  3957. wd.display.shareTable = function (wdDialogId) {
  3958. // console.log("archive!");
  3959. var iframe = wd.display.getFrameOfWindow();
  3960. //归档按钮
  3961. if (iframe != null && iframe.contentWindow == window) {
  3962. var bottom_div = $(".bottom-down-div");
  3963. if (bottom_div.find(".submitButton").length == 0) {
  3964. // bottom_div.append("<input type=\"button\" class=\"bottom-button submitButton\" value=\"确认\" />")
  3965. // bottom_div.append("<input type=\"button\" class=\"bottom-button authorize\" value=\"授权\" />")
  3966. // bottom_div.append("<select id=\"xxgkfsmOption\"><option value='1'>系统内公开</option><option value='1'>不公开</option></select>")
  3967. bottom_div.html(
  3968. '<input type="button" class="bottom-button submitButton" value="确认" />' +
  3969. '<input type="button" class="bottom-button authorize" value="授权" />' +
  3970. '<select id="xxgkfsmOption" style="display:none;"><option value="1">系统内公开</option><option value="1">不公开</option></select>' +
  3971. bottom_div.html()
  3972. );
  3973. bottom_div.on("click", ".authorize", function () {
  3974. wd.display.getwdDialogWindows().getFrame().contentWindow.authorize();
  3975. });
  3976. bottom_div.on("click", ".submitButton", function () {
  3977. wd.display.getwdDialogWindows().getFrame().contentWindow.agree();
  3978. });
  3979. }
  3980. }
  3981. var tokenList = [];
  3982. var tokenData = {};
  3983. var $elements = $("[onclick^='wd.display.showComponent']:not(:hidden)").each(
  3984. function (num, ele) {
  3985. var showComponentFunStr = this.getAttribute("onClick");
  3986. //获取token查询
  3987. var reg = new RegExp("ssToken=[0-9a-zA-Z]+", "g"); // ("token=[。Lin
  3988. var patt = reg.exec(showComponentFunStr);
  3989. if (patt == null) return true;
  3990. var token = patt[0].split("=")[1];
  3991. tokenList.push(token);
  3992. tokenData[token] = {
  3993. type: "childObject",
  3994. ele: this,
  3995. };
  3996. }
  3997. );
  3998. // console.log(tokenData)
  3999. if (iframe != null && iframe.contentWindow == window) {
  4000. var reg = new RegExp("ssToken=[0-9a-zA-Z]+", "g"); // ("token=[。Lin
  4001. var patt = reg.exec(window.location.href);
  4002. var token = "";
  4003. if (patt == null) {
  4004. // return true
  4005. token = window.location.href;
  4006. } else {
  4007. token = patt[0].split("=")[1];
  4008. }
  4009. tokenList.push(token);
  4010. tokenData[token] = {
  4011. type: "primaryObject",
  4012. };
  4013. }
  4014. if (tokenList.length == 0) return;
  4015. // console.log(tokenList)
  4016. /* 再改,规范命名。Lin
  4017. * 去掉 ?wdApplication=,不支持多个应用 -- 服务名可以写 ss.xxx
  4018. * &wdService= 改为 ssServ
  4019. $.post("/service?wdApplication=wd&wdService=objectDataQueryByToken", {
  4020. */ $.post(
  4021. "/service?ssServ=objectDataQueryByToken",
  4022. {
  4023. tokenList: JSON.stringify(tokenList),
  4024. },
  4025. function (data) {
  4026. data = eval(data);
  4027. var mark = wd.topWindow.mark[wdDialogId];
  4028. // console.log(tokenData)
  4029. for (var i = 0; i < data.length; i++) {
  4030. var temp = data[i];
  4031. var ele = tokenData[temp.token].ele;
  4032. var type = tokenData[temp.token].type;
  4033. var keyid = temp.object + temp.id;
  4034. var checked =
  4035. temp.checked == "true" || temp.checked == true ? true : false;
  4036. if (!mark[keyid]) {
  4037. mark[keyid] = {
  4038. id: temp.id,
  4039. type: type,
  4040. object: temp.object,
  4041. checkStatue: checked,
  4042. checked: checked,
  4043. };
  4044. }
  4045. // console.log(mark[keyid]);
  4046. // console.log(mark[keyid])
  4047. if (type != "childObject") continue;
  4048. var topDoc = window.document;
  4049. var chartDiv = topDoc.createElement("div");
  4050. chartDiv.setAttribute("id", keyid);
  4051. topDoc.body.appendChild(chartDiv);
  4052. // chartDiv.innerHTML = "<input id=\"" + keyid + "\" type='checkbox' " + (mark[keyid].checked ? "checked" : "") +
  4053. // " value='' />";
  4054. if (mark[keyid].checked) {
  4055. chartDiv.setAttribute("class", "smallButton-checked checked");
  4056. } else {
  4057. chartDiv.setAttribute("class", "smallButton-unchecked");
  4058. }
  4059. var bounding = ele.getBoundingClientRect();
  4060. $(chartDiv).css({
  4061. left: bounding.left - chartDiv.offsetWidth * 0.5,
  4062. top: bounding.top + ele.offsetHeight * 0.5 - chartDiv.offsetHeight,
  4063. // width: "auto",
  4064. // height: ele.offsetHeight,
  4065. zIndex: 65535,
  4066. position: "absolute",
  4067. // background: (mark[keyid].checkStatue != mark[keyid].checked ? 'red' : 'cyan'),
  4068. // display: 'block'
  4069. });
  4070. $(chartDiv).on("click", function () {
  4071. var id = this.getAttribute("id");
  4072. var checked = $(this).hasClass("smallButton-unchecked");
  4073. var mark = wd.topWindow.mark[wdDialogId];
  4074. mark[id]["checked"] = checked;
  4075. // console.log(checked)
  4076. if (checked) {
  4077. this.setAttribute("class", "smallButton-checked");
  4078. } else {
  4079. this.setAttribute("class", "smallButton-unchecked");
  4080. }
  4081. //
  4082. //
  4083. // $(this).css({
  4084. // background: (mark[id]["checkStatue"] != mark[id]["checked"] ? 'red' : 'cyan'),
  4085. // })
  4086. // console.log(wd.topWindow.mark[wdDialogId])
  4087. });
  4088. }
  4089. }
  4090. );
  4091. };
  4092. //临时js
  4093. $(function () {
  4094. //首页模板添加样式
  4095. if (wd.topWindow && wd.topWindow.MenuSetting) {
  4096. var topiframe = wd.topWindow.document.querySelector(
  4097. "iframe[name=" + wd.topWindow.MenuSetting.target + "]"
  4098. );
  4099. if (topiframe && topiframe.contentWindow) {
  4100. if (topiframe.contentWindow == window) {
  4101. $(window.document.body).addClass("home-div");
  4102. $(wd.topWindow.document.body).addClass("home-div");
  4103. $(".gridster,#pg_cj").addClass("home-div");
  4104. }
  4105. }
  4106. }
  4107. //动态添加单记录授权按钮
  4108. var wdDialogId = wd.display.getwdDialogId();
  4109. // return;
  4110. if (!wdDialogId) return;
  4111. if (!wd.topWindow.mark) wd.topWindow.mark = {};
  4112. //打标记
  4113. if (document.querySelector("meow")) {
  4114. if (!wd.topWindow.mark[wdDialogId]) wd.topWindow.mark[wdDialogId] = {};
  4115. }
  4116. if (wd.topWindow.mark[wdDialogId]) {
  4117. wd.display.shareTable(wdDialogId);
  4118. }
  4119. var win = wd.topWindow.dhxWins.window(wdDialogId);
  4120. if (wd.topWindow.lockScreen) {
  4121. win.button("lockScreen").onclick = function () {
  4122. wd.display.beaconLogin("loginOut");
  4123. wd.topWindow.lockScreen();
  4124. };
  4125. win.button("lockScreen").show();
  4126. }
  4127. });
  4128. //查询获取object的function服务
  4129. //结果用来调用弹窗方法 wd.display.showComponent.call(window,r);
  4130. wd.display.createObjectService = function (objName, functionName) {
  4131. var p = {
  4132. objName: objName,
  4133. funcName: functionName,
  4134. };
  4135. var r = null;
  4136. $.ajax({
  4137. type: "post",
  4138. /* 再改,规范命名。Lin
  4139. * 去掉 ?wdApplication=,不支持多个应用 -- 服务名可以写 ss.xxx
  4140. * &wdService= 改为 ssServ
  4141. url: "/service?wdApplication=wd&wdService=createObjectService&wdtest=false",
  4142. */ url: "/service?ssServ=makeFuncParm",
  4143. data: p,
  4144. async: false,
  4145. dataType: "json",
  4146. success: function (result) {
  4147. r = result;
  4148. // console.log(r);
  4149. addRemoveToken(r.token);
  4150. r.show = "wdDialog";
  4151. // wd.display.showComponent.call(window,r);
  4152. if (r.pageList) {
  4153. for (var i = 0; i < r.pageList.lenth; i++) {
  4154. addRemoveToken(r.pageList[i].token);
  4155. }
  4156. }
  4157. },
  4158. error: function (error) {
  4159. // alert("查询失败")
  4160. console.log(error);
  4161. },
  4162. });
  4163. return r;
  4164. };
  4165. wd.display.showTextTile = function (id, msg) {
  4166. var iii = document.getElementById(id);
  4167. iii.parentNode.setAttribute("title", msg);
  4168. iii.parentNode.removeChild(iii);
  4169. };
  4170. var styleAttrs = {
  4171. width: "width",
  4172. height: "minHeight",
  4173. };
  4174. var isdebug = false;
  4175. wd.display.initGrowHighHtml = function (areaId, maxHeight, buttons) {
  4176. return wd.display.initGrowHigh(areaId, maxHeight, buttons, true);
  4177. };
  4178. wd.display.initGrowHigh = function (areaId, maxHeight, buttons, multimedia) {
  4179. // if (typeof GrowHeight == "undefined")
  4180. // $.getScript("/wd/js/growHeight.js", function () {
  4181. // getGrowHeight(areaId, maxHeight, buttons);
  4182. // });
  4183. // else
  4184. return getGrowHeight(areaId, maxHeight, buttons, multimedia ? 2 : 3);
  4185. };
  4186. /* 再改,部件里的 var wdFitHeightbqgd= 改为 ssLblHeightByFith=。Lin
  4187. if (!window.wdFitHeightbqgd) {
  4188. window.wdFitHeightbqgd = 0;
  4189. }
  4190. */
  4191. if (!window.ssLblHeightByFith) window.ssLblHeightByFith = 0;
  4192. /**
  4193. * wdfitheight传入减去高度
  4194. */
  4195. wd.display.fitHeightbqgd = function (n) {
  4196. /* 再改,部件里的 var wdFitHeightbqgd= 改为 ssLblHeightByFith=。Lin
  4197. window.wdFitHeightbqgd += n;
  4198. */ window.ssLblHeightByFith += n;
  4199. };
  4200. wd.display.initGrowHighByIds = function (ids, maxHeight) {
  4201. for (var i = 0; i < ids.length; i++) {
  4202. if (typeof ids[i] != "string") {
  4203. console.error("这不是一个ID");
  4204. continue;
  4205. }
  4206. wd.display.initGrowHigh(ids[i], maxHeight, {});
  4207. }
  4208. };
  4209. wd.display.ellipsisContent = function (dom, height) {
  4210. function setText(text) {
  4211. var nn = this.nodeName;
  4212. if (nn == "TEXTAREA" || nn == "INPUT") {
  4213. this.value = text;
  4214. } else {
  4215. this.innerText = text;
  4216. }
  4217. }
  4218. function getText() {
  4219. var nn = this.nodeName;
  4220. if (nn == "TEXTAREA" || nn == "INPUT") {
  4221. return this.value;
  4222. } else {
  4223. return this.innerText;
  4224. }
  4225. }
  4226. function haveScroll(dom) {
  4227. return dom.scrollHeight > dom.clientHeight;
  4228. }
  4229. function getCnHeight() {
  4230. var otxt = getText.call(this);
  4231. setText.call(this, "中");
  4232. var cnHeight = Math.max(this.scrollHeight, this.clientHeight);
  4233. setText.call(this, otxt);
  4234. return cnHeight;
  4235. }
  4236. var css = dom.style.cssText,
  4237. $dom = $(dom),
  4238. srcText = getText.call(dom);
  4239. dom.srcText = srcText;
  4240. var _style = window.getComputedStyle(dom);
  4241. var fontSize = _style.fontSize;
  4242. fontSize = parseInt(fontSize) || $("body").css("font-size");
  4243. var domWidth = $dom.width();
  4244. var cnHeight = getCnHeight.call(dom);
  4245. height =
  4246. height || parseFloat(_style.height) || parseFloat($dom.css("min-height"));
  4247. height = Math.max(cnHeight, height);
  4248. dom.style.setProperty("height", height + "px", "important");
  4249. setText.call(dom, dom.srcText);
  4250. if (srcText.length == 0 || height == 0) {
  4251. dom.style.cssText = css;
  4252. return srcText;
  4253. }
  4254. // console.log(dom, cnHeight, height, fontSize, haveScroll(dom));
  4255. // var noBlankText = srcText.replace(/\s/g, "");
  4256. var endOffset = parseInt(domWidth / fontSize); //大概一行的字数
  4257. var viewText = srcText.substring(0, endOffset);
  4258. setText.call(dom, viewText);
  4259. var dot = false;
  4260. while (endOffset < srcText.length && !haveScroll(dom)) {
  4261. //还有字但是没有滚动条,加
  4262. endOffset++;
  4263. viewText = srcText.substring(0, endOffset);
  4264. setText.call(dom, viewText);
  4265. if (haveScroll(dom)) {
  4266. //
  4267. dot = true;
  4268. }
  4269. }
  4270. while (endOffset > 0 && haveScroll(dom)) {
  4271. //出了滚动条,减
  4272. endOffset--;
  4273. viewText = viewText.substring(0, endOffset) + "...";
  4274. (function (vt) {
  4275. setText.call(dom, vt);
  4276. })(viewText);
  4277. }
  4278. setText.call(dom, viewText);
  4279. dom.style.cssText = css;
  4280. return viewText;
  4281. };
  4282. //显示tag圆点
  4283. wd.display.showTagState = function (url) {
  4284. // console.log(url)
  4285. $(function () {
  4286. var tokenList = [];
  4287. var lis = document.querySelectorAll("[ssTabClick]"); // ("[wdtabclick]")。先改,是 wdtabclick,不是 wdTabClick。Lin
  4288. for (var i = 0; i < lis.length; i++) {
  4289. var reg = new RegExp("ssToken=[0-9a-zA-Z]+", "g"); // ("token=[。Lin
  4290. var patt = reg.exec(lis[i].getAttribute("ssTabClick")); // ("wdtabclick"))。先改,是 wdtabclick,不是 wdTabClick。Lin
  4291. if (patt == null) {
  4292. tokenList.push(null);
  4293. } else {
  4294. var token = patt[0].split("=")[1];
  4295. tokenList.push(token);
  4296. }
  4297. }
  4298. // console.log(7777777777)
  4299. // console.log(tokenList)
  4300. //
  4301. $.post(
  4302. url,
  4303. {
  4304. tokenList: JSON.stringify(tokenList),
  4305. },
  4306. function (result) {
  4307. result = eval("(" + result + ")");
  4308. // console.log(result);
  4309. for (var i = 0; i < lis.length; i++) {
  4310. if (!result[i]) continue;
  4311. if (true == result[i].cgxList) {
  4312. // ("true" ==。字符串改为布尔型。Lin
  4313. lis[i].innerHTML =
  4314. lis[i].innerHTML +
  4315. '<span class="statePoint icon-highlightPoint"></span>';
  4316. } else if (true == result[i].objectList) {
  4317. // ("true" ==。字符串改为布尔型。Lin
  4318. lis[i].innerHTML =
  4319. lis[i].innerHTML +
  4320. '<span class="statePoint icon-dimPoint"></span>';
  4321. } else {
  4322. }
  4323. }
  4324. }
  4325. );
  4326. });
  4327. };
  4328. //级联查看 growheight前文本处理
  4329. wd.display.combineDiv = function (id) {
  4330. // console.log($("#" + id).children().find("[id$=combine]"))
  4331. //
  4332. if (
  4333. $("#" + id)
  4334. .children()
  4335. .find("[id$=combine]").length > 0
  4336. )
  4337. return;
  4338. var content = "";
  4339. var isCascading =
  4340. $("#" + id).find(".content-offButton,.content-onButton").length == 0;
  4341. if (isCascading) {
  4342. $("#" + id)
  4343. .children(":visible")
  4344. .each(function () {
  4345. content += this.innerHTML + "&nbsp;";
  4346. });
  4347. } else {
  4348. $("#" + id)
  4349. .find(":visible")
  4350. .each(function () {
  4351. if ($(this).is("[type=button]")) {
  4352. // var name = this.getAttribute("name");
  4353. // if ("1" == $("[type=hidden][name=" + name + "]").val()) {
  4354. // content += ($("[type=button][name=" + name + "][wdValue=1]").val() + "&nbsp;");
  4355. // }
  4356. if ($(this).hasClass("content-onButton")) {
  4357. content += $(this).val() + "&nbsp;";
  4358. }
  4359. }
  4360. });
  4361. }
  4362. if (/\&nbsp\;$/.test(content))
  4363. content = content.substring(0, content.length - "&nbsp;".length);
  4364. $("#" + id)
  4365. .empty()
  4366. .html(content);
  4367. };
  4368. wd.display.initSelectOption = function (id) {
  4369. wd.topWindow.$("#" + id).remove();
  4370. var ele = $(
  4371. '<div id="' +
  4372. id +
  4373. '" class="popup-div hLine-highlightBlod" >' +
  4374. '<div class="scrollbar" style="max-height:250px;overflow-x:auto;padding-right:16px;"></div>' +
  4375. "</div>"
  4376. )[0];
  4377. wd.topWindow.document.body.appendChild(ele);
  4378. return ele;
  4379. };
  4380. wd.display.buildSelectOption = function (
  4381. dom,
  4382. datalist,
  4383. valueKey,
  4384. nameKey,
  4385. selectValue,
  4386. hasNullOption
  4387. ) {
  4388. var ul = dom.childNodes[0];
  4389. if (datalist && datalist.length > 0) {
  4390. var listr = hasNullOption
  4391. ? '<div class="popupList" status="noitem">&nbsp;&nbsp;&nbsp;</div>'
  4392. : "";
  4393. for (var i = 0; i < datalist.length; i++) {
  4394. var name = datalist[i][nameKey];
  4395. var value = datalist[i][valueKey];
  4396. listr +=
  4397. '<div class="' +
  4398. (value == selectValue ? " selected " : "") +
  4399. 'popupList" status="people" value="' +
  4400. value +
  4401. '"' +
  4402. 'index="' +
  4403. i +
  4404. '">' +
  4405. name +
  4406. "</div>";
  4407. }
  4408. ul.innerHTML = listr;
  4409. } else {
  4410. ul.innerHTML = hasNullOption
  4411. ? '<div class="popupList" status="noitem">找不到相关项</div>'
  4412. : "";
  4413. }
  4414. };
  4415. wd.display.queryNrSubNr = function (nrid, jlztm, datas) {
  4416. var result = [];
  4417. $.ajax({
  4418. type: "post",
  4419. url: "/service",
  4420. dataType: "json",
  4421. data: {
  4422. ssServ: "wrCmsList", // wdService: "nrxtsy",。Lin
  4423. nrid: "T-" + nrid,
  4424. sfbf: 1,
  4425. jlztm: jlztm,
  4426. },
  4427. async: false,
  4428. success: function (jsonData) {
  4429. for (var i = 0; i < jsonData.length; i++) {
  4430. result.push({
  4431. name: jsonData[i].mc,
  4432. value: jsonData[i].mswj,
  4433. nrjslbm: jsonData[i].nrjslbm,
  4434. });
  4435. }
  4436. },
  4437. });
  4438. return result;
  4439. };
  4440. wd.display.initCmsbtn = function (btn, fjid) {
  4441. if (fjid != null && fjid != "") {
  4442. $.ajax({
  4443. type: "post",
  4444. url: "/service?ssServ=wrCcmsList", // =getSubNrCount",。Lin
  4445. data: {
  4446. nrid: "T-" + fjid,
  4447. jlztm: 51,
  4448. },
  4449. dataType: "json", // 增加,统一 Ajax 返回标准 -- .ssCode、.ssMsg、.ssData。Lin
  4450. success: function (data) {
  4451. /* 改,增加错误处理 -- 统一 Ajax 返回标准 -- .ssCode、.ssMsg、.ssData。Lin
  4452. * 去掉 JSON.parse(,改为用 Map<String, Object> 传输
  4453. var names = JSON.parse(data);
  4454. */
  4455. if (data.ssCode != 0) {
  4456. alert(data.ssMsg);
  4457. return;
  4458. }
  4459. var names = data.ssData;
  4460. var count = names.length;
  4461. //if (count > 0) {
  4462. var num = btn[0].querySelector(".attachment_count");
  4463. if (!num) {
  4464. num = document.createElement("span");
  4465. num.className = "attachment_count";
  4466. btn[0].appendChild(num);
  4467. }
  4468. num.innerText = count;
  4469. if (count == 0) {
  4470. $(num).hide();
  4471. } else {
  4472. $(num).show();
  4473. }
  4474. var datas = [];
  4475. for (var iii = 0; iii < names.length; iii++) {
  4476. datas.push({
  4477. name: iii,
  4478. value: names[iii],
  4479. });
  4480. }
  4481. btn.off("mouseenter").on("mouseenter", function () {
  4482. var menuelement = wd.display.initCmsMenu(fjid + "", 51);
  4483. if (menuelement) {
  4484. menuelement.showAt(btn[0]);
  4485. btn.off("mouseleave").on("mouseleave", function () {
  4486. menuelement.hide();
  4487. });
  4488. }
  4489. });
  4490. },
  4491. error: function (data) {
  4492. console.log(data);
  4493. },
  4494. });
  4495. }
  4496. };
  4497. wd.display.initCmsMenu = function (id) {
  4498. wd.topWindow.$("#CMSMENU").remove();
  4499. var nrid = (id = id.replace(/\D*/, ""));
  4500. //注册内容
  4501. $.ajax({
  4502. url: "/service",
  4503. data: {
  4504. nrid: "T-" + nrid,
  4505. ssServ: "regCms", // wdService: "register"。Lin
  4506. },
  4507. async: false,
  4508. dataType: "json",
  4509. success: function (data) {
  4510. console.log(data);
  4511. },
  4512. });
  4513. var data = wd.display.queryNrSubNr(nrid);
  4514. if (data.length == 0) {
  4515. return;
  4516. }
  4517. var mainElement = wd.display.initSelectOption("CMSMENU");
  4518. function loadPlayer(contentDiv) {
  4519. var win = contentDiv.ownerDocument.defaultView;
  4520. var se = contentDiv.srcElement,
  4521. $se = $(se),
  4522. subnrid = $se.attr("value"),
  4523. nrjslbm = $se.attr("nrjslbm");
  4524. win.$.ajax({
  4525. type: "GET",
  4526. url: "/service",
  4527. data: {
  4528. ssServ: "wrCmsPlay", // : wdService: "loadNrDesignAndPlayerData",。Lin
  4529. nrid: subnrid,
  4530. nrjslbm: nrjslbm,
  4531. },
  4532. async: false,
  4533. dataType: "json",
  4534. success: function (data) {
  4535. /// 增加,增加错误处理 -- 统一 Ajax 返回标准 -- .ssCode、.ssMsg、.ssData。Lin
  4536. if (data.ssCode != 0) {
  4537. alert(data.ssMsg);
  4538. return;
  4539. }
  4540. ///
  4541. var div = document.createElement("div");
  4542. var obj = {};
  4543. obj.design = data.design;
  4544. obj.resDesign = data.resDesign;
  4545. div.setAttribute("data-init", JSON.stringify(obj));
  4546. var tempData = data.data.replace(
  4547. new RegExp("@dataFolder@", "gm"),
  4548. data.dataFolderPath
  4549. );
  4550. var $ma = win.$(contentDiv);
  4551. var hasClose = $ma.find("#pageClose").length > 0;
  4552. div.innerHTML = tempData;
  4553. var $div = $(div);
  4554. // $div.hide();
  4555. $ma.html($div);
  4556. $ma.append(
  4557. '<div id="pageClose" class=" dhtmlx_skin_dhx_skyblue"><div class="dhtmlx_window_active"><div class="icon-restore" style="position: fixed;right: 13px;top: 10px;height:22px;width:22px;" onclick="wd.display.exitFullScreen()" ></div></div></div>'
  4558. );
  4559. // var $content = $(contentDiv);
  4560. // loadScorll($content);
  4561. // $content.getNiceScroll().resize();
  4562. div.addEventListener("DOMSubtreeModified", function () {
  4563. try {
  4564. win.wd.display.CmsZNRFull(contentDiv);
  4565. } catch (e) {}
  4566. // var $content = $(contentDiv);
  4567. // loadScorll($content);
  4568. // $content.getNiceScroll().resize();
  4569. // $content.css("height", $content.height());
  4570. // $content.css("height", "100%");
  4571. });
  4572. },
  4573. });
  4574. var $pe = $se.prev(".popupList"),
  4575. prev = $pe.attr("value"),
  4576. $ne = $se.next(".popupList"),
  4577. next = $ne.attr("value");
  4578. var ismousedown = false;
  4579. var oldY, scollY;
  4580. contentDiv.onmousedown = function (e) {
  4581. oldscrollTop = contentDiv.scrollTop;
  4582. oldY = e.screenY;
  4583. scollY = contentDiv.scrollTop;
  4584. ismousedown = true;
  4585. };
  4586. contentDiv.onmouseup = function (e) {
  4587. ismousedown = false;
  4588. };
  4589. contentDiv.onmousemove = function (e) {
  4590. e = e || window.event;
  4591. var newY = e.screenY;
  4592. if (ismousedown) {
  4593. //console.log(element.scrollTop + element.clientHeight+"###"+element.scrollHeight)
  4594. if (
  4595. oldY - newY >= 150 &&
  4596. contentDiv.scrollTop + contentDiv.clientHeight + 1 >=
  4597. contentDiv.scrollHeight &&
  4598. oldscrollTop + contentDiv.clientHeight + 1 >= contentDiv.scrollHeight
  4599. ) {
  4600. ismousedown = false;
  4601. // console.log("鼠标向上移动");
  4602. if ($ne.length > 0) {
  4603. contentDiv.srcElement = $ne[0];
  4604. loadPlayer(contentDiv);
  4605. }
  4606. // console.log(contentDiv.getAttribute("isCmsFullScreen"));
  4607. } else if (
  4608. newY - oldY >= 150 &&
  4609. contentDiv.scrollTop <= 0 &&
  4610. oldscrollTop == 0
  4611. ) {
  4612. ismousedown = false;
  4613. // console.log("鼠标向下移动");
  4614. if ($pe.length > 0) {
  4615. contentDiv.srcElement = $pe[0];
  4616. loadPlayer(contentDiv);
  4617. }
  4618. // console.log(contentDiv.getAttribute("isCmsFullScreen"));
  4619. } else {
  4620. contentDiv.scrollTop = scollY + (oldY - e.screenY); //此处调节滚动速度
  4621. }
  4622. }
  4623. };
  4624. // console.log("加载播放器完毕")
  4625. }
  4626. mainElement.style.minWidth = "180px";
  4627. wd.display.buildSelectOption(mainElement, data, "value", "name", "null");
  4628. var $mainElement = wd.topWindow.$(mainElement);
  4629. $.each(data, function () {
  4630. $mainElement
  4631. .find("[value='" + this.value + "']")
  4632. .attr("nrjslbm", this.nrjslbm);
  4633. });
  4634. $mainElement.find(".popupList").click(function () {
  4635. //绑定全屏
  4636. var doc = mainElement.ownerDocument;
  4637. var maindiv = doc.querySelector("#CMSPLAY" + id);
  4638. if (maindiv == null) {
  4639. //创建打的包装div
  4640. maindiv = doc.createElement("div");
  4641. maindiv.id = "CMSPLAY" + id;
  4642. maindiv.style.textAlign = "center";
  4643. maindiv.onselectstart = function () {
  4644. return false;
  4645. };
  4646. doc.body.appendChild(maindiv);
  4647. $(maindiv).append('<link rel="stylesheet" href="/ss/pdf/base.min.css">');
  4648. $(maindiv).append('<link rel="stylesheet" href="/ss/pdf/fancy.min.css">');
  4649. $(maindiv).append(
  4650. '<script type="text/javascript" src="/ss/pdf/compatibility.min.js"></script>'
  4651. );
  4652. $(maindiv).append(
  4653. '<script type="text/javascript" src="/ss/pdf/pdf2htmlEX.min.js"></script>'
  4654. );
  4655. var contentDiv = (maindiv.contentDiv = doc.createElement("div"));
  4656. contentDiv.className = "mainDiv";
  4657. contentDiv.style.width = "100%";
  4658. contentDiv.style.height = "100%";
  4659. contentDiv.style.display = "flex";
  4660. contentDiv.style.justifyContent = "center";
  4661. contentDiv.style.background = "white";
  4662. contentDiv.style.alignItems = "center";
  4663. maindiv.appendChild(contentDiv);
  4664. }
  4665. maindiv.contentDiv.srcElement = this;
  4666. // setTimeout(function () {
  4667. // console.log("开始全屏")
  4668. doc.defaultView.wd.display.CmsFullScreen(
  4669. maindiv.getElementsByTagName("DIV")[0],
  4670. function () {
  4671. loadPlayer(maindiv.contentDiv);
  4672. $(maindiv).children("#pageClose").remove();
  4673. },
  4674. function () {
  4675. maindiv.parentNode.removeChild(maindiv);
  4676. doc.defaultView.clearInterval(maindiv.contentDiv.intervalID);
  4677. }
  4678. );
  4679. // }, 500);
  4680. });
  4681. $mainElement.mouseenter(function () {
  4682. if (this.removeTimerId != null) {
  4683. this.ownerDocument.defaultView.clearTimeout(this.removeTimerId);
  4684. this.removeTimerId = null;
  4685. }
  4686. });
  4687. mainElement.hide = function () {
  4688. mainElement.removeTimerId =
  4689. mainElement.ownerDocument.defaultView.setTimeout(function () {
  4690. $mainElement.remove();
  4691. }, 300);
  4692. };
  4693. $mainElement.mouseleave(function () {
  4694. this.hide();
  4695. });
  4696. mainElement.showAt = function (element) {
  4697. $mainElement.show();
  4698. var bounding = element.getBoundingClientRect(),
  4699. mb = mainElement.getBoundingClientRect(),
  4700. xy = recursionIframe(window);
  4701. var left = bounding.right + xy.left - mb.width;
  4702. var top_ = bounding.top + xy.top - 10 - mb.height;
  4703. $mainElement.css({
  4704. left: left,
  4705. top: top_,
  4706. });
  4707. };
  4708. $mainElement.click(function (e) {
  4709. e.stopPropagation();
  4710. });
  4711. $("body").click(function () {
  4712. mainElement.hide();
  4713. });
  4714. $("body", wd.topWindow.document).click(function () {
  4715. mainElement.hide();
  4716. });
  4717. $mainElement.hide();
  4718. return mainElement;
  4719. };
  4720. //获取表单元素
  4721. //growHeight
  4722. //objectpicker
  4723. //onoffbutton
  4724. //ueditor
  4725. //input select datepicker
  4726. //编辑帮助,个人选值
  4727. wd.display.getInputsGroups = function () {
  4728. var arr = $("form,input,select,:radio,:checkbox").serializeArray();
  4729. var ret = {};
  4730. for (var i = 0; i < arr.length; i++) {
  4731. var name = arr[i].name;
  4732. if (!name) continue;
  4733. if (/objectPicker.*/.test(name)) continue;
  4734. var cc = wd.display.getInputBox(name);
  4735. if (!cc) continue;
  4736. ret[name] = cc;
  4737. }
  4738. return ret;
  4739. };
  4740. /**
  4741. *
  4742. * @param {Object} name
  4743. * @param {Object} any true:不过滤隐藏元素
  4744. */
  4745. wd.display.getInputBox = function (name, any) {
  4746. if (wd.display.filterInputBoxNames[name]) {
  4747. // console.log("filterInputBoxNames:"+name);
  4748. return null;
  4749. }
  4750. var result = {
  4751. name: name,
  4752. container: null, //定位元素
  4753. setChange: null,
  4754. focus: null, //光标
  4755. onKeyDown: null, //enter key event
  4756. onKeyDownContainer: null,
  4757. modify: null,
  4758. modifyContainer: null,
  4759. };
  4760. result.getValue = function () {
  4761. return $(this.container).val();
  4762. };
  4763. result.setValue = function (v) {
  4764. $(this.container).val(v);
  4765. };
  4766. result.setChange = function (changefunc) {
  4767. $(this.container).on("change", changefunc);
  4768. };
  4769. result.focus = function () {
  4770. $(this.container).focus();
  4771. };
  4772. result.modify = function (canmodify) {
  4773. if (canmodify) {
  4774. $(this.modifyContainer || this.container).removeAttr("readonly");
  4775. } else {
  4776. $(this.modifyContainer || this.container).attr("readonly", "readonly");
  4777. }
  4778. };
  4779. //键盘录入监听,keycode 9:tab 13:enter
  4780. result.onKeyDown = function (keycode, func) {
  4781. var code = [];
  4782. code = keycode;
  4783. $(this.onKeyDownContainer || this.container).on("keydown", function () {
  4784. if (code.indexOf(window.event.keyCode) != -1) {
  4785. return func();
  4786. }
  4787. });
  4788. };
  4789. try {
  4790. if (window.growHeightList && window.growHeightList[name]) {
  4791. result.type = "growHeight";
  4792. result.instance = growHeightList[name];
  4793. result.container = growHeightList[name].container.parentNode;
  4794. result.getValue = function () {
  4795. return this.instance.val();
  4796. };
  4797. result.setValue = function (v) {
  4798. this.instance.val(v);
  4799. };
  4800. result.focus = function () {
  4801. this.instance.onFocus();
  4802. };
  4803. result.onKeyDownContainer = $(
  4804. growHeightList[name].getInputElement().parentNode
  4805. ).find("textarea");
  4806. result.modifyContainer = growHeightList[name].getInputElement();
  4807. } else if (
  4808. wd &&
  4809. wd.edit &&
  4810. wd.edit.objectPicker &&
  4811. wd.edit.objectPicker.getInstance(name)
  4812. ) {
  4813. result.type = "objectPicker";
  4814. result.instance = wd.edit.objectPicker.getInstance(name);
  4815. result.container = result.instance.getDisplayElement();
  4816. result.getValue = function () {
  4817. return this.instance.getValue();
  4818. };
  4819. result.setValue = function (v) {
  4820. this.instance.initValue(v);
  4821. };
  4822. result.setChange = function (func) {
  4823. this.instance.onchange = func;
  4824. };
  4825. result.modify = function (canmodify) {
  4826. this.instance.modify(canmodify);
  4827. };
  4828. } else if (
  4829. window.EditorManager &&
  4830. EditorManager.instances &&
  4831. EditorManager.instances[name]
  4832. ) {
  4833. result.type = "ueditor";
  4834. result.container = EditorManager.instances[name].getUeditor().container;
  4835. result.instance = EditorManager.instances[name].getUeditor();
  4836. result.getValue = function () {
  4837. var c = this.instance.getContent();
  4838. return c ? wd.display.toPlainText() : c;
  4839. };
  4840. result.setValue = function (v) {
  4841. return this.instance.setContent(v);
  4842. };
  4843. } else if ($("#" + name + "_onoffbutton_list").length == 1) {
  4844. result.type = "onoffbutton";
  4845. result.container = $("[name=" + name + "][type=button]").last()[0];
  4846. result.getValue = function () {
  4847. return $("[name='" + name + "'][type=hidden]").val();
  4848. };
  4849. result.setValue = function (v) {
  4850. /* 改,是小写的 wdvalue=,也改先 -- 规范命名。Lin
  4851. $("[name='"+name+"'][type=button][wdvalue="+v+"]").click();
  4852. */ $("[name='" + name + "'][type=button][ssVal=" + v + "]").click();
  4853. };
  4854. } else if (window.enrolDateList && window.enrolDateList[name]) {
  4855. result.type = "enrolDate";
  4856. result.instance = window.enrolDateList[name];
  4857. result.container = window.enrolDateList[name].container;
  4858. result.getValue = function () {
  4859. return this.instance.getValue();
  4860. };
  4861. result.setValue = function (v) {
  4862. this.instance.setValue(v);
  4863. };
  4864. result.setChange = function (func) {
  4865. this.instance.onchange = func;
  4866. };
  4867. } else if (window.editPhotoList && window.editPhotoList[name]) {
  4868. result.type = "editPhoto";
  4869. result.instance = window.editPhotoList[name];
  4870. result.container = window.editPhotoList[name].container;
  4871. result.getValue = function () {
  4872. return this.instance.getValue();
  4873. };
  4874. result.setValue = function (v) {
  4875. this.instance.setValue(v);
  4876. };
  4877. result.modify = function (canmodify) {
  4878. this.instance.modify(canmodify);
  4879. };
  4880. } else if (document.querySelector("[name='" + name + "']")) {
  4881. result.type = "input";
  4882. result.container = document.querySelector("[name='" + name + "']");
  4883. } else {
  4884. return null;
  4885. }
  4886. if (any) {
  4887. } else {
  4888. if ($(result.container).width() == 0) return null;
  4889. }
  4890. } catch (e) {
  4891. console.log(e);
  4892. }
  4893. return result;
  4894. };
  4895. if (!wd.display.filterInputBoxNames) {
  4896. wd.display.filterInputBoxNames = {};
  4897. }
  4898. /**
  4899. * 过滤inputbox
  4900. */
  4901. wd.display.filterInputBox = function (name) {
  4902. for (var i = 0; i < arguments.length; i++) {
  4903. var m = arguments[i];
  4904. wd.display.filterInputBoxNames[m] = "1";
  4905. }
  4906. // console.log(wd.display.filterInputBoxNames);
  4907. };
  4908. wd.display.changeFirstTitle = function (t) {
  4909. var displgid = wd.display.getwdDialogId();
  4910. if (!displgid) return;
  4911. wd.topWindow.dhxWins
  4912. .window(displgid)
  4913. .querySelector(".dialog-title").innerHTML = t;
  4914. };
  4915. wd.display.changeSecondTitle = function (t) {
  4916. var displgid = wd.display.getwdDialogId();
  4917. if (!displgid) return;
  4918. wd.topWindow.dhxWins
  4919. .window(displgid)
  4920. .querySelector(".secondTitle").innerHTML = t;
  4921. };
  4922. /**
  4923. * 判断当前url是否个人首页
  4924. * @param {Object} win
  4925. */
  4926. wd.display.isPersonalHomePageUrl = function (url) {
  4927. if (!url) return false;
  4928. return url.indexOf("initDesktop") == -1 ? false : true;
  4929. };
  4930. /**
  4931. * 生成更多按钮
  4932. * @param {Object} buttonId
  4933. * @param {Object} childrenClass
  4934. * selectedDiv 选中菜单,显示按钮名称
  4935. * recordvalue 启用个人选值
  4936. */
  4937. wd.display.attachButton = function (
  4938. buttonId,
  4939. childrenClass,
  4940. selectedDiv,
  4941. buttonNotClickAschild,
  4942. recordvalue
  4943. ) {
  4944. var $button = $("#" + buttonId);
  4945. var vanishId;
  4946. //获取二级数据
  4947. function findDatalist() {
  4948. var datalist = [];
  4949. var d = document.querySelectorAll("." + childrenClass);
  4950. //adminNo
  4951. for (var i = 0; i < d.length; i++) {
  4952. datalist.push({
  4953. name: d[i].getAttribute("value"),
  4954. value: d[i].getAttribute("value"),
  4955. ele: d[i],
  4956. });
  4957. }
  4958. return datalist;
  4959. }
  4960. function showChild(v, isinit) {
  4961. var datalist = findDatalist();
  4962. var thisdata;
  4963. for (var i = 0; i < datalist.length; i++) {
  4964. if (datalist[i].value == v) {
  4965. thisdata = datalist[i];
  4966. }
  4967. }
  4968. //记忆,点击按钮触发上一个点击过的选项
  4969. $button.off("click");
  4970. if (true === buttonNotClickAschild) {
  4971. $button.on("click", function () {
  4972. vanishId = setTimeout(function () {
  4973. $("#" + buttonId + "_buttons").hide();
  4974. }, 500);
  4975. });
  4976. } else {
  4977. $("#" + buttonId + "_buttons").hide();
  4978. var html = thisdata ? thisdata.name : "";
  4979. if (true === isinit) {
  4980. html = $button.val() + html;
  4981. }
  4982. if (selectedDiv) {
  4983. $button.find(selectedDiv).html(html);
  4984. } else if ($button.is("input")) {
  4985. $button.val(html);
  4986. }
  4987. $button.on("click", function () {
  4988. $(thisdata.ele).trigger("click");
  4989. });
  4990. }
  4991. return thisdata;
  4992. }
  4993. $button
  4994. .on("mouseenter click", function () {
  4995. //获取下拉数据
  4996. var datalist = findDatalist();
  4997. //create div
  4998. $("#" + buttonId + "_buttons").remove();
  4999. var dom = wd.display.initSelectOption(buttonId + "_buttons");
  5000. if (datalist.length > 0) {
  5001. /* 再改,不知为何要反转 细分部件(原 plugin) 顺序???Lin
  5002. wd.display.buildSelectOption(dom, datalist.reverse(), "value", "name", null, false);
  5003. */ wd.display.buildSelectOption(dom, datalist, "value", "name", null, false);
  5004. $("body").append(dom);
  5005. }
  5006. //position
  5007. var dombounding = dom.getBoundingClientRect();
  5008. var bounding = (
  5009. this.querySelector("img") || this
  5010. ).getBoundingClientRect();
  5011. //console.log(bounding);
  5012. var left = bounding.left;
  5013. //防止超出屏幕出现滚动条
  5014. if (left + dombounding.width > window.innerWidth) {
  5015. left = window.innerWidth - dombounding.width;
  5016. }
  5017. dom.style.left = Math.max(left, 0) + "px";
  5018. if (
  5019. bounding.top + bounding.height + dombounding.height >
  5020. window.innerHeight
  5021. ) {
  5022. dom.style.top = bounding.top - dombounding.height + "px";
  5023. //console.log("up side")
  5024. } else {
  5025. //console.log("down side")
  5026. dom.style.top = bounding.top + bounding.height + "px";
  5027. }
  5028. //bind event
  5029. $(dom)
  5030. .on("click", ".popupList", function () {
  5031. if (window.event) {
  5032. if (window.event.stopPropagation) {
  5033. window.event.stopPropagation();
  5034. } else {
  5035. window.event.cancelBubble = true;
  5036. }
  5037. }
  5038. var v = this.getAttribute("value");
  5039. var thisdata = showChild(v);
  5040. $(thisdata.ele).trigger("click");
  5041. // console.log(thisdata);
  5042. if (recordvalue) {
  5043. var recordzhi = {};
  5044. recordzhi[buttonId] = {
  5045. value: v,
  5046. default: true,
  5047. };
  5048. wd.edit.insertRecord(recordzhi);
  5049. }
  5050. })
  5051. .on("mouseleave", function () {
  5052. $(this).hide();
  5053. })
  5054. .on("mouseenter", function () {
  5055. if (vanishId) clearTimeout(vanishId);
  5056. });
  5057. })
  5058. .on("mouseleave", function () {
  5059. if ($(window.event.relatedTarget).is($(this).parents())) {
  5060. vanishId = setTimeout(function () {
  5061. $("#" + buttonId + "_buttons").hide();
  5062. }, 500);
  5063. }
  5064. });
  5065. if (recordvalue) {
  5066. $(function () {
  5067. var record = wd.edit.getRecord();
  5068. // console.log(record);
  5069. if (record && record[buttonId]) {
  5070. var v = record[buttonId].value;
  5071. showChild(v, true);
  5072. }
  5073. });
  5074. }
  5075. };
  5076. wd.display.inputCaptcha = function (name, captchalength) {
  5077. try {
  5078. var inputbox = wd.display.getInputBox(name);
  5079. if (!inputbox) return;
  5080. var inputClass = name + "_inputCaptcha";
  5081. var va = $(
  5082. '<div style="position:absolute; left: 5px;top: 5px;width: 100%;height: 100%;z-index: 1;display: flex;">' +
  5083. '<div class="hLine" style="display: flex; height: 30px;">' +
  5084. '<input class="' +
  5085. inputClass +
  5086. '" style="width:140px;border: none;padding-left: 7px;" placeholder=\'请输入验证码\'/>' +
  5087. '<img align="middle" vspace="2" id="codeimg" title="看不清楚可单击刷新" class="header_yzmimg" src="/wd/verificationCode.do?' +
  5088. new Date().getTime() +
  5089. '">' +
  5090. // +"<input type=\"button\" value=\"确定\" class=\"content-button\" onclick=\"void(0);\" style=\"margin-left: 10px;\"/>"
  5091. "</div>" +
  5092. "</div>"
  5093. );
  5094. // va.css({position:"absolute",left:0,top:0,width:"100%",height:"100%",background:"azure",zIndex:1})
  5095. $(inputbox.container).before(va);
  5096. va.on("click", "img", function () {
  5097. this.setAttribute(
  5098. "src",
  5099. "/wd/verificationCode.do?" + new Date().getTime()
  5100. );
  5101. }).on("blur", "." + inputClass, function () {
  5102. /* 再改,规范命名。Lin
  5103. * 去掉 ?wdApplication=,不支持多个应用 -- 服务名可以写 ss.xxx
  5104. * &wdService= 改为 ssServ
  5105. $.post("/service?wdApplication=wd&wdService=checkCaptcha_ajax&wdtest=false", {
  5106. */ $.post(
  5107. "/service?ssServ=checkCaptcha_ajax",
  5108. {
  5109. yzm: this.value,
  5110. },
  5111. function (result) {
  5112. if ("1" == result.result) {
  5113. va.hide();
  5114. $(inputbox.container).show();
  5115. if (typeof window.inputCaptchaCallback == "function")
  5116. window.inputCaptchaCallback();
  5117. } else {
  5118. wd.display.alert("验证码错误!");
  5119. }
  5120. },
  5121. "json"
  5122. );
  5123. });
  5124. $(inputbox.container).hide();
  5125. } catch (e) {
  5126. console.log(e);
  5127. }
  5128. };
  5129. wd.display.previewPicture = function (url, errorPhoto) {
  5130. if ($(window.event.srcElement).is("input,button")) return;
  5131. $(".previewPicture").remove();
  5132. // var onerror = errorPhoto ? ('this.src=\'' + errorPhoto + '\'') : "";
  5133. var onerror = "";
  5134. // if(true)return;
  5135. // $("<div class='previewPicture ' style=\"display:none;z-index: 999999;position: absolute;left: 50%;top: 50%;transform: translate(-50%,-50%);border: 1px solid #6c9ddb;\">"
  5136. // + "<img src=" + url + " onerror=\"" + onerror + "\" style=\"max-width:100%;max-height: 100%;\" onload=\"$('.previewPicture').show()\"/>"
  5137. // +"<span class='close' style=\"width: 30px;height:30px;position: absolute;top: 0px;right: 0px;font-size: 20px;background-color: #e2e2e2;text-align: center;line-height: 30px;\">X</span>"
  5138. // +"<span class='download' style=\"width: 30px;height:30px;position: absolute;top: 0px;right: -30px;font-size: 20px;background-color: #e2e2e2;text-align: center;line-height: 30px;\">download</span>"
  5139. // + "</div>")
  5140. // .appendTo("body")
  5141. // .on('click',".close", function () {
  5142. // $('.previewPicture').remove();
  5143. // });
  5144. var startLeft, startTop, startX, startY;
  5145. $(
  5146. "<div class='previewPicture lightDialog-div' style=\"display:none;z-index: 9999;position: absolute;left: 50%;top: 50%;transform: translate(-50%,-50%);border: 1px solid #6c9ddb;\">" +
  5147. '<div class="lightDialog-title hLine">' +
  5148. '<div title="下载" class="download icon-download" style="position: absolute;right: 35px;top: 9px;"></div>' +
  5149. '<div title="关闭" class="close icon-close"></div>' +
  5150. "</div>" +
  5151. "<img src=" +
  5152. url +
  5153. ' onerror="' +
  5154. onerror +
  5155. '" style="max-width:100%;max-height: 100%;" onload="$(\'.previewPicture\').show()"/>' +
  5156. "</div>"
  5157. )
  5158. .appendTo("body")
  5159. .on("click", ".close", function () {
  5160. $(".previewPicture").remove();
  5161. })
  5162. .on("click", ".download", function () {
  5163. wd.display.downloadFile(url + "&download=1");
  5164. // $('.previewPicture').remove();
  5165. });
  5166. // on("mousedown",function(){
  5167. // startLeft=parseInt( $(this).css("marginLeft"));
  5168. // startTop=parseInt( $(this).css("marginTop"));
  5169. // startX=window.event.clientX;
  5170. // startY=window.event.clientY;
  5171. // this.setAttribute("move","1");
  5172. // }).on("mouseup mouseout",function(){
  5173. // this.setAttribute("move","0");
  5174. // }).on("mousemove",function(){
  5175. // if("1"!=this.getAttribute("move"))return;
  5176. // $(this).css({
  5177. // marginLeft:startLeft+window.event.clientX-startX,
  5178. // marginTop:startTop+window.event.clientY-startY
  5179. // })
  5180. // })
  5181. };
  5182. wd.display.beaconLogin = function (type) {
  5183. type = type || "login";
  5184. try {
  5185. if (typeof beacon == "undefined") return false;
  5186. if (type == "login") {
  5187. beacon.login(wd.topWindow.beaconLoginTicket);
  5188. } else {
  5189. beacon.loginOut();
  5190. }
  5191. return true;
  5192. } catch (error) {
  5193. console.log("------------------------------------");
  5194. console.log(error);
  5195. console.log("------------------------------------");
  5196. }
  5197. return false;
  5198. };
  5199. wd.display.getBeaconWhetherToOpen = function () {
  5200. try {
  5201. if (typeof beacon == "undefined") return false;
  5202. if (beacon.getBeaconWhetherToOpen() == "True") {
  5203. alert("“待办列表”已在烽火台打开");
  5204. beacon.close2();
  5205. }
  5206. return true;
  5207. } catch (error) {
  5208. console.error(error);
  5209. }
  5210. return false;
  5211. };
  5212. wd.display.refreshToDoList = function () {
  5213. wd.display.refreshHomeplugin("6011");
  5214. };
  5215. wd.display.refreshHomeplugin = function (type) {
  5216. if (!wd.topWindow.wd.base.applyIframeElement.contentWindow.SYBJCTRL)
  5217. return "0";
  5218. return wd.topWindow.wd.base.applyIframeElement.contentWindow.SYBJCTRL.refreshHomeplugin(
  5219. type
  5220. );
  5221. };
  5222. wd.display.setCloseWindowParam = function (p) {
  5223. if (!p) return;
  5224. var wdDialogId = wd.display.getwdDialogId();
  5225. if (!wdDialogId) return;
  5226. var win = wd.topWindow.dhxWins.window(wdDialogId);
  5227. win.closeWindowParam = p;
  5228. return win;
  5229. };
  5230. wd.display.onCloseDialog = function (win, popWindow) {
  5231. try {
  5232. // console.log("wd.display.onCloseDialog");
  5233. // console.log(win.closeWindowParam);
  5234. if (!win.closeWindowParam) return;
  5235. var openerWindow = popWindow.wd.display.getwdDialogOpener();
  5236. var name = openerWindow.wd.edit.objectPicker.addButtonClickName;
  5237. if (!name) return;
  5238. var objectpickerobj = openerWindow.wd.edit.objectPicker.getInstance(name);
  5239. if (!objectpickerobj) return;
  5240. // var data={option:[{name:"abc",id:"999"}]};
  5241. var data = eval("(" + win.closeWindowParam + ")");
  5242. objectpickerobj.setwdCloseWindowParamData(data);
  5243. // console.log(objectpickerobj);
  5244. } catch (err) {
  5245. console.error(err);
  5246. }
  5247. };
  5248. /**
  5249. * 调用关闭窗口时调用的回调方法
  5250. */
  5251. wd.display.closeDialogCallbackFun = null;
  5252. /**
  5253. * 给一个按钮绑定事件
  5254. * @param {Object} buttonname
  5255. * @param {Object} bindevent
  5256. * @param {Object} bindfunction
  5257. */
  5258. wd.display.bindWdButton = function (buttonname, bindevent, bindfunction) {
  5259. var wdDialogId = wd.display.getwdDialogId();
  5260. if (!wdDialogId) return;
  5261. var win = wd.topWindow.dhxWins.window(wdDialogId);
  5262. var b = win.button(buttonname);
  5263. $(b).on(bindevent, bindfunction);
  5264. };
  5265. /**
  5266. * px 2 rem
  5267. */
  5268. wd.display.px2Rem = function (px) {
  5269. var unit = parseFloat($("html").css("font-size"));
  5270. return px / unit;
  5271. };
  5272. /**
  5273. *
  5274. * rem 2 px
  5275. */
  5276. wd.display.rem2Px = function (rem) {
  5277. var unit = parseFloat($("html").css("font-size"));
  5278. return rem * unit;
  5279. };
  5280. /*
  5281. *
  5282. 调用示例
  5283. 1:
  5284. wd.flashMsg.show({
  5285. el: $("#domDiv"), // 吸附的元素
  5286. msg: "hi,hello", // 内容
  5287. time: 200000, // 显示的时间,默认 3000,单位毫秒,
  5288. offset: 'd', // 气泡方向,[u]: 上, [d]: 下,当所定的方向无法完全显示内容时,将自动进行调整方向
  5289. arrowsOffset: 'r', // 箭头方位,[l]:左边,[c]:居中,[r]:右,默认为[c]居中
  5290. zindex: 100, // 层级,默认 1996,
  5291. animate: true, // 为真则开启动画,默认开启
  5292. end: function() {
  5293. console.log("销毁后的回调");
  5294. }
  5295. });
  5296. 2:
  5297. wd.flashMsg.show("内容");
  5298. */
  5299. wd.flashMsg = {
  5300. vars: {
  5301. ARROWS_UP_CLASS_NAME: "flashMsg-up",
  5302. ARROWS_DOWN_CLASS_NAME: "flashMsg-down",
  5303. },
  5304. timeout: undefined,
  5305. flashDivTemplate: `<div class="flashMsg-div {flashMsgClassName}" id="flashmsgtipsId" style="left: 0px; top: 0px; display: none;{position}">
  5306. <p>{msg}</p>
  5307. <div class="{arrorwsClassName}" style="{arrorwsStyle}"></div>
  5308. </div>`,
  5309. show: function (param) {
  5310. var setting;
  5311. if (typeof param == "object") {
  5312. setting = param;
  5313. } else {
  5314. setting = {
  5315. el: window.event.srcElement,
  5316. msg: param,
  5317. };
  5318. }
  5319. if (!this.validation(setting)) {
  5320. return;
  5321. }
  5322. // 获取吸附元素的坐标和宽高
  5323. // var positionObj = this.getAbsolute(document, $(setting.el)[0]);
  5324. var positionObj = $(setting.el).position();
  5325. var offsetObj = $(setting.el).offset();
  5326. var elTop = offsetObj.top;
  5327. var elLeft = offsetObj.left;
  5328. var elWidth = $(setting.el).innerWidth();
  5329. var elHeight = $(setting.el).innerHeight();
  5330. setting.time = isNaN(setting.time) ? 3000 : setting.time; // 显示时间,默认3秒
  5331. setting.animate = setting.animate == undefined ? true : setting.animate; // 动画,默认为真
  5332. setting.zindex = this.isNull(setting.zindex) ? 1996 : setting.zindex; // 气泡的层级样式,默认层级 999
  5333. setting.offset = this.isNull(setting.offset) ? "d" : setting.offset; // 气泡的定位样式,默认在下面
  5334. setting.arrowsOffset = this.isNull(setting.arrowsOffset)
  5335. ? "l"
  5336. : setting.arrowsOffset; // 箭头的定位样式,默认左边
  5337. var arrorwsStyle = ""; // 箭头样式
  5338. var flashMsgClassName = setting.animate ? "wd-anim wd-anim-upbit" : ""; // 动画
  5339. var arrorwsClassName = undefined; // 箭头的类名
  5340. // 气泡在上
  5341. if (setting.offset && setting.offset == "u") {
  5342. arrorwsStyle += "bottom: -10px;left: 7px";
  5343. arrorwsClassName = this.vars.ARROWS_DOWN_CLASS_NAME;
  5344. }
  5345. // 气泡在下
  5346. else if (setting.offset && setting.offset == "d") {
  5347. arrorwsStyle += "bottom: -10px;left: 7px";
  5348. arrorwsClassName = this.vars.ARROWS_UP_CLASS_NAME;
  5349. }
  5350. // 默认气泡在上
  5351. else {
  5352. arrorwsStyle += "bottom: -10px;left: 7px";
  5353. arrorwsClassName = this.vars.ARROWS_DOWN_CLASS_NAME;
  5354. }
  5355. this.clearFlashMsg();
  5356. $("body").append(
  5357. this.getFlashDivTemplate(
  5358. setting,
  5359. elTop,
  5360. elLeft,
  5361. arrorwsClassName,
  5362. arrorwsStyle,
  5363. flashMsgClassName
  5364. )
  5365. );
  5366. ////////////////////////////// 计算最终的坐标 //////////////////////////////
  5367. var lastTop = -1;
  5368. var flashDom = $("#flashmsgtipsId");
  5369. var flashDomWidth = $(flashDom).innerWidth();
  5370. var flashDomHeight = $(flashDom).innerHeight(); // 是箭头的高度
  5371. $(flashDom).css({
  5372. top: elTop + "px",
  5373. left: elLeft + "px",
  5374. });
  5375. // 气泡在上
  5376. if (arrorwsClassName == this.vars.ARROWS_DOWN_CLASS_NAME) {
  5377. var lastDomTop = elTop - flashDomHeight - 16;
  5378. lastTop = elTop - flashDomHeight - 16;
  5379. // flashMsg 元素超出了窗口顶部范围
  5380. if (lastDomTop < 0) {
  5381. // 未尝试过向上的方向
  5382. if (!setting.upFlag) {
  5383. setting.offset = "d";
  5384. setting.downFlag = true;
  5385. this.show(setting);
  5386. return;
  5387. }
  5388. lastTop = flashDomHeight + 6;
  5389. }
  5390. }
  5391. // 气泡在下
  5392. else if (arrorwsClassName == this.vars.ARROWS_UP_CLASS_NAME) {
  5393. lastTop = elTop + elHeight + 20;
  5394. var lastDomTop = elTop + elHeight + flashDomHeight + 20;
  5395. // flashMsg 元素超出了窗口底部范围
  5396. if (lastDomTop > window.innerHeight) {
  5397. // 未尝试过向下的方向
  5398. if (!setting.downFlag) {
  5399. setting.offset = "u";
  5400. setting.upFlag = true;
  5401. this.show(setting);
  5402. return;
  5403. }
  5404. lastTop = window.innerHeight - flashDomHeight - 12;
  5405. }
  5406. } else {
  5407. console.error("arrorwsClassName [" + arrorwsClassName + "] error!");
  5408. return;
  5409. }
  5410. this.settingFlashMsgArrorwsLeft(
  5411. setting,
  5412. arrorwsClassName,
  5413. elWidth,
  5414. elLeft,
  5415. flashDom,
  5416. flashDomWidth
  5417. );
  5418. $(flashDom).css("top", lastTop + "px");
  5419. $(flashDom).show();
  5420. if (setting.time != 0) {
  5421. this.timeout = setTimeout(function () {
  5422. wd.flashMsg.clearFlashMsg(setting);
  5423. }, setting.time);
  5424. }
  5425. },
  5426. /**
  5427. * 清除气泡
  5428. */
  5429. clear: function () {
  5430. this.clearFlashMsg();
  5431. },
  5432. settingFlashMsgArrorwsLeft: function (
  5433. setting,
  5434. arrorwsClassName,
  5435. elWidth,
  5436. elLeft,
  5437. flashDom,
  5438. flashDomWidth
  5439. ) {
  5440. var arrorwsDom = $(flashDom).find("div." + arrorwsClassName);
  5441. // 箭头往左
  5442. if (setting.arrowsOffset == "l") {
  5443. var arrowLeft = 7;
  5444. $(arrorwsDom).css("left", arrowLeft + "px");
  5445. return;
  5446. }
  5447. // 箭头往右
  5448. else if (setting.arrowsOffset == "r") {
  5449. var arrowLeft = flashDomWidth - 20;
  5450. // 箭头的位置超出了元素的宽度
  5451. var elEndLeft = elLeft + elWidth;
  5452. if (arrowLeft > elEndLeft) {
  5453. // 元素的一半宽度大于12像素的时候,看着就不会太别扭,放心置 left 为 6px
  5454. if (elWidth / 2 >= 12) {
  5455. arrowLeft = elEndLeft - 6 - 7;
  5456. }
  5457. // 取半
  5458. else {
  5459. arrowLeft = elLeft + elWidth / 2;
  5460. }
  5461. }
  5462. $(arrorwsDom).css("left", arrowLeft + "px");
  5463. }
  5464. // 箭头居中
  5465. else {
  5466. /////////////////////// 重新定位气泡 ///////////////////////
  5467. var flashMsgDomLeft = this.settingFlashMsgLeft(
  5468. flashDom,
  5469. flashDomWidth,
  5470. elWidth,
  5471. elLeft
  5472. );
  5473. var arrowLeft = elLeft - flashMsgDomLeft + elWidth / 2;
  5474. $(arrorwsDom).css("left", arrowLeft + "px");
  5475. }
  5476. },
  5477. settingFlashMsgLeft: function (flashDom, flashDomWidth, elWidth, elLeft) {
  5478. var flashMsgDomLeft = elLeft - (flashDomWidth - elWidth) / 2;
  5479. // 超出了屏幕左边,向右移动
  5480. if (flashMsgDomLeft < 0) {
  5481. flashMsgDomLeft = 6;
  5482. }
  5483. // 超出屏幕右边,向左移动
  5484. else if (flashMsgDomLeft + flashDomWidth > window.innerWidth) {
  5485. flashMsgDomLeft -= flashMsgDomLeft + flashDomWidth - window.innerWidth;
  5486. }
  5487. $(flashDom).css("left", flashMsgDomLeft);
  5488. return flashMsgDomLeft;
  5489. },
  5490. clearFlashMsg: function (setting) {
  5491. window.clearTimeout(wd.flashMsg.timeout);
  5492. wd.flashMsg.timeout = undefined;
  5493. $("#flashmsgtipsId").remove(); // 移除掉之前的
  5494. if (setting && setting.end) {
  5495. setting.end();
  5496. }
  5497. },
  5498. getFlashDivTemplate: function (
  5499. setting,
  5500. elTop,
  5501. elLeft,
  5502. arrorwsClassName,
  5503. arrowsStyle,
  5504. flashMsgClassName
  5505. ) {
  5506. var html = this.flashDivTemplate.replace(
  5507. "{position}",
  5508. "zindex:" + setting.zindex + ";"
  5509. );
  5510. html = html.replace("{arrorwsClassName}", arrorwsClassName);
  5511. html = html.replace("{arrorwsStyle}", arrowsStyle);
  5512. html = html.replace("{msg}", setting.msg);
  5513. html = html.replace("{flashMsgClassName}", flashMsgClassName);
  5514. return html;
  5515. },
  5516. isNull: function (obj) {
  5517. switch (typeof obj) {
  5518. case "undefined":
  5519. return true;
  5520. case "string":
  5521. if (obj.replace(/(^[ \t\n\r]*)|([ \t\n\r]*$)/g, "").length == 0)
  5522. return true;
  5523. break;
  5524. case "boolean":
  5525. if (!obj) return true;
  5526. break;
  5527. case "number":
  5528. if (0 === obj || isNaN(obj)) return true;
  5529. break;
  5530. case "object":
  5531. if (null === obj || obj.length === 0) return true;
  5532. for (var i in obj) {
  5533. return false;
  5534. }
  5535. return true;
  5536. }
  5537. return false;
  5538. },
  5539. notNull: function (obj) {
  5540. return !this.isNull(obj);
  5541. },
  5542. validation: function (setting) {
  5543. if (this.isNull(setting)) {
  5544. console.error("flashMsg 未获取到 setting!");
  5545. return false;
  5546. }
  5547. if (this.isNull(setting.el)) {
  5548. console.error("flashMsg Setting [el] 属性不能为空 ");
  5549. return false;
  5550. }
  5551. if (this.isNull(setting.msg)) {
  5552. console.error("flashMsg Setting [msg] 属性不能为空 ");
  5553. return false;
  5554. }
  5555. return true;
  5556. },
  5557. getAbsolute: function (reference, target) {
  5558. var result = {
  5559. left: -target.clientLeft,
  5560. top: -target.clientTop,
  5561. };
  5562. var node = target;
  5563. while (node != reference && node != document) {
  5564. result.left = result.left + node.offsetLeft + node.clientLeft;
  5565. result.top = result.top + node.offsetTop + node.clientTop;
  5566. node = node.parentNode;
  5567. }
  5568. if (isNaN(reference.scrollLeft)) {
  5569. result.right = document.documentElement.scrollWidth - result.left;
  5570. result.bottom = document.documentElement.scrollHeight - result.top;
  5571. } else {
  5572. result.right = reference.scrollWidth - result.left;
  5573. result.bottom = reference.scrollHeight - result.top;
  5574. }
  5575. return result;
  5576. },
  5577. };
  5578. //隐藏的元素
  5579. wd.display._lockScreenElement = null;
  5580. //有值表示正在执行lockScreen,unlockScreen
  5581. wd.display._lockScreenWaitting = null;
  5582. /**
  5583. * 锁屏
  5584. */
  5585. wd.display.lockScreen = function () {
  5586. "use strict";
  5587. if (wd.display._lockScreenWaitting) return;
  5588. wd.display._lockScreenWaitting = 0;
  5589. $.post(
  5590. "/service?ssServ=lockScreen",
  5591. {},
  5592. function (result) {
  5593. if (wd.display._lockScreenElement) return;
  5594. wd.display._lockScreenElement = $("body > * :visible");
  5595. wd.display._lockScreenElement.hide();
  5596. $("body").append(
  5597. '<div class="lockscreenMask" style="position: absolute;left: 0px;top: 0px;width: 100%;height: 100%;background-color: black;z-index: 99;"></div>'
  5598. );
  5599. },
  5600. "json"
  5601. );
  5602. wd.display._lockScreenWaitting = null;
  5603. };
  5604. /**
  5605. * 解锁屏
  5606. */
  5607. wd.display.unlockScreen = function () {
  5608. "use strict";
  5609. if (wd.display._lockScreenWaitting) return;
  5610. wd.display._lockScreenWaitting = 1;
  5611. $.post(
  5612. "/service?ssServ=unlockScreen",
  5613. {},
  5614. function (result) {
  5615. if (!wd.display._lockScreenElement) return;
  5616. wd.display._lockScreenElement.show();
  5617. wd.display._lockScreenElement = null;
  5618. $(".lockscreenMask").remove();
  5619. },
  5620. "json"
  5621. );
  5622. wd.display._lockScreenWaitting = null;
  5623. };
  5624. window.enrolDateList = window.enrolDateList || {};
  5625. wd.display.initEnrolDate = function (nameee, mode) {
  5626. var hiddenEle = document.querySelector("[name=" + nameee + "][type=hidden]");
  5627. if ("play" == mode) {
  5628. if (!hiddenEle.value) return;
  5629. var year = parseInt(hiddenEle.value.split("-")[0]);
  5630. var month = parseInt(hiddenEle.value.split("-")[1]);
  5631. $(hiddenEle).before(
  5632. "<span>" + year + "年(" + (month <= 6 ? "春季" : "秋季") + ")</span>"
  5633. );
  5634. return;
  5635. }
  5636. function editEnrolDate(name) {
  5637. var THIS = this;
  5638. this.onchange = null;
  5639. this.getValue = null;
  5640. this.setValue = null;
  5641. this.container = null;
  5642. var hiddenEle = document.querySelector("[name=" + name + "][type=hidden]");
  5643. this.element = hiddenEle;
  5644. var yyy = document.querySelector("[name=" + name + "_year]");
  5645. var mmm = document.querySelector("[name=" + name + "_month]");
  5646. wd.display.filterInputBox(name + "_year", name + "_month");
  5647. var placeholder = hiddenEle.getAttribute("placeholder");
  5648. if (placeholder) {
  5649. yyy.setAttribute("placeholder", placeholder);
  5650. } else {
  5651. //样式特殊处理
  5652. yyy.style.width = "30px";
  5653. }
  5654. this.container = yyy.parentNode;
  5655. this.container.style.display = "inline";
  5656. var width = hiddenEle.getAttribute("width");
  5657. if (width) yyy.style.width = width;
  5658. this._initYear = function (y) {
  5659. yyy.value = y;
  5660. };
  5661. this._initMonth = function (m) {
  5662. /* 改,规范 wdValue= 命名。Lin
  5663. $("[name="+name+"_month][type=button][wdValue="+(m<=6?3:9)+"]").trigger("click");
  5664. */ $(
  5665. "[name=" + name + "_month][type=button][ssVal=" + (m <= 6 ? 3 : 9) + "]"
  5666. ).trigger("click");
  5667. };
  5668. var year, month;
  5669. //默认值为当前时间
  5670. if ("0" == hiddenEle.value) {
  5671. year = new Date().getUTCFullYear();
  5672. month = new Date().getMonth() + 1;
  5673. } else if (hiddenEle.value && hiddenEle.value.split("-").length > 0) {
  5674. year = parseInt(hiddenEle.value.split("-")[0]);
  5675. month = parseInt(hiddenEle.value.split("-")[1]);
  5676. } else {
  5677. //默认秋季
  5678. month = 9;
  5679. }
  5680. if (year) {
  5681. this._initYear(year);
  5682. }
  5683. if (month) {
  5684. this._initMonth(month);
  5685. }
  5686. function RebuildingValue() {
  5687. var yy = document.querySelector("[name=" + name + "_year]").value;
  5688. var mm = document.querySelector(
  5689. "[name=" + name + "_month][type=hidden]"
  5690. ).value;
  5691. var hiddenvalue = "";
  5692. if (yy && mm) {
  5693. hiddenvalue = yy + "-0" + mm + "-01";
  5694. }
  5695. console.log(hiddenvalue);
  5696. document.querySelector("[name=" + name + "][type=hidden]").value =
  5697. hiddenvalue;
  5698. if (THIS.onchange) THIS.onchange();
  5699. }
  5700. RebuildingValue();
  5701. $("[name=" + name + "_month][type=button]").on("click", RebuildingValue);
  5702. $("[name=" + name + "_year][type=text]").on("click", function () {
  5703. wd.edit.datePicker({
  5704. dateFmt: "yyyy",
  5705. onpicked: RebuildingValue,
  5706. oncleared: RebuildingValue,
  5707. el: this,
  5708. });
  5709. });
  5710. this.setValue = function (v) {
  5711. var v_year = v.split("-")[0];
  5712. var v_month = v.split("-")[1];
  5713. THIS._initYear(v_year);
  5714. THIS._initMonth(v_month);
  5715. };
  5716. this.getValue = function () {
  5717. return THIS.element.value;
  5718. };
  5719. }
  5720. if (window.enrolDateList[nameee]) return;
  5721. window.enrolDateList[nameee] = new editEnrolDate(nameee);
  5722. };
  5723. window.defaultValueList = window.defaultValueList || {};
  5724. wd.display.inputDefaultValue = function (name, param) {
  5725. //xq[rxnd];
  5726. param = param.replace(/]$/, "");
  5727. var pp = param.split(/\[/);
  5728. var dictName = pp[0];
  5729. var dictParam = pp[1];
  5730. if (window.defaultValueList[name]) return;
  5731. window.defaultValueList[name] = new (function (name, n, p) {
  5732. var THIS = this;
  5733. this.name = name;
  5734. this.dict = n;
  5735. this.dictParam = p;
  5736. this.dictItem = wd.display.getInputBox(p);
  5737. this._change = function () {
  5738. console.log(THIS);
  5739. var v = THIS.dictItem.getValue();
  5740. $.ajax({
  5741. url: "/service?ssServ=defaultValueTranslate",
  5742. data: {
  5743. dict: THIS.dict,
  5744. param: "{" + THIS.dictParam + ":" + v + "}",
  5745. },
  5746. async: true,
  5747. dataType: "json",
  5748. success: function (data) {
  5749. wd.display.getInputBox(THIS.name).setValue(data.result);
  5750. },
  5751. });
  5752. };
  5753. this.dictItem.setChange(this._change);
  5754. if (!wd.display.getInputBox(name).getValue()) {
  5755. this._change();
  5756. }
  5757. })(name, dictName, dictParam);
  5758. };
  5759. //下载文件
  5760. wd.display.downloadFile = function (path, downloadName) {
  5761. var download = downloadName ? 'download="' + downloadName + '"' : "";
  5762. $("<a " + download + ' href="' + path + '"><span></span></a>')
  5763. .find("span")
  5764. .trigger("click");
  5765. //关闭圈圈
  5766. wd.display.closeLoad();
  5767. //ScreenOver层移除
  5768. $("#ScreenOver").remove();
  5769. };
  5770. //首页图标
  5771. wd.display.setHomeIconName = function (name) {
  5772. var ele = wd.topWindow.document.getElementById("mbwzbj");
  5773. if (ele != null && name) {
  5774. ele.innerHTML = name;
  5775. }
  5776. };
  5777. /**
  5778. *
  5779. * 弹出右键菜单
  5780. *
  5781. * param {
  5782. * leftClick:true//左击弹菜单
  5783. * }
  5784. *
  5785. * wd.display.showContextMenu("body",[{text:"图片",func:function(element){}}]);
  5786. */
  5787. wd.display.showContextMenu = function (selecter, datas, param) {
  5788. var options = $.extend({}, { leftClick: false }, param);
  5789. for (var i = 0; i < datas.length; i++) {
  5790. datas[i].value = i;
  5791. }
  5792. var id = "what_menu" + new Date().getTime();
  5793. var dom = wd.display.initSelectOption(id);
  5794. wd.display.buildSelectOption(dom, datas, "value", "text", null, false);
  5795. $("body").append(dom);
  5796. var $dom = $(dom).css({ position: "absolute" }).hide();
  5797. var triggerElement;
  5798. $dom.on("click", ".popupList", function () {
  5799. var v = $(this).attr("value");
  5800. datas[v].func.call(triggerElement, triggerElement);
  5801. $dom.hide();
  5802. return false;
  5803. });
  5804. var eventName = options.leftClick ? "contextmenu click" : "contextmenu";
  5805. $(document).on(eventName, selecter, function () {
  5806. var offset = $(this).offset();
  5807. dom.style.left = offset.left + window.event.offsetX + "px";
  5808. dom.style.top = offset.top + window.event.offsetY + "px";
  5809. $(dom).show();
  5810. triggerElement = this;
  5811. return false;
  5812. });
  5813. $(document).on("click", function () {
  5814. $dom.hide();
  5815. });
  5816. $(".content-div,.list-div").scroll(function () {
  5817. $dom.hide();
  5818. });
  5819. };