display.js 179 KB

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