display.js 185 KB

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