12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854 |
- //归结主要方法有: 居中显示,关闭、打开层,自适应高度,冻结表头、冻结头和列,
- //首先: special命名为sp
- var sp = window.NameSpace || {};
- if (typeof (SM4Util) != "undefined") {
- var s4 = new SM4Util();
- }
- /*禁用右键*/
- if (window.parent.location.href.indexOf("tpl/index/index2.html") > -1) {
- console.log(window.location.href)
- $("body").attr("oncontextmenu", "return false").attr("onselectstart", "return false")
- }
- //在页面dom加载完之后执行
- $(document).ready(function () {
- sp.addMask(); //为body添加上遮罩层
- sp.setClass(); //为自定义class类添加功能操作
- sp.table(); //操作table,为table加上隔行变色、
- sp.setPanel(); //面板
- sp.disablesaving(); //禁止ctrl+s
- sp.setdisabled();
- sp.setreadonly();
- sp.addDLTX(); //为body添加上点击不会隐藏的遮罩层
- //文字不可被选中
- //document.body.onselectstart = function () {
- // return false;
- //}
- });
- // $(document).click(function (e) {
- // var className = ["sp-menu-item", "sp-menu-tab", "icon-menu", "sp-menu-switch"], n = 0;
- // className.forEach(function (item) {
- // if (e.target.className.indexOf(item) != -1 || ($(e.target).parents("." + item).length > 0 && e.target.className.indexOf('fa-close') == -1)) {
- // n = 1;
- // return;
- // }
- // })
- // if (n == 0) {
- // $(".sp-menu-tab", window.parent.document).removeClass("fadeInLeft").addClass("fadeOutLeft");
- // setTimeout(function () {
- // $(".sp-menu-tab", window.parent.document).hide()
- // }, 500)
- // }
- // if (n == 1) {
- // $(".sp-menu-tab", window.parent.document).removeClass("fadeOutLeft").addClass("fadeInLeft")
- // $(".sp-menu-tab", window.parent.document).show()
- // }
- // })
- sp.addMask = function () {
- //1.为每个页面的body加上遮罩层,样式为不可见
- if ($('body').find(".sp-bgMask").length < 1) {
- $('body').prepend("<div class=\"sp-bgMask\"></div>");
- }
- //2.如果body中含有对话框 sp-dialog类名,就为其加上温馨提示和关闭按钮
- if ($('body').find(".sp-dialog").length < 1) {
- $('body').prepend("<div class=\"sp-dialog\"></div>");
- }
- //3.点击遮罩层,对话框、弹出层、遮罩层均淡出
- $(".sp-bgMask").bind("click", function () {
- $(this).fadeOut(200);
- if ($(".sp-dialog").is(":visible")) { //若对话框显示则淡出
- $(".sp-dialog").fadeOut(200);
- }
- if ($(".sp-layer").is(":visible")) { //若中间层显示则淡出
- $(".sp-layer").fadeOut(200);
- }
- if ($(".sp-layer2").is(":visible")) { //若中间层显示则淡出
- $(".sp-layer2").fadeOut(200);
- }
- });
- }
- //sp.dialog("身份证号不能为空!");
- sp.dialog = function (tip, state) {
- /// <summary>显示对话框</summary>
- var dialogHead = "<span class=\"sp-dialog-head\"><span class=\"sp-dialog-tip\">温馨提示</span><span class=\"sp-dialog-close sp-closeDialog\" title=\"关闭\">×</span></span>";
- if (state) {
- var imgState = "<span class=\"sp-dialog-logo-true\"></span>";
- var dialogBody = "<div class=\"sp-dialog-body\"><span class=\"sp-lh-22 sp-color-gray sp-text-center\">" + tip + "</span>" + imgState + "</div>";
- var dialogFoot = "<div class=\"sp-dialog-foot\"><input type=\"button\" value=\"确 定\" class=\"sp-dialog-btnClose sp-closeDialog\" style=\"float:none;\" /></div>";
- }else if(state==false){
- var imgState = "<span class=\"sp-dialog-logo-false\"></span>";;
- var dialogBody = "<div class=\"sp-dialog-body\"><span class=\"sp-lh-22 sp-color-gray sp-text-center\">" + tip + "</span>" + imgState + "</div>";
- var dialogFoot = "<div class=\"sp-dialog-foot\"><input type=\"button\" value=\"确 定\" class=\"sp-dialog-btnClose sp-closeDialog\" style=\"float:none;\" /></div>";
- } else {
- var dialogBody = "<div class=\"sp-dialog-body\">" + tip + "</div>";
- var dialogFoot = "<div class=\"sp-dialog-foot\"><input type=\"button\" id=\"dialogClose\" value=\"关 闭\" class=\"sp-dialog-btnClose sp-closeDialog\" /></div>";
- }
-
- $('.sp-dialog').html(dialogHead + dialogBody + dialogFoot);
- sp.openCenter(".sp-dialog");
- $('.sp-closeDialog').click(function (event) {
- //sp.closeCenter(".sp-dialog");
- $(".sp-dialog").fadeOut(200);
- var layerNum = 0;
- $(".sp-layer").each(function () {
- if ($(this).css("display") == "none") {
- layerNum++;
- }
- })
- if (layerNum == $(".sp-layer").length) {
- $('.sp-bgMask').fadeOut(200);
- }
- event.preventDefault(); event.stopPropagation();
- });
- }
- sp.dialoghide = function () {
- /// <summary>关闭对话框</summary>
- var layerNum = 0;
- $(".sp-dialog").fadeOut(200);
- $(".sp-layer").each(function () {
- if ($(this).css("display") == "none") {
- layerNum++;
- }
- })
- if (layerNum == $(".sp-layer").length) {
- $('.sp-bgMask').fadeOut(200);
- }
- };
- //加载loading演示
- sp.load = function () {
- /// <summary>加载loading</summary>
- if ($('body').find(".sp-load").length < 1) {
- $('body').append("<div class=\"sp-load\"><span class=\"sp-load-img\"></span><span class=\"sp-load-title\">请稍等,正努力加载中......</span></div>");
- }
- sp.setCenter(".sp-load");
- };
- sp.loadhide = function () {
- /// <summary>关闭loading</summary>
- $(".sp-load").fadeOut(200);
- };
- //打开后 居中,并且后有遮罩层
- sp.layer = function (Name) {
- /// <summary>打开弹出层</summary>
- //3.如果body中含有对话框sp-layer类名,就为其加上关闭按钮
- if ($('body').find(".sp-layer").length > 0) {
- $('.sp-layer').hide();//为对话框样式是可见的,加载时设置隐藏
- $('.sp-layer').each(function () {
- if ($(this).find(".sp-layer-head").length < 1) {
- $(this).prepend("<div class=\"sp-layer-head\"></div>");
- if ($(this).attr("data-title") != undefined) {
- var getTitle = $(this).attr("data-title");
- $(".sp-layer-head", this).prepend("<span class=\"sp-layer-title\">" + getTitle + "</span>");
- }
- }
- if ($(this).find(".sp-layer-close").length < 1) {
- $('.sp-layer-head', this).append("<span class=\"sp-layer-close\" title=\"关闭\" onclick=\"sp.closeCenter('.sp-layer')\">×</span>");
- }
- });
- };
- ///查看图片大图遮罩层
- if ($("body").find(".sp-layer2").length > 0) {
- $('.sp-layer2').each(function () {
- if ($(this).find(".sp-layer2-close").length < 1) {
- $(this).prepend("<span class=\"sp-layer2-close\" title=\"关闭\" onclick=\"sp.closeCenter('.sp-layer2')\"></span>");
- }
- });
- };
- $('.sp-bgMask').fadeIn(200);
- $("body").attr("onselectstart", "return false")
- setTimeout(function () {
- sp.setCenter(Name);
- sp.drag(Name)
- },1)
- }
- sp.layerhide = function () {
- /// <summary>关闭弹出层</summary>
- $(".sp-layer").fadeOut(200);
- $('.sp-bgMask').fadeOut(200);
- }
- sp.setClass = function () {
- //1.实现初始获取焦点 根据class="focus"用法
- $('.sp-focus').focus();
- //2. jquery实现input文本框禁用效果 根据class="banInput"用法
- $('.banInput').css({ 'background': '#ebebe4', 'border': '1px solid #a9a9a9', 'cursor': 'default' });
- $('.banInput').focus(function () {
- $('.banInput').blur();
- });
- //4.中间弹出层
- $('.openCenter').click(function () {
- sp.openCenter(".sp-layer");
- });
- $('.closeCenter').click(function () {
- sp.closeCenter(".sp-layer");
- });
- $('.sp-closeCenter').click(function () {
- sp.closeCenter(".sp-layer");
- });
- }
- //5.添加禁用方法
- sp.setdisabled = function () {
- $('.sp-disabled').attr("disabled", "disabled");
- $('.sp-disabled').click(function (event) {
- return false;
- event.preventDefault();
- });//禁止a标签链接跳转
- }
- ///6.为只读加上属性
- sp.setreadonly = function () {
- $('.sp-readonly').attr("readonly", "readonly");
- };
- //////下面是让层居中显示的js代码,
- ///页面调用方法 setCenter("#DivCeng"); 让DivCeng这个层打开并且居中显示 setCenter(".DivCeng");
- sp.setCenter = function (divName) {
- /// <summary>居中显示</summary>
- $(document).ready(function () {
- var top = ($(window).height() - $(divName).height()) / 2;
- var left = ($(window).width() - $(divName).width()) / 2;
- var scrollTop = $(document).scrollTop();
- var scrollLeft = $(document).scrollLeft();
- var zIndex = divName == ".sp-dialog" ? 100001 : 100000;
- $(divName).css({ position: 'absolute', 'top': top + scrollTop, left: left + scrollLeft, 'z-index': zIndex }).fadeIn(200);
- });
- //浏览器窗口大小改变时
- $(window).resize(function () {
- var top = ($(window).height() - $(divName).height()) / 2;
- var left = ($(window).width() - $(divName).width()) / 2;
- var scrollTop = $(document).scrollTop();
- var scrollLeft = $(document).scrollLeft();
- var zIndex = divName == ".sp-dialog" ? 100001 : 100000;
- $(divName).css({ position: 'absolute', 'top': top + scrollTop, left: left + scrollLeft, 'z-index': zIndex });
- });
- //浏览器有滚动条时的操作、
- $(window).scroll(function () {
- var top = ($(window).height() - $(divName).height()) / 2;
- var left = ($(window).width() - $(divName).width()) / 2;
- var scrollTop = $(document).scrollTop();
- var scrollLeft = $(document).scrollLeft();
- var zIndex = divName == ".sp-dialog" ? 100001 : 100000;
- $(divName).css({ position: 'absolute', 'top': top + scrollTop, left: left + scrollLeft, 'z-index': zIndex });
- });
- }
- ///单纯的打开、关闭 调用:close('#id')或 Close('.class')
- sp.open = function (name) {
- $(name).fadeIn(200);
- }
- sp.close = function (name) {
- $(name).fadeOut(200);
- }
- //打开后 居中,并且后有遮罩层
- sp.openCenter = function (Name) {
- /// <summary>打开后居中后有遮罩层</summary>
- $('.sp-bgMask').fadeIn(200);
- sp.setCenter(Name);
- }
- sp.closeCenter = function (Name) {
- /// <summary>关闭居中层</summary>
- $(Name).fadeOut(200);
- $('.sp-bgMask').fadeOut(200);
- $("body").attr("onselectstart", "")
- }
- //操作radio
- sp.funRadio = function (radioDiv, radioClass, radioCheckClass) {
- //三个参数
- $(radioDiv).each(function () {
- if (radioDiv != ".sp-radio-none") {
- $("input[type='radio']", this).hide();
- }
- $("input[type='radio']", this).parent("label").addClass(radioClass);
- $("input[type='radio']", this).click(function () {
- $(this).attr("checked", true).parent().siblings().find("input[type='radio']").removeAttr("checked");
- $(this).parent("label").addClass(radioCheckClass).siblings("label").removeClass(radioCheckClass);
- });
- $("input[type='radio']", this).each(function () {
- if ($(this).attr("checked")) {
- $(this).attr("checked", true).parent("label").addClass(radioCheckClass).siblings().removeClass(radioCheckClass);
- }
- });
- });
- }
- sp.radio = function () {
- /// <summary>美化radio</summary>
- //灰色radio
- if ($("body").find(".sp-radio-default").length > 0) {
- sp.funRadio(".sp-radio-default", "rd-default", "rd-default-checked");
- }
- //橙色radio
- if ($("body").find(".sp-radio-orange").length > 0) {
- sp.funRadio(".sp-radio-orange", "rd-orange", "rd-orange-checked");
- }
- //蓝色radio
- if ($("body").find(".sp-radio-blue").length > 0) {
- sp.funRadio(".sp-radio-blue", "rd-blue", "rd-blue-checked");
- }
- //无皮肤radio
- if ($("body").find(".sp-radio-none").length > 0) {
- sp.funRadio(".sp-radio-none", "rd-none", "rd-none-checked");
- }
- }
- //操作checkbox
- sp.funcheckbox = function (chbDiv, chbClass, chbchecked) {
- /// <summary>操作checkbox</summary>
- $(chbDiv).each(function () {
- if (chbDiv != ".sp-checkbox-none") {
- $("input[type='checkbox']", this).hide();
- }
- $("input[type='checkbox']", this).parent("label").addClass(chbClass);
- $("input[type='checkbox']", this).click(function () {
- if ($(this).parent("label").hasClass(chbchecked)) {
- $(this).removeAttr("checked").parent("label").removeClass(chbchecked);
- } else {
- $(this).attr("checked", true).parent("label").addClass(chbchecked);
- }
- });
- $("input[type='checkbox']", this).each(function () {
- if ($(this).attr("checked")) {
- $(this).attr("checked", true).parent("label").addClass(chbchecked);
- }
- });
- if ($(this).children(".sp-checkbox-all").length = 1) {
- $(".sp-checkbox-all", this).click(function () {
- if ($(this).hasClass("hasClick")) {
- $(this).removeClass("hasClick");
- $(this).parent().parent().find("input[type='checkbox']").removeAttr("checked");
- $(this).parent().parent().find("label").removeClass(chbchecked);
- } else {
- $(this).addClass("hasClick");
- $(this).parent().parent().find("input[type='checkbox']").attr("checked", true);
- $(this).parent().parent().find("label").addClass(chbchecked);
- }
- });
- }
- });
- }
- sp.checkbox = function () {
- /// <summary>美化checkbox</summary>
- if ($("body").find(".sp-checkbox-gray").length > 0) {
- sp.funcheckbox(".sp-checkbox-gray", "chb-gray", "chb-gray-checked"); //蓝色checkbox
- }
- if ($("body").find(".sp-checkbox-blue").length > 0) {
- sp.funcheckbox(".sp-checkbox-blue", "chb-blue", "chb-blue-checked"); //蓝色checkbox
- }
- if ($("body").find(".sp-checkbox-orange").length > 0) {
- sp.funcheckbox(".sp-checkbox-orange", "chb-orange", "chb-orange-checked");//橙色checkbox
- }
- if ($("body").find(".sp-checkbox-none").length > 0) {
- sp.funcheckbox(".sp-checkbox-none", "chb-none", "chb-none-checked");//无皮肤checkbox
- }
- }
- //设置upload 文件上传file控件--原生调用
- ////图片是转成base64,文件上传是模拟假的
- sp.upload = function () {
- /// <summary>美化file控件</summary>
- if ($("body").find(".sp-upload-file").length > 0) {
- $(".sp-upload .sp-upload-file").change(function () {
- if ($(this).parent().children(".sp-upload-url").length > 0) {
- var file = this.files[0];
- if (file.size > 52428800) {
- alert("文件大小不能大于50M");
- file = null;
- return false;
- } else {
- var fileUrl = $(this).val();
- $(this).parent().children(".sp-upload-url").val(fileUrl);
- }
- } else if ($(this).parent().children(".sp-upload-btn-single").length > 0) {
- var file = this.files[0];
- if (file.size > 52428800) {
- alert("文件大小不能大于50M");
- file = null;
- return false;
- } else {
- var fileUrl = $(this).val();
- var urlArr = fileUrl.split("\\");
- var getName = urlArr[urlArr.length - 1];//截取路径并获取文件的名字
- var setdiv = "<div class='sp-lh-20'>" + getName + "</div>";
- $(this).parent().children(".sp-upload-tip").show(200).append(setdiv);
- }
- }
- });
- }
- ////图片上传组件
- if ($("body").find(".sp-upload-file-img").length > 0) {
- $(".sp-upload-file-img").each(function () {
- var getimgWidth = $(this).prev(".sp-upload-img").outerWidth();
- $(this).css({ width: getimgWidth });
- });
- $(".sp-upload .sp-upload-file-img").change(function () {
- var file = this.files[0];
- if (file.size > 5242880) {
- alert("图片大小不能大于5M");
- file = null;
- return false;
- }
- var fileName = file.name;
- var postfix = fileName.substring(fileName.lastIndexOf(".") + 1).toLowerCase();
- if (postfix != "jpg" && postfix != "png" && postfix != "jpeg" && postfix != "gif") {
- alert("图片仅支持png、jpg、jpeg、gif类型的文件");
- fileName = "";
- file = null;
- return false;
- }
- var fileUrl = $(this).val();
- $(this).parent().children(".sp-upload-img").attr("data-url", fileUrl);
- var getimg = $(this).parent().children(".sp-upload-img");
- var filereader = new FileReader();
- filereader.readAsDataURL(file);
- $(filereader).load(function () {
- getimg.attr("src", this.result);
- });
- });
- }
- }
- ////图片上传组件---正式利用ajax连接后端服务的真实功能,谨慎用,记得检查各个项目的端口地址【20180921zyg】
- ///sp.uploadimg("http://103.233.7.57:8080/GoldFile/image/upload");
- sp.uploadimg = function (imgUpUrl) {
- if (!imgUpUrl) {
- alert("您好,图片上传组件的数据库路径不能为空");
- } else if ($("body").find(".sp-upload-file-img").length > 0) {
- //此是设置图片上传file控件跟其上部的img宽度设为一致,解决点击img右侧外部区域触发上传事件的bug
- $(".sp-upload-file-img").each(function () {
- var getimgWidth = $(this).prev(".sp-upload-img").outerWidth();
- $(this).css({ width: getimgWidth });
- });
- $(".sp-upload .sp-upload-file-img").change(function () {
- var file = this.files[0];
- if (file.size > 5242880) {
- //5M:5242880,10M:10485760,20M:2097120,30M:31457280,40M:41943040,50M:52428800,100M:104857600
- alert("图片大小不能大于5M");
- file = null;
- return false;
- }
- var fileName = file.name;
- var postfix = fileName.substring(fileName.lastIndexOf(".") + 1).toLowerCase();
- if (postfix != "jpg" && postfix != "png" && postfix != "jpeg" && postfix != "gif") {
- alert("图片仅支持png、jpg、jpeg、gif类型的文件");
- fileName = "";
- file = null;
- return false;
- }
- var fileUrl = $(this).val();
- $(this).parent().children(".sp-upload-img").attr("data-url", fileUrl).attr("data-name", fileName);
- var getimg = $(this).parent().children(".sp-upload-img");
- var filereader = new FileReader();
- filereader.readAsDataURL(file);
- $(filereader).load(function () {
- //getimg.attr("src", this.result);
- /////post给另外一个服务器生成一个文件地址,再返回
- var picBase = this.result;
- var picName = file.name;
- var str = "base64,"
- var begin = picBase.indexOf(str) + str.length;
- picBase = picBase.substring(begin, picBase.length);
- var data = {
- "filename": picName,
- "filedata": picBase
- }
- ////将base64和文件名传给后台
- $.ajax({
- url: imgUpUrl,
- type: 'post',
- contentType: "application/json",
- data: JSON.stringify(data),
- dataType: "json",
- success: function (res) {
- if (res.success) {
- //sp.dialog("图片上传成功");
- //$("#eventIMG").attr("src", res.url);
- getimg.attr("src", res.url); ///将文件路径赋给图片
- } else {
- alert("你好,图片上传失败");
- }
- }
- });
- });
- });
- } else { return;}
- };
- ////小文件上传组件---正式利用ajax连接后端服务的真实功能,谨慎用,记得检查各个项目的端口地址【20180921zyg】
- ///sp.uploadfile("http://103.233.7.57:8080/GoldFile/stream/upload");
- sp.uploadfile = function (fileUpUrl) {
- //$("#fbMainTableProgress_13").show();
- //$("#fbMainTableProgress_13").myProgress({ speed: 1000, percent: 30, width: "100%", height: "10px" });
- if (!fileUpUrl) {
- alert("您好,附件上传的数据库路径不能为空");
- } else if ($("body").find(".sp-upload-file-single").length > 0) {
- $(".sp-upload .sp-upload-file-single").change(function () {
- ////按钮风格
- var tip = $(this).parent().children(".sp-upload-tip");////获取显示文件及进度条的区域元素
- tip.show();///发生变化,让其显示
- var getfiles = this.files;
- var setindex = 0;
- sp.uploadfile_submit(tip, setindex, getfiles, fileUpUrl); ///调用方法,
- });
- } else { return;}
- };
- sp.uploadfile_submit = function (tip, index, getfiles, fileUpUrl) {
- ///传递三个变量,tip元素,index递归顺序量,getfiles全部文件
- var setindex = index;
- var fileItem = getfiles[setindex];///声明文件流中的第几个文件
- var getName = fileItem.name;//声明文件的名字
- var fileItemSize = fileItem.size; ////声明文件的大小
- var hasfilevar = 0;///声明变量记录是否有重复文件
- tip.find(".sp-upload-tip-lh").each(function () {
- if (getName == $(this).attr("data-name")) {
- alert("文件<" + getName + ">不能重复上传");
- hasfilevar = 1;
- //fileItem = null;
- };
- });
- if (hasfilevar != 1) {
- ////不含重复上传的重名文件
- if (fileItemSize > 10485760) {
- //5M:5242880,10M:10485760,20M:2097120,30M:31457280,40M:41943040,50M:52428800,100M:104857600
- alert("文件<" + getName + ">大小不能大于10M"); ///目前为了防止恶意上传,限制10M;后期根据项目需要进行更改
- fileItem = null;
- return false;
- } else {
- var fileSize = 0;
- if (fileItemSize > 1024 * 1024) {
- fileSize = (Math.round(fileItemSize * 100 / (1024 * 1024)) / 100).toString() + 'MB';
- }
- else {
- fileSize = (Math.round(fileItemSize * 100 / 1024) / 100).toString() + 'KB';
- }
- //往tip中append---sp-upload-tip-lh
- var settiplh = "<div class='sp-upload-tip-lh' data-url='' data-name='" + getName + "'><div class='sp-progress sp-progress-blue' style='display:none;'><div class='percent-show'><span>0</span>%</div><div class='progress-in'></div></div><div class='sp-upload-tip-info'></div></div>";
- tip.append(settiplh);
- var eqtiplh = tip.find(".sp-upload-tip-lh:last-child");//得到刚添加的最后一个.sp-upload-tip-lh元素
- var fileProgress = eqtiplh.children(".sp-progress");////其下进度条
- fileProgress.show();
- //eqtiplh.show();
- var formData = new FormData();///声明FormData
- formData.append("streamFile", fileItem); ///将存放在参数名streamFile中的file中的数据一起append到formData
- var date1 = new Date();
- $.ajax({
- url: fileUpUrl,
- type: 'POST',
- cache: false, //上传文件无需缓存
- data: formData,
- async: true, ///异步true,同步false
- processData: false,// 是否序列化data属性,默认true(注意:false时type必须是post)
- contentType: false,// 当有文件要上传时,此项是必须的,否则后台无法识别文件流的起始位置
- xhr: function () {
- //这是关键 获取原生的xhr对象
- var xhr = jQuery.ajaxSettings.xhr();
- /////监测上传进度
- xhr.upload.onprogress = function (ev) {
- if (ev.lengthComputable) {
- var percent = 100 * ev.loaded / ev.total;
- fileProgress.myProgress({ speed: 0, percent: percent.toFixed(0), width: "100%", height: "10px" });
- //console.log(percent, ev); ///打印百分比以及进度
- }
- }
- ////上传完成后
- xhr.upload.onload = function () {
- setTimeout(function () {
- fileProgress.hide();
- eqtiplh.children(".sp-upload-tip-info").show().append("" + getName + "(" + fileSize + ")-上传成功<i class='fa fa-close sp-upload-tip-close'> 删除</i>");
- $(".sp-upload .sp-upload-tip-lh").each(function () {
- $(".fa-close", this).click(function () {
- $(this).parents(".sp-upload-tip-lh").remove();
- });
- });
- }, 200);
- }
- return xhr;
- },
- success: function (res) {
- eqtiplh.attr("data-url", res.url).attr("data-size", fileItemSize);
- },
- error: function (data, status, e) {
- alert("您好,附件上传失败");
- console.log(e);
- }
- });
- }
- }
- ///递归循环调用此方法,加个延时防止异步加载返回值冲突
- setTimeout(function () {
- if (setindex < getfiles.length - 1) {
- setindex++;
- sp.uploadfile_submit(tip, setindex, getfiles); ///调用方法
- };
- }, 100);
- };
- ///div自适应分辨率高度 使用: fitHeight('#id', 50);fitHeight('.class', 50);
- sp.fitHeight = function (Name, Height) {
- /// <summary>自适应分辨率的高度</summary>
- $(document).ready(function () { //DOM加载后就执行
- var WindowHeight = $(window).height();
- $(Name).css('height', WindowHeight - Height);
- });
- $(window).resize(function () { //改变窗体大小时 *resize()变化或者改变事件
- var WindowHeight = $(window).height();
- $(Name).css('height', WindowHeight - Height);
- });
- $(window).scroll(function () { //浏览器有滚动条时的操作 scroll()滚动事件
- var WindowHeight = $(window).height();
- $(Name).css('height', WindowHeight - Height);
- });
- }
- ///div自适应分辨率高度 使用: fitWidth('#id', 50);fitWidth('.class', 50);
- sp.fitWidth = function (Name, width) {
- /// <summary>自适应分辨率宽度</summary>
- $(document).ready(function () { //DOM加载后就执行
- var WindownWidth = $(window).width();
- $(Name).css('width', (WindownWidth - width) + 'px');
- });
- $(window).resize(function () { //改变窗体大小时 *resize()变化或者改变事件
- var WindownWidth = $(window).width();
- $(Name).css('width', (WindownWidth - width) + 'px');
- });
- $(window).scroll(function () { //浏览器有滚动条时的操作 scroll()滚动事件
- var WindownWidth = $(window).width();
- $(Name).css('width', (WindownWidth - width) + 'px');
- });
- }
- //操作table
- sp.table = function () {
- /// <summary>设置table</summary>
- if ($('body').find(".sp-grid").length > 0) {
- $('.sp-grid-striped tbody tr:odd').addClass('evenTr');//奇数行背景色
- $('.sp-grid tbody tr:last-child td').css('border-bottom', '0');
- $('.sp-grid-select tbody tr').click(function () {
- if ($(this).hasClass('sp-grid-trselected')) {
- $(this).removeClass('sp-grid-trselected')
- }
- else {
- $(this).addClass('sp-grid-trselected').siblings().removeClass('sp-grid-trselected');
- }
- });
- }
- //$('.grid tbody tr td').each(function () {
- // $(this).attr("title", $(this).text());//加上title属性
- //});
- }
- /**sp.getPage(URL, ID);调用Ajax获取数据集 <param name="URL">URL地址</param>**/
- sp.getPage = function (URL, ID) {
- /// 调用Ajax获取数据集 <param name="URL">URL地址</param> <returns>返回数据集</returns>
- sp.AjaxControl(URL, function (result) {
- $(ID).html(result);
- });
- };
- /**Common.AjaxControl(URL, callBack);调用Ajax操作**/
- sp.AjaxControl = function (URL, callBack) {
- /// 调用Ajax操作数据库(底层方法)
- /// <param name="URL">URL地址</param>
- /// <param name="callBack">回调函数的作用就是在Ajax成功执行之后可以执行一个函数</param>
- /// <returns>返回数据集</returns>
- $.ajax({
- url: URL, //这里是静态页的地址
- type: "GET", //静态页用get方法,否则服务器会抛出405错误
- //cache: false,
- async: false,
- success: function (result) {
- callBack(result);
- },
- //请求执行异常后,执行的方法
- error: function (XMLHttpRequest, textStatus, errorThrown) {
- alert("没有找到页面源!");
- }
- });
- };
- //操作5级菜单
- sp.setLeftMenu = function () {
- $(".sp-leftmenu-first").children("a").on("click", function () {
- if ($(this).hasClass("hasclick")) {
- $(this).removeClass("hasclick").parents(".sp-leftmenu-first").find(".sp-leftmenu-second").slideUp(300);
- if ($(this).children(".sp-leftmenu-icon").length > 0) {
- $('.sub-logo', this).show();
- $('.sub-logo-hide', this).hide();
- }
- } else {
- //点击一级菜单时,如果已经折叠,取消折叠样式,
- if ($('#spWrapperLeftBar').hasClass('sp-leftmenu-fold')) {
- $('#spWrapperLeftBar').removeClass("sp-leftmenu-fold");
- $("#setLeftMenu_fold").removeClass("hasclick");
- $('.sp-wrapper-left').css('width', '140px');
- $('.sp-wrapper-right').css('left', '140px');
- }
- $(this).addClass("hasclick").addClass("sp-leftmenu-active");
- var leftmenufirst = $(this).parents(".sp-leftmenu-first");
- leftmenufirst.siblings().children("a").removeClass('sp-leftmenu-active').removeClass("hasclick");
- if ($(this).children(".sp-leftmenu-icon").length > 0) {
- //含有子菜单
- $('.sub-logo', this).hide();
- $('.sub-logo-hide', this).show();
- leftmenufirst.find(".sp-leftmenu-second").slideDown(300);//其下二级菜单展开
- } else {
- //不含子菜单
- var get_clickID = $(this).attr('id');//获取menuClick的id
- localStorage.setItem("GlWorkPlatform-setLeftBarClickID", get_clickID);
- }
- leftmenufirst.siblings().find('.sub-logo').show(); //其他一级菜单下右侧图标恢复
- leftmenufirst.siblings().find('.sub-logo-hide').hide();//其他一级菜单下右侧图标恢复
- leftmenufirst.siblings('li').find('li').slideUp(300);
- }
- });
- $(".sp-leftmenu-second").children("a").on("click", function () {
- if ($(this).hasClass("hasclick")) {
- $(this).removeClass("hasclick").removeClass("leftmenuClick").parents(".sp-leftmenu-second").find(".sp-leftmenu-third").slideUp(300);
- if ($(this).children(".sp-leftmenu-icon").length > 0) {
- $('.sub-logo', this).show();
- $('.sub-logo-hide', this).hide();
- }
- } else {
- $(this).addClass("hasclick").addClass("leftmenuClick");
- var leftmenufirst = $(this).parents(".sp-leftmenu-first");
- var leftmenuSecond = $(this).parents(".sp-leftmenu-second");
- if ($(this).children(".sp-leftmenu-icon").length > 0) {
- ///含有子菜单时
- $('.sub-logo', this).hide();
- $('.sub-logo-hide', this).show();
- leftmenuSecond.find(".sp-leftmenu-third").slideDown(300); ///当前级别三级菜单打开
- } else {
- //其下不含有子菜单
- var get_clickID = $(this).attr('id');//获取menuClick的id
- localStorage.setItem("GlWorkPlatform-setLeftBarClickID", get_clickID);
- }
- leftmenuSecond.siblings().find("li").slideUp(300); //其他二级菜单下三级菜单折叠
- leftmenuSecond.siblings().children("a").removeClass("hasclick").removeClass("leftmenuClick"); //其他二级菜单去掉样式
- leftmenuSecond.siblings().find('.sub-logo').show(); //其他二级菜单下右侧图标恢复
- leftmenuSecond.siblings().find('.sub-logo-hide').hide();//其他二级菜单下右侧图标恢复
- leftmenufirst.siblings().find("a").removeClass("hasclick").removeClass("leftmenuClick");///其他一级下菜单去掉样式
- }
- });
- $(".sp-leftmenu-third").children("a").on("click", function () {
- if ($(this).hasClass("hasclick")) {
- $(this).removeClass("hasclick").removeClass("leftmenuClick").parents(".sp-leftmenu-third").find(".sp-leftmenu-fourth").slideUp(300);
- if ($(this).children(".sp-leftmenu-icon").length > 0) {
- $('.sub-logo', this).show();
- $('.sub-logo-hide', this).hide();
- }
- } else {
- $(this).addClass("hasclick").addClass("leftmenuClick");
- var leftmenufirst = $(this).parents(".sp-leftmenu-first");
- var leftmenuSecond = $(this).parents(".sp-leftmenu-second");
- var leftmenuThird = $(this).parents(".sp-leftmenu-third");
- if ($(this).children(".sp-leftmenu-icon").length > 0) {
- ///含有子菜单时
- $('.sub-logo', this).hide();
- $('.sub-logo-hide', this).show();
- leftmenuThird.find(".sp-leftmenu-fourth").slideDown(300); ///当前级别四级菜单打开
- } else {
- //其下不含有子菜单
- var get_clickID = $(this).attr('id');//获取menuClick的id
- localStorage.setItem("GlWorkPlatform-setLeftBarClickID", get_clickID);
- }
- leftmenuThird.siblings().find("li").slideUp(300); //其他三级菜单下四级菜单折叠
- leftmenuThird.siblings().find("a").removeClass("hasclick").removeClass("leftmenuClick"); //其他三级菜单去掉样式
- leftmenuThird.siblings().find('.sub-logo').show(); //其他同级菜单下右侧图标恢复
- leftmenuThird.siblings().find('.sub-logo-hide').hide();//其他同级菜单下右侧图标恢复
- leftmenuSecond.siblings().find("a").removeClass("hasclick").removeClass("leftmenuClick");///其他二级下菜单去掉样式
- leftmenufirst.siblings().find("a").removeClass("hasclick").removeClass("leftmenuClick");///其他一级下菜单去掉样式
- leftmenuSecond.children("a").removeClass("leftmenuClick");///父级二级菜单去掉样式
- };
- });
- $(".sp-leftmenu-fourth").children("a").on("click", function () {
- if ($(this).hasClass("hasclick")) {
- $(this).removeClass("hasclick").removeClass("leftmenuClick").parents(".sp-leftmenu-fourth").find(".sp-leftmenu-fifth").slideUp(300);
- if ($(this).children(".sp-leftmenu-icon").length > 0) {
- $('.sub-logo', this).show();
- $('.sub-logo-hide', this).hide();
- }
- } else {
- $(this).addClass("hasclick").addClass("leftmenuClick");
- var leftmenufirst = $(this).parents(".sp-leftmenu-first");
- var leftmenuSecond = $(this).parents(".sp-leftmenu-second");
- var leftmenuThird = $(this).parents(".sp-leftmenu-third");
- var leftmenuFourth = $(this).parents(".sp-leftmenu-fourth");
- if ($(this).children(".sp-leftmenu-icon").length > 0) {
- ///含有子菜单时
- $('.sub-logo', this).hide();
- $('.sub-logo-hide', this).show();
- leftmenuFourth.find(".sp-leftmenu-fifth").slideDown(300); ///当前级别四级菜单打开
- } else {
- //其下不含有子菜单
- var get_clickID = $(this).attr('id');//获取menuClick的id
- localStorage.setItem("GlWorkPlatform-setLeftBarClickID", get_clickID);
- }
- leftmenuFourth.siblings().find("li").slideUp(300); //其他四级菜单下五级菜单折叠
- leftmenuFourth.siblings().find("a").removeClass("hasclick").removeClass("leftmenuClick"); //其他四级菜单去掉样式
- leftmenuFourth.siblings().find('.sub-logo').show(); //其他同级菜单下右侧图标恢复
- leftmenuFourth.siblings().find('.sub-logo-hide').hide();//其他同级菜单下右侧图标恢复
- leftmenuThird.siblings().find("a").removeClass("hasclick").removeClass("leftmenuClick");///其他三级下菜单去掉样式
- leftmenuSecond.siblings().find("a").removeClass("hasclick").removeClass("leftmenuClick");///其他二级下菜单去掉样式
- leftmenufirst.siblings().find("a").removeClass("hasclick").removeClass("leftmenuClick");///其他一级下菜单去掉样式
- leftmenuThird.children("a").removeClass("leftmenuClick");///父级三级菜单去掉样式
- leftmenuSecond.children("a").removeClass("leftmenuClick");///父级二级菜单去掉样式
- };
- });
- $(".sp-leftmenu-fifth").children("a").on("click", function () {
- if ($(this).hasClass("hasclick")) {
- $(this).removeClass("hasclick").removeClass("leftmenuClick");
- } else {
- $(this).addClass("hasclick").addClass("leftmenuClick");
- var leftmenufirst = $(this).parents(".sp-leftmenu-first");
- var leftmenuSecond = $(this).parents(".sp-leftmenu-second");
- var leftmenuThird = $(this).parents(".sp-leftmenu-third");
- var leftmenuFourth = $(this).parents(".sp-leftmenu-fourth");
- var leftmenuFifth = $(this).parents(".sp-leftmenu-fifth");
- if ($(this).children(".sp-leftmenu-icon").length > 0) {
- ///含有子菜单时
- $('.sub-logo', this).hide();
- $('.sub-logo-hide', this).show();
- leftmenuFourth.find(".sp-leftmenu-fifth").slideDown(300); ///当前级别四级菜单打开
- } else {
- //其下不含有子菜单
- var get_clickID = $(this).attr('id');//获取menuClick的id
- localStorage.setItem("GlWorkPlatform-setLeftBarClickID", get_clickID);
- }
- leftmenuFifth.siblings().find("a").removeClass("hasclick").removeClass("leftmenuClick"); //其他五级菜单去掉样式
- leftmenuFourth.siblings().find("a").removeClass("hasclick").removeClass("leftmenuClick");///其他四级下菜单去掉样式
- leftmenuThird.siblings().find("a").removeClass("hasclick").removeClass("leftmenuClick");///其他三级下菜单去掉样式
- leftmenuSecond.siblings().find("a").removeClass("hasclick").removeClass("leftmenuClick");///其他二级下菜单去掉样式
- leftmenufirst.siblings().find("a").removeClass("hasclick").removeClass("leftmenuClick");///其他一级下菜单去掉样式
- leftmenuFourth.children("a").removeClass("leftmenuClick");///父级四级菜单去掉样式
- leftmenuThird.children("a").removeClass("leftmenuClick");///父级三级菜单去掉样式
- leftmenuSecond.children("a").removeClass("leftmenuClick");///父级二级菜单去掉样式
-
- };
- });
- //左侧最上折叠/打开左侧菜单 按钮
- $("#setLeftMenu_fold").on("click", function () {
- if ($(this).hasClass("hasclick")) {
- $(this).removeClass("hasclick");
- $('#spWrapperLeftBar').removeClass("sp-leftmenu-fold");
- $('.sp-wrapper-left').css('width', '140px');
- $(".sp-wrapper-right").css("left", "140px");
- }
- else {
- $(this).addClass("hasclick");
- $('#spWrapperLeftBar').addClass("sp-leftmenu-fold");
- $('.sp-wrapper-left').css('width', '40px');
- $(".sp-wrapper-right").css("left", "40px");
- }
- });
- };
- //操作皮肤变色,将变色id加到localStorage中
- sp.setCssSkin = function () {
- //选择皮肤
- if ($("body").find(".sp-skin-box").length > 0) {
- var li = $(".sp-skin-box span");
- li.click(function () {
- var id = $(this).attr('id');
- $(this).addClass("sp-skin-current").siblings().removeClass("sp-skin-current");
- $("#skin_color").attr("href", "AFrontEnd/css/skin/" + id + ".css");
- localStorage.setItem("GlWorkPlatform-cssSkin", id);
- });
- var cookieSkin = localStorage.getItem("GlWorkPlatform-cssSkin");
- if (cookieSkin) {
- $("#" + cookieSkin).addClass("sp-skin-current").siblings().removeClass("sp-skin-current");
- $("#skin_color").attr("href", "AFrontEnd/css/skin/" + cookieSkin + ".css");
- localStorage.setItem("GlWorkPlatform-cssSkin", cookieSkin);
- }
- }
- }
- sp.setCssSkinTwo = function () {
- //选择皮肤
- if ($("body").find(".sp-skin-box").length > 0) {
- var li = $(".sp-skin-box span");
- li.click(function () {
- var id = $(this).attr('id');
- $(this).addClass("sp-skin-current").siblings().removeClass("sp-skin-current");
- $("#skin_color").attr("href", "AFrontEnd/css/skintwo/" + id + ".css");
- localStorage.setItem("GlWorkPlatform-cssSkin", id);
- });
- var cookieSkin = localStorage.getItem("GlWorkPlatform-cssSkin");
- if (cookieSkin) {
- $("#" + cookieSkin).addClass("sp-skin-current").siblings().removeClass("sp-skin-current");
- $("#skin_color").attr("href", "AFrontEnd/css/skintwo/" + cookieSkin + ".css");
- localStorage.setItem("GlWorkPlatform-cssSkin", cookieSkin);
- }
- }
- }
- ///根据localStorage中存的菜单id,加载到设置中 20180801改
- sp.setLeftMenuActiveByCookie = function () {
- //判断存到的ID 然后进行一级、二级、三级的判断
- var cookie_clickID = localStorage.getItem("GlWorkPlatform-setLeftBarClickID");
- //加上条件,在其不能为空或者null时方可执行
- if (cookie_clickID != "" && cookie_clickID != null) {
- localStorage.setItem("GlWorkPlatform-setLeftBarClickID", cookie_clickID);
- //获取ID的class,然后进行一级、二级、三级的判断
- var get_className = $("#" + cookie_clickID).parent().attr('class');
- if (get_className != "" && get_className != null && get_className != undefined) {
- if (get_className.indexOf('sp-leftmenu-first') != -1) {
- ///仅有一级菜单时
- sp.restoreHomeFirst("#" + cookie_clickID);
- }
- else if (get_className.indexOf('sp-leftmenu-second') != -1) {
- ///含有有二级菜单时
- sp.restoreHomeSecond("#" + cookie_clickID);
- }
- else if (get_className.indexOf("sp-leftmenu-third") != -1) {
- //三级three
- sp.restoreHomeThird("#" + cookie_clickID);
- }
- else if (get_className.indexOf('sp-leftmenu-fourth') != -1) {///四级 .four
- sp.restoreHomeFourth("#" + cookie_clickID);
- }
- else if (get_className.indexOf('sp-leftmenu-fifth') != -1) {///五级 .five
- sp.restoreHomeFifth("#" + cookie_clickID);
- } else { return; }
- }
- }
- }
- ///当首页文件处在一级时
- sp.restoreHomeFirst = function (getfileid) {
- $(getfileid).addClass("hasclick").addClass("sp-leftmenu-active");
- var leftmenufirst = $(getfileid).parents(".sp-leftmenu-first");
- leftmenufirst.siblings().children("a").removeClass('sp-leftmenu-active').removeClass("hasclick");
- leftmenufirst.siblings().find('.sub-logo').show(); //其他一级菜单下右侧图标恢复
- leftmenufirst.siblings().find('.sub-logo-hide').hide();//其他一级菜单下右侧图标恢复
- leftmenufirst.siblings('li').find('li').slideUp(300);
- leftmenufirst.children("a").find('.sub-logo').hide(); //右侧图标变化
- leftmenufirst.children("a").find('.sub-logo-hide').show();
- };
- ///当首页文件处在二级时
- sp.restoreHomeSecond = function (getfileid) {
- $(getfileid).addClass("hasclick").addClass("leftmenuClick");
- var leftmenufirst = $(getfileid).parents(".sp-leftmenu-first");
- var leftmenuSecond = $(getfileid).parents(".sp-leftmenu-second");
- leftmenuSecond.siblings().find("li").slideUp(300); //其他二级菜单下三级菜单折叠
- leftmenuSecond.siblings().children("a").removeClass("hasclick").removeClass("leftmenuClick"); //其他二级菜单去掉样式
- leftmenuSecond.siblings().find('.sub-logo').show(); //其他二级菜单下右侧图标恢复
- leftmenuSecond.siblings().find('.sub-logo-hide').hide();//其他二级菜单下右侧图标恢复
- leftmenufirst.find(".sp-leftmenu-second").slideDown(300); ///当前级别二级菜单打开
- leftmenufirst.children("a").find('.sub-logo').hide();
- leftmenufirst.children("a").find('.sub-logo-hide').show();///右侧图标变化
- leftmenufirst.children("a").addClass("sp-leftmenu-active");
- leftmenufirst.siblings().find('li').slideUp(300);
- leftmenufirst.siblings().find('.sub-logo').show();
- leftmenufirst.siblings().find('.sub-logo-hide').hide(); //其他一级菜单下右侧图标恢复
- leftmenufirst.siblings().find("a").removeClass("hasclick").removeClass("leftmenuClick").removeClass("sp-leftmenu-active");///其他一级下菜单去掉样式
- };
- ///当首页文件 处在三级时
- sp.restoreHomeThird = function (getfileid) {
- //三级three
- $(getfileid).addClass("hasclick").addClass("leftmenuClick");
- var leftmenufirst = $(getfileid).parents(".sp-leftmenu-first");
- var leftmenuSecond = $(getfileid).parents(".sp-leftmenu-second");
- var leftmenuThird = $(getfileid).parents(".sp-leftmenu-third");
- leftmenuThird.siblings().find("li").slideUp(300); //其他三级菜单下四级菜单折叠
- leftmenuThird.siblings().find("a").removeClass("hasclick").removeClass("leftmenuClick"); //其他三级菜单去掉样式
- leftmenuThird.children("a").find('.sub-logo').hide();
- leftmenuThird.children("a").find('.sub-logo-hide').show(); ///右侧图标变化
- leftmenuThird.siblings().find('.sub-logo').show();
- leftmenuThird.siblings().find('.sub-logo-hide').hide(); //其他同级菜单下右侧图标恢复
- leftmenuSecond.find(".sp-leftmenu-third").slideDown(300); ///当前级别三级菜单打开
- leftmenuSecond.siblings().find("li").slideUp(300); //其他二级菜单下三级菜单折叠
- leftmenuSecond.siblings().children("a").removeClass("hasclick").removeClass("leftmenuClick"); //其他二级菜单去掉样式
- leftmenuSecond.children("a").find('.sub-logo').hide();
- leftmenuSecond.children("a").find('.sub-logo-hide').show(); //其右侧标变化
- leftmenuSecond.siblings().find('.sub-logo').show();
- leftmenuSecond.siblings().find('.sub-logo-hide').hide(); //其他二级菜单下右侧图标恢复
- leftmenufirst.siblings().find("a").removeClass("hasclick").removeClass("leftmenuClick").removeClass("sp-leftmenu-active");///其他一级下菜单去掉样式
- leftmenufirst.find(".sp-leftmenu-second").slideDown(300); ///当前级别二级菜单打开
- leftmenufirst.children("a").find('.sub-logo').hide();
- leftmenufirst.children("a").find('.sub-logo-hide').show();
- leftmenufirst.children("a").addClass("sp-leftmenu-active");
- leftmenufirst.siblings().find('li').slideUp(300);
- leftmenufirst.siblings().find('.sub-logo').show();
- leftmenufirst.siblings().find('.sub-logo-hide').hide(); //其他一级菜单下右侧图标恢复
- };
- ///当首页文件处在四级时
- sp.restoreHomeFourth = function (getfileid) {
- $(getfileid).addClass("hasclick").addClass("leftmenuClick");
- var leftmenufirst = $(getfileid).parents(".sp-leftmenu-first");
- var leftmenuSecond = $(getfileid).parents(".sp-leftmenu-second");
- var leftmenuThird = $(getfileid).parents(".sp-leftmenu-third");
- var leftmenuFourth = $(getfileid).parents(".sp-leftmenu-fourth");
- leftmenuFourth.siblings().find("li").slideUp(300); //其他四级菜单下五级菜单折叠
- leftmenuFourth.siblings().find("a").removeClass("hasclick").removeClass("leftmenuClick"); //其他四级菜单去掉样式
- leftmenuFourth.children("a").find('.sub-logo').hide();
- leftmenuFourth.children("a").find('.sub-logo-hide').show(); //其右侧标变化
- leftmenuFourth.siblings().find('.sub-logo').show().find('.sub-logo-hide').hide(); //其他同级菜单下右侧图标恢复
- leftmenufirst.find(".sp-leftmenu-second").slideDown(300);//其下二级菜单展开
- leftmenufirst.siblings('li').find('li').slideUp(300);
- leftmenufirst.siblings().find("a").removeClass("hasclick").removeClass("leftmenuClick").removeClass("sp-leftmenu-active");///其他一级下菜单去掉样式
- leftmenufirst.children("a").addClass("sp-leftmenu-active");
- leftmenufirst.children("a").find('.sub-logo').hide();
- leftmenufirst.children("a").find('.sub-logo-hide').show();
- leftmenufirst.siblings().find('.sub-logo').show();
- leftmenufirst.siblings().find('.sub-logo-hide').hide(); //其他一级菜单下右侧图标恢复
- leftmenuSecond.find(".sp-leftmenu-third").slideDown(300); ///当前级别三级菜单打开
- leftmenuSecond.siblings().find("a").removeClass("hasclick").removeClass("leftmenuClick");///其他二级下菜单去掉样式
- leftmenuSecond.siblings().children("a").removeClass("hasclick").removeClass("leftmenuClick"); //其他二级菜单去掉样式
- leftmenuSecond.children("a").find('.sub-logo').hide();
- leftmenuSecond.children("a").find('.sub-logo-hide').show(); //其右侧标变化
- leftmenuSecond.siblings().find('.sub-logo').show();
- leftmenuSecond.siblings().find('.sub-logo-hide').hide(); //其他二级菜单下右侧图标恢复
- leftmenuThird.find(".sp-leftmenu-fourth").slideDown(300); ///当前级别四级菜单打开
- leftmenuThird.siblings().find("a").removeClass("hasclick").removeClass("leftmenuClick");///其他三级下菜单去掉样式
- leftmenuThird.children("a").removeClass("leftmenuClick");///父级三级菜单去掉样式
- leftmenuThird.children("a").find('.sub-logo').hide();
- leftmenuThird.children("a").find('.sub-logo-hide').show(); //其右侧标变化
- leftmenuThird.siblings().find('.sub-logo').show();
- leftmenuThird.siblings().find('.sub-logo-hide').hide(); //其他同级菜单下右侧图标恢复
- };
- ///当首页文件处在五级时
- sp.restoreHomeFifth = function (getfileid) {
- $(getfileid).addClass("hasclick").addClass("leftmenuClick");
- var leftmenufirst = $(getfileid).parents(".sp-leftmenu-first");
- var leftmenuSecond = $(getfileid).parents(".sp-leftmenu-second");
- var leftmenuThird = $(getfileid).parents(".sp-leftmenu-third");
- var leftmenuFourth = $(getfileid).parents(".sp-leftmenu-fourth");
- var leftmenuFifth = $(getfileid).parents(".sp-leftmenu-fifth");
- leftmenuFifth.siblings().find("a").removeClass("hasclick").removeClass("leftmenuClick"); //其他五级菜单去掉样式
- leftmenufirst.find(".sp-leftmenu-second").slideDown(300);//其下二级菜单展开
- leftmenufirst.siblings('li').find('li').slideUp(300);
- leftmenufirst.siblings().find("a").removeClass("hasclick").removeClass("leftmenuClick").removeClass("sp-leftmenu-active");///其他一级下菜单去掉样式
- leftmenufirst.children("a").addClass("sp-leftmenu-active");
- leftmenufirst.children("a").find('.sub-logo').hide();
- leftmenufirst.children("a").find('.sub-logo-hide').show();//其右侧标变化
- leftmenufirst.siblings().find('.sub-logo').show().find('.sub-logo-hide').hide(); //其他一级菜单下右侧图标恢复
- leftmenuSecond.find(".sp-leftmenu-third").slideDown(300); ///当前级别三级菜单打开
- leftmenuSecond.siblings().find("a").removeClass("hasclick").removeClass("leftmenuClick");///其他二级下菜单去掉样式
- leftmenuSecond.siblings().children("a").removeClass("hasclick").removeClass("leftmenuClick"); //其他二级菜单去掉样式
- leftmenuSecond.children("a").find('.sub-logo').hide();
- leftmenuSecond.children("a").find('.sub-logo-hide').show(); //其右侧标变化
- leftmenuSecond.siblings().find('.sub-logo').show();
- leftmenuSecond.siblings().find('.sub-logo-hide').hide(); //其他二级菜单下右侧图标恢复
- leftmenuThird.find(".sp-leftmenu-fourth").slideDown(300); ///当前级别四级菜单打开
- leftmenuThird.siblings().find("a").removeClass("hasclick").removeClass("leftmenuClick");///其他三级下菜单去掉样式
- leftmenuThird.children("a").removeClass("leftmenuClick");///父级三级菜单去掉样式
- leftmenuThird.children("a").find('.sub-logo').hide();
- leftmenuThird.children("a").find('.sub-logo-hide').show(); //其右侧标变化
- leftmenuThird.siblings().find('.sub-logo').show();
- leftmenuThird.siblings().find('.sub-logo-hide').hide(); //其他同级菜单下右侧图标恢复
- leftmenuFourth.find(".sp-leftmenu-fifth").slideDown(300); ///当前级别四级菜单打开
- leftmenuFourth.siblings().find("li").slideUp(300); //其他四级菜单下五级菜单折叠
- leftmenuFourth.siblings().find("a").removeClass("hasclick").removeClass("leftmenuClick"); //其他四级菜单去掉样式
- leftmenuFourth.children("a").find('.sub-logo').hide();
- leftmenuFourth.children("a").find('.sub-logo-hide').show(); //其右侧标变化
- leftmenuFourth.siblings().find('.sub-logo').show();
- leftmenuFourth.siblings().find('.sub-logo-hide').hide(); //其他同级菜单下右侧图标恢复
- };
- /////记录打开的菜单文件20180730
- /////保存打开的菜单中的文件路径,存入本地存储中,
- sp.savemenufile = function (idstr, title, src) {
- var fileJsonObj = { "id": idstr, "title": title, "src": src };
- if (localStorage.getItem("GlWorkPlatform-openfileArray") == undefined || localStorage.getItem("GlWorkPlatform-openfileArray") == null) {
- var openFileArray = [];
- openFileArray.push(fileJsonObj);
- localStorage.setItem("GlWorkPlatform-openfileArray", JSON.stringify(openFileArray)); //localStorage默认的是字符型,因此需要将json串转成字符型
- } else {
- var getopenfilearry = localStorage.getItem("GlWorkPlatform-openfileArray");//取出菜单文件数据
- //console.log(getopenfilearry);
- var setfilearry = JSON.parse(getopenfilearry);//把字符串转换成JSON对象
- var sethasfileno = 0; ///设置是否存有问价的标识
- var oldfiledata = ""; //旧得数据
- $.each(setfilearry, function (index, item) {
- if (item.id == idstr) {
- sethasfileno = 1; ///说明菜单文件中已经存在该文件
- oldfiledata = { "id": idstr, "title": item.title, "src": item.src };
- }
- });
- if (sethasfileno == 0) {
- //没有重复时push
- setfilearry.push(fileJsonObj);
- } else {
- ///重复时应该更新该条数据
- var updatedataarray = JSON.stringify(setfilearry);
- var updatereplaceArray = updatedataarray.replace(JSON.stringify(oldfiledata), JSON.stringify(fileJsonObj));
- setfilearry = JSON.parse(updatereplaceArray);
- }
- ///未找到,没有重复的
- //if (getopenfilearry.indexOf(JSON.stringify(fileJsonObj)) == -1) {
- // setfilearry.push(fileJsonObj);
- //};
- localStorage.setItem("GlWorkPlatform-openfileArray", JSON.stringify(setfilearry)); //localStorage默认的是字符型,因此需要将json串转成字符型
- //console.log(JSON.stringify(setfilearry));
- }
- };
- //首页tab签导航条
- sp.clickTabNavActive = function (obj) {
- var get_child_id = $(obj).attr("data-href");
- $(obj).addClass("sp-wrapper-tabs-current").siblings().removeClass("sp-wrapper-tabs-current");
- $(get_child_id).show().addClass("sp-wrapper-tabs-box-current");
- $(get_child_id).siblings().removeClass("sp-wrapper-tabs-box-current").hide();
- }
- sp.closeSingleTabsNav = function (obj) {
- //点击上面的叉号时
- var get_child_id = $(obj).parent().attr("data-href"); //获取对应id
- var getid = get_child_id.substring(get_child_id.lastIndexOf("_") + 1, get_child_id.length);
- var temp = localStorage.getItem("GlWorkPlatform-openfileArray");//取出文件数据
- var tempObj = JSON.parse(temp);//把字符串转换成JSON对象
- var fileJsonObj = "";
- $.each(tempObj, function (index, item) {
- if (item.id == getid) {
- fileJsonObj = { "id": item.id, "title": item.title, "src": item.src }
- }
- });
- var setItemStr = "," + JSON.stringify(fileJsonObj);
- //console.log(setItemStr);
- var replaceArray = temp.replace(setItemStr, "");
- //console.log(replaceArray);
- localStorage.setItem("GlWorkPlatform-openfileArray", replaceArray); //localStorage默认的是字符型,因此需要将json串转成字符型
- if ($(obj).parent().hasClass("sp-wrapper-tabs-current")) {
- //若此列是当前显示的列,让其前一列显示
- $(obj).parent().prev("li").addClass("sp-wrapper-tabs-current").show();
- $(get_child_id).prev(".sp-wrapper-tabs-box-col").addClass("sp-wrapper-tabs-box-current").show();
- $(obj).parent().remove();
- $(get_child_id).remove();
- } else {
- //若不是当前列,则直接移除
- $(obj).parent().remove();
- $(get_child_id).remove();
- }
- ////当关闭到只剩下首页页签时,要将菜单定位到首页
- if (JSON.parse(replaceArray).length == 1) {
- var gethomefilecutid = JSON.parse(replaceArray)[0].id;
- if ($("body").find(".sp-wrapper-left").length > 0) {
- $("#spWrapperLeftBarUl li:eq(0) .sp-leftmenu-ltitle").each(function (index, item) {
- var getfileid = $(this).parent().attr("id");
- var getfilecutid = getfileid.substring(getfileid.lastIndexOf("_") + 1, getfileid.length);
- if (getfilecutid == gethomefilecutid) {
- if ($("#" + getfileid).parent().attr("class").indexOf("sp-leftmenu-first") != -1) {
- ///仅有一级菜单时
- sp.restoreHomeFirst("#" + getfileid);
- } else if ($("#" + getfileid).parent().attr("class").indexOf("sp-leftmenu-second") != -1) {
- ///含有二级菜单时
- sp.restoreHomeSecond("#" + getfileid);
- } else if ($("#" + getfileid).parent().attr("class").indexOf("sp-leftmenu-third") != -1) { //三级three
- //含有三级菜单时three
- sp.restoreHomeThird("#" + getfileid);
- } else { return; }
- }
- });
- } else if ($("body").find(".sp-wrapper-left-second").length > 0) {
- $("#spLeftBarULTwo li").removeClass("leftbarTwoActive");
- $("#spLeftBarULTwo li:eq(0)").addClass("leftbarTwoActive");
- ///遍历第一级菜单下面的子菜单,分处于二级和三级
- $("#spLeftBarULTwo li:eq(0) a").each(function () {
- if ($(this).find(".lbtitle").length > 0) {
- var getfileid = $(this).attr("id")
- var getfilecutid = getfileid.substring(getfileid.lastIndexOf("_") + 1, getfileid.length);
- if (getfilecutid == gethomefilecutid) {
- var getparentclass = $(this).parent("li").attr("class");
- if (getparentclass.indexOf("sp-leftbar-second") != -1) {
- $(this).parents(".sp-leftbar-first").find("a").removeClass("leftbartitleActive");
- $(this).parents(".sp-leftbar-first").siblings().find("a").removeClass("leftbartitleActive");
- $(this).addClass("leftbartitleActive");
- } else if (getparentclass.indexOf("sp-leftbar-third") != -1) {
- $(this).parents(".sp-leftbar-first").find("a").removeClass("leftbartitleActive");
- $(this).parents(".sp-leftbar-first").siblings().find("a").removeClass("leftbartitleActive");
- $(this).addClass("leftbartitleActive");
- $(this).parents(".sp-leftbar-second").children("a").addClass("leftbartitleActive");
- } else { return; }
- } else {
- return;
- }
- }
- });
- } else {
- return;
- }
- }
- };
- //onclick事件时引用,向首页添加tabs切换书签
- //sp.addTabNav = function (id, title, src) {
- // /// <summary>
- // /// 向首页添加tabs切换书签
- // /// </summary>
- // /// <param name="id">唯一id编码</param>
- // /// <param name="title">标题</param>
- // /// <param name="src">文件路径</param>
- // /// <returns>会生成tabs标题及文件iframe一个</returns>
- // var setID = "wrapper_tabs_box_col_" + id;
- // var set_title = "";
- // var getLen2 = sp.getlength(title); ///汉字算2个字符
- // if (getLen2 > 9) {
- // set_title = sp.cutstr(title, 8);
- // //set_title = title.substring(0, 8) + "..";
- // } else {
- // set_title = title;
- // }
- // if ($("#spWrapperTabsPart .sp-wrapper-tabs-box").children("#" + setID).length < 1) {
- // $("#spWrapperTabsPart ul li").removeClass("sp-wrapper-tabs-current");
- // $(".sp-wrapper-tabs-box-current").hide();
- // $("#spWrapperTabsPart .sp-wrapper-tabs-box .sp-wrapper-tabs-box-col").removeClass("sp-wrapper-tabs-box-current");
- // $("#spWrapperTabsPart ul").append("<li class=\"sp-wrapper-tabs-current\" id=\"wrapper_tabs_menu_li_" + id + "\" data-href=\"#" + setID + "\" title=\"" + title + "\" onclick=\"sp.clickTabNavActive(this)\">" + set_title + "<i class=\"fa fa-times-circle\" onclick=\"sp.closeSingleTabsNav(this)\"></i></li>");
- // $("#spWrapperTabsPart .sp-wrapper-tabs-box").append("<div class=\"sp-wrapper-tabs-box-col sp-wrapper-tabs-box-current\" id=\"" + setID + "\"><iframe src=\"" + src + "\" width=\"100%\" height=\"100%\" frameborder=\"0\" scrolling=\"auto\"></iframe></div>");
- // $("#" + setID).show();
- // sp.savemenufile(id, title, src); ///记录打开的菜单文件
- // sp.pagetabShiftRight();
- // } else {
- // $("#spWrapperTabsPart ul li").removeClass("sp-wrapper-tabs-current");
- // $(".sp-wrapper-tabs-box-current").hide();
- // $("#spWrapperTabsPart .sp-wrapper-tabs-box .sp-wrapper-tabs-box-col").removeClass("sp-wrapper-tabs-box-current");
- // $("#wrapper_tabs_menu_li_" + id).addClass("sp-wrapper-tabs-current").show();
- // $("#" + setID).addClass("sp-wrapper-tabs-box-current").show();
- // $("#" + setID + " iframe").attr("src", src); ////然后让里面的iframe重新加载点击后的页面
- // }
- // sp.fitHeight("iframe",$(".sp-wrapper-head").outerHeight() + $(".sp-wrapper-tabs-head").outerHeight()); //设置iframe的高度
- //};
- //onclick事件时引用,向首页添加tabs切换书签
- /// <summary>
- /// 本方法目的:适应菜单在上侧显示框架----20230224
- /// </summary>
- //sp.addTabNav = function (id, title, src) {
- // $("#indexhd_iframe_fileurl").attr("src", src);
- //}
- sp.addTabNav = function (id, title, src) {
- /// <summary>
- /// 向首页添加tabs切换书签
- /// </summary>
- /// <param name="id">唯一id编码</param>
- /// <param name="title">标题</param>
- /// <param name="src">文件路径</param>
- /// <returns>会生成tabs标题及文件iframe一个</returns>
- var setID = "wrapper_tabs_box_col_" + id;
- if ($("#spWrapperTabsPart .sp-wrapper-tabs-box").find("#" + setID).length < 1) {
- //$(".sp-wrapper-tabs-box-col").hide();
- $("#spWrapperTabsPart .sp-wrapper-tabs-box .sp-wrapper-tabs-box-col").removeClass("sp-wrapper-tabs-box-current");
- $("#spWrapperTabsPart .sp-wrapper-tabs-box").append("<div class=\"sp-wrapper-tabs-box-col sp-wrapper-tabs-box-current\" id=\"" + setID + "\"><iframe id=\"iframe_" + setID + "\" src=\"" + src + "\" width=\"100%\" height=\"100%\" frameborder=\"0\" scrolling=\"auto\"></iframe></div>");
- //$("#" + setID).show();
- sp.fitHeight("#iframe_" + setID + "", $(".sp-wrapper-head").outerHeight() + 30); //设置iframe的高度
- //alert($(".sp-wrapper-head").outerHeight() + 35);
- } else {
- //$(".sp-wrapper-tabs-box-current").hide();
- $(".sp-wrapper-tabs-box-col").removeClass("sp-wrapper-tabs-box-current");
- var get_oldurl = $("#iframe_" + setID + "").attr("src");
- if (get_oldurl != src) {
- $("#" + setID).addClass("sp-wrapper-tabs-box-current");
- //$("#" + setID).show();
- $("#" + setID + " iframe").attr("src", src); ////然后让里面的iframe重新加载点击后的页面
- } else {
- $("#" + setID).addClass("sp-wrapper-tabs-box-current");
- }
- sp.fitHeight("#iframe_" + setID + "", $(".sp-wrapper-head").outerHeight() + 30); //设置iframe的高度
- }
- };
- //根据左侧菜单json动态加载首页第一个home文件20180801
- //让菜单中的排序为第一个的页面以及页面名称显示到第一个,且没有右上关闭图标
- sp.addhometabnav = function (id, title, src) {
- var set_title = "";
- var getLen2 = sp.getlength(title);///汉字算2个字符
- if (getLen2 > 9) {
- set_title = sp.cutstr(title, 8);
- //set_title = title.substring(0, 4) + "..";
- } else {
- set_title = title;
- }
- $("#spWrapperTabsPart ul").append("<li class=\"sp-wrapper-tabs-current\" id=\"wrapper_tabs_menu_li_" + id + "\" data-href=\"#wrapper_tabs_box_col_" + id + "\" title=\"" + title + "\" onclick=\"sp.clickTabNavActive(this)\">" + set_title + "</li>");
- $("#spWrapperTabsPart .sp-wrapper-tabs-box").append("<div class=\"sp-wrapper-tabs-box-col sp-wrapper-tabs-box-current\" id=\"wrapper_tabs_box_col_" + id + "\"><iframe src=\"" + src + "\" width=\"100%\" height=\"100%\" frameborder=\"0\" scrolling=\"auto\"></iframe></div>");
- sp.fitHeight("iframe",$(".sp-wrapper-head").outerHeight() + $(".sp-wrapper-tabs-head").outerHeight()); //设置iframe的高度
- ////加载第一个菜单作为home文件时都判断并添加home文件--start,
- var fileJsonObj = { "id": id, "title": title, "src": src };
- if (localStorage.getItem("GlWorkPlatform-openfileArray") == undefined || localStorage.getItem("GlWorkPlatform-openfileArray") == null) {
- var openFileArray = [];
- openFileArray.push(fileJsonObj);
- localStorage.setItem("GlWorkPlatform-openfileArray", JSON.stringify(openFileArray)); //localStorage默认的是字符型,因此需要将json串转成字符型
- } else {
- var hashomechange = 0;
- var getopenfilearry = localStorage.getItem("GlWorkPlatform-openfileArray");//取出菜单文件数据
- $.each(JSON.parse(getopenfilearry), function (index, item) {
- if (item.id == id) {
- //说明存在第一个页签
- hashomechange = 1;
- }
- });
- ///home文件已经发生变化
- if (hashomechange == 0) {
- var openFileArray = [];
- openFileArray.push(fileJsonObj);
- localStorage.removeItem("GlWorkPlatform-openfileArray");
- localStorage.setItem("GlWorkPlatform-openfileArray", JSON.stringify(openFileArray)); //localStorage默认的是字符型,因此需要将json串转成字符型
- } else {
- sp.savemenufile(id, title, src);
- }
- }
- ////--end
- ///将home文件所在的左侧菜单进行激活并展开-start
- setTimeout(function () {
- if ($("body").find(".sp-wrapper-left").length > 0) {
- $("#spWrapperLeftBarUl li:eq(0) .sp-leftmenu-ltitle").each(function (index, item) {
- var get_left_bar_id = $(this).parent().attr("id");
- var getleftbarcutid = get_left_bar_id.substring(get_left_bar_id.lastIndexOf("_") + 1, get_left_bar_id.length);
- if (getleftbarcutid == id) {
- var get_className = $("#" + get_left_bar_id).parent().attr('class');
- if (get_className.indexOf('sp-leftmenu-first') != -1) {
- sp.restoreHomeFirst("#" + get_left_bar_id);
- } else if (get_className.indexOf('sp-leftmenu-second') != -1) {
- ///二级 .two
- sp.restoreHomeSecond("#" + get_left_bar_id);
- } else if (get_className.indexOf('sp-leftmenu-third') != -1) {
- sp.restoreHomeThird("#" + get_left_bar_id);
- } else { return; }
- };
- });
- } else if ($("body").find(".sp-wrapper-left-second").length > 0) {
- $("#spLeftBarULTwo li:eq(0)").addClass("leftbarTwoActive");
- ///遍历第一级菜单下面的子菜单,分处于二级和三级
- $("#spLeftBarULTwo li:eq(0) a").each(function () {
- if ($(this).find(".lbtitle").length > 0) {
- var getfileid = $(this).attr("id")
- var getfilecutid = getfileid.substring(getfileid.lastIndexOf("_") + 1, getfileid.length);
- //var getlbtitle = $(".lbtitle", this).text();
- if (getfilecutid == id) {
- var getparentclass = $(this).parent("li").attr("class");
- if (getparentclass.indexOf("sp-leftbar-second") != -1) {
- $(this).parents(".sp-leftbar-first").find("a").removeClass("leftbartitleActive");
- $(this).parents(".sp-leftbar-first").siblings().find("a").removeClass("leftbartitleActive");
- $(this).addClass("leftbartitleActive");
- } else if (getparentclass.indexOf("sp-leftbar-third") != -1) {
- $(this).parents(".sp-leftbar-first").find("a").removeClass("leftbartitleActive");
- $(this).parents(".sp-leftbar-first").siblings().find("a").removeClass("leftbartitleActive");
- $(this).addClass("leftbartitleActive");
- $(this).parents(".sp-leftbar-second").children("a").addClass("leftbartitleActive");
- } else { return;}
- } else {
- return;
- }
- }
- });
- } else {
- }
-
- },5);
- //-end
- };
- ////根据传过来的json数据动态生成框架风格一五级菜单
- sp.dynamicLeftMenu = function (jsondata) {
- var res = JSON.parse(jsondata);
- $.each(res.rows, function (index, item) {
- if (typeof item.C_H_I_L_D == "undefined" || item.C_H_I_L_D.length < 1) {
- if (item.OPENTYPE == "_blank") {
- $("#spWrapperLeftBarUl").append("<li class=\"sp-leftmenu-first\"><a id=\"leftBar_first_" + item.PKID + "\" href=\"" + item.FILEN + "\" title=\"" + item.CNAME + "\" target=\"" + item.OPENTYPE + "\"><i class=\"" + item.SRCIMG + "\"></i><span class=\"sp-leftmenu-ltitle\">" + item.CNAME + "</span></a></li>");
- } else {
- $("#spWrapperLeftBarUl").append("<li class=\"sp-leftmenu-first\"><a id=\"leftBar_first_" + item.PKID + "\" onclick=\"sp.addTabNav('" + item.PKID + "', '" + item.CNAME + "', '" + item.FILEN + "');\" title=\"" + item.CNAME + "\"><i class=\"" + item.SRCIMG + "\"></i><span class=\"sp-leftmenu-ltitle\">" + item.CNAME + "</span></a></li>");
- }
- } else {
- var setSecondAll = "";
- var setFirstMenu = "<li class=\"sp-leftmenu-first\"><a id=\"leftBar_first_" + item.PKID + "\" title=\"" + item.CNAME + "\"><i class=\"icon " + item.SRCIMG + "\"></i><span class=\"sp-leftmenu-ltitle\">" + item.CNAME + "</span><span class=\"sp-leftmenu-icon\"><i class=\"sub-logo icon-left-open\"></i><i class=\"sub-logo-hide icon-down-open\"></i></span></a>";
- $.each(item.C_H_I_L_D, function (index2, item2) {
- //alert(item2.C_H_I_L_D);
- if (typeof item2.C_H_I_L_D == "undefined" || item2.C_H_I_L_D.length < 1) {
- if (item2.OPENTYPE == "_blank") {
- setSecondAll += "<li class=\"sp-leftmenu-second\"><a id=\"leftBar_second_" + item2.PKID + "\" href=\"" + item2.FILEN + "\" title=\"" + item2.CNAME + "\" target=\"" + item2.OPENTYPE + "\"><span class=\"sp-leftmenu-ltitle\">" + item2.CNAME + "</span></a></li>";
- } else {
- setSecondAll += "<li class=\"sp-leftmenu-second\"><a id=\"leftBar_second_" + item2.PKID + "\" onclick=\"sp.addTabNav('" + item2.PKID + "', '" + item2.CNAME + "', '" + item2.FILEN + "');\" title=\"" + item2.CNAME + "\"><span class=\"sp-leftmenu-ltitle\">" + item2.CNAME + "</span></a></li>";
- }
- } else {
- var getThrdAll = "";
- var setSecondSingle = "<li class=\"sp-leftmenu-second\"><a id=\"leftBar_second_" + item2.PKID + "\"' title='" + item2.CNAME + "'><span class='sp-leftmenu-ltitle'>" + item2.CNAME + "</span><span class=\"sp-leftmenu-icon\"><i class=\"sub-logo icon-left-open\"></i><i class=\"sub-logo-hide icon-down-open\"></i></span></a>";
- $.each(item2.C_H_I_L_D, function (index3, item3) {
- //alert(item3.C_H_I_L_D);
- if (item3.C_H_I_L_D == undefined || item3.C_H_I_L_D.length < 1) {
- if (item3.OPENTYPE == "_blank") {
- getThrdAll += "<li class=\"sp-leftmenu-third\"><a id=\"leftBar_third_" + item3.PKID + "\" href=\"" + item3.FILEN + "\" title='" + item3.CNAME + "' target=\"" + item3.OPENTYPE + "\"><span class=\"sp-leftmenu-ltitle\">" + item3.CNAME + "</span></a></li>"
- } else {
- getThrdAll += "<li class=\"sp-leftmenu-third\"><a id=\"leftBar_third_" + item3.PKID + "\" onclick=\"sp.addTabNav('" + item3.PKID + "', '" + item3.CNAME + "', '" + item3.FILEN + "')\" title='" + item3.CNAME + "'><span class=\"sp-leftmenu-ltitle\">" + item3.CNAME + "</span></a></li>"
- }
- } else {
- var setFourthAll = "";
- var getThirdSingle = "<li class='sp-leftmenu-third'><a id=\"leftBar_third_" + item3.PKID + "\" title='" + item3.CNAME + "'><span class='sp-leftmenu-ltitle'>" + item3.CNAME + "</span><span class=\"sp-leftmenu-icon\"><i class=\"sub-logo icon-left-open\"></i><i class=\"sub-logo-hide icon-down-open\"></i></span></a>";
- $.each(item3.C_H_I_L_D, function (index4, item4) {
- if (item4.C_H_I_L_D == undefined || item4.C_H_I_L_D.length < 1) {
- if (item4.OPENTYPE == "_blank") {
- setFourthAll += "<li class=\"sp-leftmenu-fourth\"><a id=\"leftBar_fourth_" + item4.PKID + "\" href=\"" + item4.FILEN + "\" title=\"" + item4.CNAME + "\" target=\"" + item4.OPENTYPE + "\"><span class=\"sp-leftmenu-ltitle\">" + item4.CNAME + "</span></a></li>";
- } else {
- setFourthAll += "<li class=\"sp-leftmenu-fourth\"><a id=\"leftBar_fourth_" + item4.PKID + "\" onclick=\"sp.addTabNav('" + item4.PKID + "', '" + item4.CNAME + "', '" + item4.FILEN + "');\" title=\"" + item4.CNAME + "\"><span class=\"sp-leftmenu-ltitle\">" + item4.CNAME + "</span></a></li>";
- }
- } else {
- var setFifthAll = "";
- var setFourthSingle = "<li class=\"sp-leftmenu-fourth\"><a id=\"leftBar_fourth_" + item4.PKID + "\" title=\"" + item4.CNAME + "\"><span class=\"sp-leftmenu-ltitle\">" + item4.CNAME + "</span><span class=\"sp-leftmenu-icon\"><i class=\"sub-logo icon-left-open\"></i><i class=\"sub-logo-hide icon-down-open\"></i></span></a>";
- $.each(item4.C_H_I_L_D, function (index5, item5) {
- if (item5.OPENTYPE == "_blank") {
- setFifthAll += "<li class=\"sp-leftmenu-fifth\"><a id=\"leftBar_fifth_" + item5.PKID + "\" href=\"" + item5.FILEN + "\" title=\"" + item5.CNAME + "\" target=\"" + item5.OPENTYPE + "\"><span class=\"sp-leftmenu-ltitle\">" + item5.CNAME + "</span></a></li>";
- } else {
- setFifthAll += "<li class=\"sp-leftmenu-fifth\"><a id=\"leftBar_fifth_" + item5.PKID + "\" onclick=\"sp.addTabNav('" + item5.PKID + "', '" + item5.CNAME + "', '" + item5.FILEN + "');\" title=\"" + item5.CNAME + "\"><span class=\"sp-leftmenu-ltitle\">" + item5.CNAME + "</span></a></li>";
- }
- });
- setFourthAll += setFourthSingle + "<ul>" + setFifthAll + "</ul></li>";
- }
- });
- getThrdAll += getThirdSingle + "<ul>" + setFourthAll + "</ul></li>";
- }
- });
- setSecondAll += setSecondSingle + "<ul>" + getThrdAll + "</ul></li>";
- }
- });
- var setChild = setFirstMenu + "<ul>" + setSecondAll + "</ul></li>";
- //console.log(setChild);
- $("#spWrapperLeftBarUl").append(setChild);
- }
- });
- //////让菜单中的排序为第一个的页面以及页面名称显示到第一个,且没有右上关闭图标-----start
- if (typeof res.rows[0].C_H_I_L_D == "undefined" || res.rows[0].C_H_I_L_D.length < 1) {
- ///若没有子节点
- var title = res.rows[0].CNAME;
- var id = res.rows[0].PKID;
- var src = res.rows[0].FILEN;
- sp.addhometabnav(id, title, src); ///将左侧菜单第一个设为home的tab签
- } else if (typeof res.rows[0].C_H_I_L_D[0].C_H_I_L_D == "undefined" || res.rows[0].C_H_I_L_D[0].C_H_I_L_D.length < 1) {
- ///如有子节点-二级
- var title = res.rows[0].C_H_I_L_D[0].CNAME;
- var id = res.rows[0].C_H_I_L_D[0].PKID;
- var src = res.rows[0].C_H_I_L_D[0].FILEN;
- sp.addhometabnav(id, title, src);///将左侧菜单第一个设为home的tab签
- } else {
- //三级
- var title = res.rows[0].C_H_I_L_D[0].C_H_I_L_D[0].CNAME;
- var id = res.rows[0].C_H_I_L_D[0].C_H_I_L_D[0].PKID;
- var src = res.rows[0].C_H_I_L_D[0].C_H_I_L_D[0].FILEN;
- sp.addhometabnav(id, title, src);///将左侧菜单第一个设为home的tab签
- }
- ///////-----end
- setTimeout(function () {
- //sp.loadmenufiles();//加载记录菜单文件
- sp.setLeftMenu(); ///操作左侧五级菜单
- }, 300);
- /////----end
- };
- ////层里面设置多个div
- sp.tabscoliframeset = function (id, title, src) {
- var get_current_id = $(".sp-wrapper-tabs-box-current").attr("id").split("wrapper_tabs_box_col_")[1];
- var setID = "spwrappertabsboxcoliframelayer_" + get_current_id + "_" + id;
- if ($(".sp-wrapper-tabs-box-current").find("#" + setID).length < 1) {
- var get_iframelength = $(".sp-wrapper-tabs-box-current").find("iframe").length;
- //console.log(get_iframelength);
- var set_width_1 = 0, set_width_2 = 0;
- if (get_iframelength == 1) {
- set_width_1 = "33.333%"; set_width_2 = "65.666%";
- } else if (get_iframelength == 2) {
- set_width_1 = "33.333%"; set_width_2 = "32.333%";
- } else if (get_iframelength == 3) {
- set_width_1 = "30%"; set_width_2 = "22.333%";
- } else if (get_iframelength == 4) {
- set_width_1 = "30%"; set_width_2 = "16.5%";
- } else {
- set_width_1 = "30%"; set_width_2 = "13%";
- }
- $(".sp-wrapper-tabs-box-current iframe:eq(0)").css("width", set_width_1);
- $(".sp-wrapper-tabs-box-current").find(".sp-wrapper-tabs-box-col-iframelayer").removeClass("sp-wrapper-tabs-box-col-iframelayer-curent");
- var setiframe = "<div class=\"sp-wrapper-tabs-box-col-iframelayer sp-wrapper-tabs-box-col-iframelayer-curent\" id=\"" + setID + "\"><div class=\"sp-wrapper-tabs-box-col-iframelayer-close\" onclick=\"sp.tabscoliframesetClose('" + setID + "')\">×</div><iframe id=\"iframe_" + setID + "\" src=\"" + src + "\" width=\"100%\" height=\"100%\" frameborder=\"0\" scrolling=\"auto\"></iframe></div>";
- $(".sp-wrapper-tabs-box-current").append(setiframe);
- sp.fitHeight("iframe", $(".sp-wrapper-head").outerHeight() + $(".sp-wrapper-tabs-head").outerHeight()); //设置iframe的高度
- $(".sp-wrapper-tabs-box-current").find(".sp-wrapper-tabs-box-col-iframelayer").css("width", set_width_2);
- $(".sp-wrapper-tabs-box-current").find(".sp-wrapper-tabs-box-col-iframelayer").each(function () {
- $(this).click(function () {
- $(this).addClass("sp-wrapper-tabs-box-col-iframelayer-curent").siblings().removeClass("sp-wrapper-tabs-box-col-iframelayer-curent");
- });
- });
- setTimeout(function () {
- $("#" + setID).resizable({
- handles: "e,w",
- minWidth: 100,
- minHeight: 300,
- resize: function (event, ui) {
- //self.settopWorkLayer(event.target);
- //$(event.target).find('.gmt-work-mask').show();
- //var set_wid = "";
- //if (get_iframelength >1){
- // set_wid = ($(".sp-wrapper-tabs-box-current").width() / 2 - 10 * get_iframelength - $("#" + setID).width()) / get_iframelength;
- //}
- //$("#" + setID).siblings(".sp-wrapper-tabs-box-col-iframelayer").css("width", "" + set_wid + "%");
- },
- stop: function (event, ui) {
- //$(event.target).find('.gmt-work-mask').hide();
- }
- });
- }, 1000)
- }
- };
- sp.tabscoliframesetClose = function (idnum) {
- //alert(idnum);
- $(".sp-wrapper-tabs-box-current").find("#" + idnum).remove();
- if ($(".sp-wrapper-tabs-box-current").find("iframe").length < 2) {
- $(".sp-wrapper-tabs-box-current iframe:eq(0)").css("width", "100%");
- }
- };
- ///打开页签操作part
- sp.setpagetab = function () {
- $(".sp-pagetab-close").on("click", function (e) {
- if ($(".sp-pagetab-close").hasClass("hasclick")) {
- $(".sp-pagetab-close").removeClass("hasclick");
- $(".sp-pagetab-closepart").fadeOut(200);
- } else {
- $(".sp-pagetab-close").addClass("hasclick");
- $(".sp-pagetab-closepart").fadeIn(200);
- ///若此一直展开处于无操作时,就将页签操作part进行关闭
- setTimeout(function () {
- if ($(".sp-pagetab-closepart").is(":visible")) {
- //alert(1);
- $(".sp-pagetab-close").removeClass("hasclick");
- $(".sp-pagetab-closepart").fadeOut(200);
- }
- }, 10000);
- }
- sp.stopPropagation(e);
- });
- $(document).on('click', function () {
- $(".sp-pagetab-close").removeClass("hasclick");
- $(".sp-pagetab-closepart").fadeOut(200);
- });
- $(".sp-pagetab-close").click(function (e) {
- sp.stopPropagation(e);
- });
- };
- sp.setpagetab();
- ///关闭全部页签20180730
- sp.closePagetab = function () {
- var getopenfilearry = localStorage.getItem("GlWorkPlatform-openfileArray");//取出菜单文件数据
- if (JSON.parse(getopenfilearry).length > 1) {
- var setopenfilearry = getopenfilearry.substring(0, getopenfilearry.indexOf("},") + 1);
- setopenfilearry = setopenfilearry + "]";
- localStorage.setItem("GlWorkPlatform-openfileArray", setopenfilearry);
- if ($(".sp-wrapper-tabs-menu li").length > 1) {
- $(".sp-wrapper-tabs-menu li").each(function (index, item) {
- var gettabsmenuliid = $(this).attr("id");
- var getiframeid = $(this).attr("data-href");//得到iframe的id
- if (index != 0) {
- ///删除首页之外的菜单文件
- $(this).remove();
- $(getiframeid).remove();
- } else {
- ///为第一个加上选中样式
- $("#" + gettabsmenuliid).addClass("sp-wrapper-tabs-current");
- $(getiframeid).show().addClass("sp-wrapper-tabs-box-current");
- var gethometitle = $(this).attr("title");
- var gethomefileid = $(this).attr("id");
- var gethomefilecutid = gethomefileid.substring(gethomefileid.lastIndexOf("_") + 1, gethomefileid.length);
- if ($("body").find(".sp-wrapper-left").length > 0) {
-
- $("#spWrapperLeftBarUl li:eq(0) .sp-leftmenu-ltitle").each(function (index, item) {
- var getfileid = $(this).parent().attr("id");
- var getfilecutid = getfileid.substring(getfileid.lastIndexOf("_") + 1, getfileid.length);
-
- if (getfilecutid == gethomefilecutid) {
- if ($("#" + getfileid).parent().attr("class").indexOf("sp-leftmenu-first") != -1) {
- ///仅有一级菜单时
- sp.restoreHomeFirst("#" + getfileid);
- } else if ($("#" + getfileid).parent().attr("class").indexOf("sp-leftmenu-second") != -1) {
- ///含有有二级菜单时
- sp.restoreHomeSecond("#" + getfileid);
- } else if ($("#" + getfileid).parent().attr("class").indexOf("sp-leftmenu-third") != -1) {
- //三级three
- sp.restoreHomeThird("#" + getfileid);
- } else { return;}
- }
- });
- } else if ($("body").find(".sp-wrapper-left-second").length > 0) {
- $("#spLeftBarULTwo li").removeClass("leftbarTwoActive");
- $("#spLeftBarULTwo li:eq(0)").addClass("leftbarTwoActive");
- ///遍历第一级菜单下面的子菜单,分处于二级和三级
- $("#spLeftBarULTwo li:eq(0) a").each(function () {
- if ($(this).find(".lbtitle").length > 0) {
- var getfileid = $(this).attr("id")
- var getfilecutid = getfileid.substring(getfileid.lastIndexOf("_") + 1, getfileid.length);
- if (getfilecutid == gethomefilecutid) {
- var getparentclass = $(this).parent("li").attr("class");
- if (getparentclass.indexOf("sp-leftbar-second") != -1) {
- $(this).parents(".sp-leftbar-first").find("a").removeClass("leftbartitleActive");
- $(this).parents(".sp-leftbar-first").siblings().find("a").removeClass("leftbartitleActive");
- $(this).addClass("leftbartitleActive");
- } else if (getparentclass.indexOf("sp-leftbar-third") != -1) {
- $(this).parents(".sp-leftbar-first").find("a").removeClass("leftbartitleActive");
- $(this).parents(".sp-leftbar-first").siblings().find("a").removeClass("leftbartitleActive");
- $(this).addClass("leftbartitleActive");
- $(this).parents(".sp-leftbar-second").children("a").addClass("leftbartitleActive");
- } else { return;}
- } else {
- return;
- }
- }
- });
- }else{return;}
- }
- });
- localStorage.removeItem("GlWorkPlatform-setLeftBarClickID");
- }
-
- }
- $(".sp-pagetab-closepart").fadeOut(200);
- };
- ///关闭其他页签,除当前active的20180730
- sp.closePagetabOthers = function () {
- ///得到当前打开项的id
- var get_child_id = $(".sp-wrapper-tabs-current").attr("data-href");
- var getid = get_child_id.substring(get_child_id.lastIndexOf("_") + 1, get_child_id.length);
- var temp = localStorage.getItem("GlWorkPlatform-openfileArray");//取出菜单文件数据
- if (JSON.parse(temp).length > 1) {
- ////将home文件即第一个菜单文件取出
- var gethomefile = temp.substring(0, temp.indexOf("},") + 1);
- gethomefile = gethomefile + "]";
- var sethomefileArray = JSON.parse(gethomefile);
- var gethomefileid = sethomefileArray[0].id; ///得到home文件的id编号
- ////进行比对
- if (getid == gethomefileid) {
- ///tabs签停在首页home时,将其他删除并清空记录
- if ($(".sp-wrapper-tabs-menu li").length > 1) {
- $(".sp-wrapper-tabs-menu li").each(function (index, item) {
- if (index != 0) {
- ///删除首页之外的菜单文件
- var getiframeid = $(this).attr("data-href");//得到iframe的id
- $(this).remove();
- $(getiframeid).remove();
- }
- });
- }
- //alert(gethomefile);
- localStorage.setItem("GlWorkPlatform-openfileArray", gethomefile);
- } else {
- ///tabs签没有停留在首页
- if ($(".sp-wrapper-tabs-menu li").length > 1) {
- $(".sp-wrapper-tabs-menu li").each(function (index, item) {
- if (index != 0) {
- ///删除首页之外的菜单文件
- var getiframeid = $(this).attr("data-href");//得到iframe的id
- if (getiframeid != get_child_id) {
- $(this).remove();
- $(getiframeid).remove();
- }
- }
- });
- }
- var tempObj = JSON.parse(temp);//把字符串转换成JSON对象
- var fileJsonObj = "";
- $.each(tempObj, function (index, item) {
- if (item.id == getid) {
- fileJsonObj = { "id": item.id, "title": item.title, "src": item.src }
- }
- });
- var setOtherfilesarray = temp.substring(0, temp.indexOf("},") + 2) + JSON.stringify(fileJsonObj) + "]";
- //alert(setOtherfilesarray);
- localStorage.setItem("GlWorkPlatform-openfileArray", setOtherfilesarray);
- }
- }
- $(".sp-wrapper-tabs-closepart").fadeOut(200);
- };
- //刷新当前页签
- sp.reloadPagetabCurrent = function () {
- var geturl = "";
- var getid = $(".sp-wrapper-tabs-menu .sp-wrapper-tabs-current").attr("data-href");
- geturl = $(getid + " iframe").attr("src");
- if (geturl.indexOf("?") != -1 && geturl.indexOf("?time") == -1) {
- //若含有?问号,并且没有找到?time,即文件路径含有其他参数,加上time时间戳加载后面
- if (geturl.indexOf("&time") != -1) {
- //含有时间戳
- var cuturl = geturl.substring(0, geturl.indexOf("&time")); ///先截取
- geturl = cuturl + "&time=" + new Date().getTime();
- } else {
- ///没有时间戳
- geturl = geturl + "&time=" + new Date().getTime(); ///直接在后面加上时间戳
- }
- } else if (geturl.indexOf("?time") != -1) {
- ///若第一个参数就是?time,即上次加了时间戳
- var cuturl = geturl.substring(0, geturl.indexOf("?"));
- geturl = cuturl + "?time=" + new Date().getTime();
- } else if (geturl.indexOf("?") == -1) {
- //若无参数,也无?就直接加上时间戳
- geturl = geturl + "?time=" + new Date().getTime();
- } else { return; }
- $(getid + " iframe").attr("src", geturl);
- $(".sp-pagetab-closepart").fadeOut(200);
- };
- ////打开页面时加载记录菜单文件20180801
- sp.loadmenufiles = function () {
- var temp = localStorage.getItem("GlWorkPlatform-openfileArray");//取出文件数据
- var tempObj = JSON.parse(temp);//把字符串转换成JSON对象
- var gethomefiletitle = tempObj[0].title;//得到home文件名称标题
- if (tempObj.length > 1) {
- var dialogHead = "<span class=\"sp-dialog-head\"><span class=\"sp-dialog-tip\">您好</span><span class=\"sp-dialog-close sp-closeDialog\" title=\"关闭\">×</span></span>";
- var dialogBody = "<div class=\"sp-dialog-body\">是否打开上次浏览的菜单页签?</div>";
- var dialogFoot = "<div class=\"sp-dialog-foot\"><button id='delDataTrue' class='sp-dialog-btnTrue'><i class='icon-check'> </i> 打开</button><button class='sp-dialog-btnCancle sp-closeDialog'><i class='icon-cancel'> </i> 取消</button></div>";
- $('.sp-dialog').html(dialogHead + dialogBody + dialogFoot);
- sp.openCenter(".sp-dialog");
- ///取消按钮
- $('.sp-closeDialog').click(function (event) {
- sp.dialoghide();
- var getopenfilearry = localStorage.getItem("GlWorkPlatform-openfileArray");//取出菜单文件数据
- var setopenfilearry = getopenfilearry.substring(0, getopenfilearry.indexOf("},") + 1);
- setopenfilearry = setopenfilearry + "]";
- localStorage.setItem("GlWorkPlatform-openfileArray", setopenfilearry);
- localStorage.removeItem("GlWorkPlatform-setLeftBarClickID");
- return false;
- event.preventDefault();
- event.stopPropagation();
- });
- ///确认按钮
- $("#delDataTrue").click(function () {
- ///从localStorage中取出点击左侧菜单的激活id
- var cookiemenuid = localStorage.getItem("GlWorkPlatform-setLeftBarClickID") || 0;
- var setcookiemenuid = "";
- if (cookiemenuid == 0) {
- setcookiemenuid == 0;
- } else {
- setcookiemenuid = cookiemenuid.substring(cookiemenuid.lastIndexOf("_") + 1, cookiemenuid.length);
- }
- sp.dialoghide();
- $.each(tempObj, function (index, item) {
- if (index != 0) {
- var get_file_id = item.id;
- var get_file_title = item.title;
- var get_file_src = item.src;
- var setID = "wrapper_tabs_box_col_" + get_file_id;
- var set_title = "";
- var getLen2 = sp.getlength(get_file_title); ///汉字算2个字符
- if (getLen2 > 9) {
- set_title = sp.cutstr(get_file_title, 8);
- } else {
- set_title = get_file_title;
- }
- if (get_file_id != setcookiemenuid) {
- //菜单文件记录没有当前激活左侧菜单
- $("#spWrapperTabsPart ul").append("<li class=\"\" id=\"wrapper_tabs_menu_li_" + get_file_id + "\" data-href=\"#" + setID + "\" title=\"" + get_file_title + "\" onclick=\"sp.clickTabNavActive(this)\">" + set_title + "<i class=\"fa fa-times-circle\" onclick=\"sp.closeSingleTabsNav(this)\"></i></li>");
- $("#spWrapperTabsPart .sp-wrapper-tabs-box").append("<div class=\"sp-wrapper-tabs-box-col\" id=\"" + setID + "\"><iframe src=\"" + get_file_src + "\" width=\"100%\" height=\"100%\" frameborder=\"0\" scrolling=\"auto\"></iframe></div>");
- } else {
- ///菜单文件记录有当前激活左侧菜单
- sp.setLeftMenuActiveByCookie(); ////设置左侧菜单根据localStorage而激活
- $("#spWrapperTabsPart ul li").removeClass("sp-wrapper-tabs-current");
- $(".sp-wrapper-tabs-box-current").hide();
- $("#spWrapperTabsPart ul").append("<li class=\"sp-wrapper-tabs-current\" id=\"wrapper_tabs_menu_li_" + get_file_id + "\" data-href=\"#" + setID + "\" title=\"" + get_file_title + "\" onclick=\"sp.clickTabNavActive(this)\">" + set_title + "<i class=\"fa fa-times-circle\" onclick=\"sp.closeSingleTabsNav(this)\"></i></li>");
- $("#spWrapperTabsPart .sp-wrapper-tabs-box").append("<div class=\"sp-wrapper-tabs-box-col sp-wrapper-tabs-box-current\" id=\"" + setID + "\"><iframe src=\"" + get_file_src + "\" width=\"100%\" height=\"100%\" frameborder=\"0\" scrolling=\"auto\"></iframe></div>");
- $("#" + setID).show();
- }
- };
- });
- //sp.closeSingleTabsNav('#spWrapperTabsPart');
- sp.pagetabShiftRight();
- sp.fitHeight("iframe",$(".sp-wrapper-head").outerHeight() + $(".sp-wrapper-tabs-head").outerHeight()); //设置iframe的高度
- });
- };
- };
- /////第二种框架的加载记录菜单文件 20180803
- sp.loadmenufilesTwo = function () {
- var temp = localStorage.getItem("GlWorkPlatform-openfileArray");//取出文件数据
- var tempObj = JSON.parse(temp);//把字符串转换成JSON对象
- var gethomefiletitle = tempObj[0].title;//得到home文件名称标题
- if (tempObj.length > 1) {
- var dialogHead = "<span class=\"sp-dialog-head\"><span class=\"sp-dialog-tip\" style=\"margin-left:0px;\">您好</span><span class=\"sp-dialog-close sp-closeDialog\" title=\"关闭\">×</span></span>";
- var dialogBody = "<div class=\"sp-dialog-body\">是否打开上次浏览的菜单页签?</div>";
- var dialogFoot = "<div class=\"sp-dialog-foot\"><button id='delDataTrue' class='sp-dialog-btnTrue'><i class='icon-check'> </i> 打开</button><button class='sp-dialog-btnCancle sp-closeDialog'><i class='icon-cancel'> </i> 取消</button></div>";
- $('.sp-dialog').html(dialogHead + dialogBody + dialogFoot);
- sp.openCenter(".sp-dialog");
- $('.sp-closeDialog').click(function (event) {
- sp.dialoghide();
- var getopenfilearry = localStorage.getItem("GlWorkPlatform-openfileArray");//取出菜单文件数据
- var setopenfilearry = getopenfilearry.substring(0, getopenfilearry.indexOf("},") + 1);
- setopenfilearry = setopenfilearry + "]";
- localStorage.setItem("GlWorkPlatform-openfileArray", setopenfilearry);
- ///将home文件所在的左侧菜单进行激活并展开-start
- $("#spLeftBarULTwo li:eq(0)").addClass("leftbarTwoActive");
- //-end
- localStorage.removeItem("GlWorkPlatform-setLeftBarClickID");
- return false;
- event.preventDefault();
- event.stopPropagation();
- });
- ///确认按钮
- $("#delDataTrue").click(function () {
- ///从localStorage中取出点击左侧菜单的激活id
- var cookiemenuid = localStorage.getItem("GlWorkPlatform-setLeftBarClickID") || 0;
- var setcookiemenuid = "";
- if (cookiemenuid == 0) {
- setcookiemenuid == 0;
- } else {
- setcookiemenuid = cookiemenuid.substring(cookiemenuid.lastIndexOf("_") + 1, cookiemenuid.length);
- }
- sp.dialoghide();
- $.each(tempObj, function (index, item) {
- if (index != 0) {
- var get_file_id = item.id;
- var get_file_title = item.title;
- var get_file_src = item.src;
- var setID = "wrapper_tabs_box_col_" + get_file_id;
- var set_title = "";
- var getLen2 = sp.getlength(get_file_title); ///汉字算2个字符
- if (getLen2 > 9) {
- set_title = sp.cutstr(get_file_title, 8);
- } else {
- set_title = get_file_title;
- }
- if (get_file_id != setcookiemenuid) {
- //菜单文件记录没有当前激活左侧菜单
- $("#spWrapperTabsPart ul").append("<li class=\"\" id=\"wrapper_tabs_menu_li_" + get_file_id + "\" data-href=\"#" + setID + "\" title=\"" + get_file_title + "\" onclick=\"sp.clickTabNavActive(this)\">" + set_title + "<i class=\"fa fa-times-circle\" onclick=\"sp.closeSingleTabsNav(this)\"></i></li>");
- $("#spWrapperTabsPart .sp-wrapper-tabs-box").append("<div class=\"sp-wrapper-tabs-box-col\" id=\"" + setID + "\"><iframe src=\"" + get_file_src + "\" width=\"100%\" height=\"100%\" frameborder=\"0\" scrolling=\"auto\"></iframe></div>");
- } else {
- ////上面页签选中,对应iframe显示
- $("#spWrapperTabsPart ul li").removeClass("sp-wrapper-tabs-current");
- $(".sp-wrapper-tabs-box-current").hide();
- $("#spWrapperTabsPart ul").append("<li class=\"sp-wrapper-tabs-current\" id=\"wrapper_tabs_menu_li_" + get_file_id + "\" data-href=\"#" + setID + "\" title=\"" + get_file_title + "\" onclick=\"sp.clickTabNavActive(this)\">" + set_title + "<i class=\"fa fa-times-circle\" onclick=\"sp.closeSingleTabsNav(this)\"></i></li>");
- $("#spWrapperTabsPart .sp-wrapper-tabs-box").append("<div class=\"sp-wrapper-tabs-box-col sp-wrapper-tabs-box-current\" id=\"" + setID + "\"><iframe src=\"" + get_file_src + "\" width=\"100%\" height=\"100%\" frameborder=\"0\" scrolling=\"auto\"></iframe></div>");
- $("#" + setID).show();
- ///菜单文件记录有当前激活左侧菜单
- var leftbarfirst = $("#" + cookiemenuid).parents(".sp-leftbar-first");
- leftbarfirst.addClass("leftbarTwoActive").siblings().removeClass("leftbarTwoActive");
- leftbarfirst.find("a").removeClass("leftbartitleActive");
- leftbarfirst.siblings().find("a").removeClass("leftbartitleActive");
- $("#" + cookiemenuid).addClass("leftbartitleActive");
- //判断其上面父级菜单,若有父级菜单则选中
- var getparentclass = $("#" + cookiemenuid).parent("li").attr("class");
- if (getparentclass.indexOf("sp-leftbar-third") != -1) {
- $("#" + cookiemenuid).parents(".sp-leftbar-second").children("a").addClass("leftbartitleActive");
- } else if (getparentclass.indexOf("sp-leftbar-fourth") != -1) {
- $("#" + cookiemenuid).parents(".sp-leftbar-second").children("a").addClass("leftbartitleActive");
- $("#" + cookiemenuid).parents(".sp-leftbar-third").children("a").addClass("leftbartitleActive");
- } else if (getparentclass.indexOf("sp-leftbar-fifth") != -1) {
- $("#" + cookiemenuid).parents(".sp-leftbar-second").children("a").addClass("leftbartitleActive");
- $("#" + cookiemenuid).parents(".sp-leftbar-third").children("a").addClass("leftbartitleActive");
- $("#" + cookiemenuid).parents(".sp-leftbar-fourth").children("a").addClass("leftbartitleActive");
- } else { return; }
- }
- };
- });
- //sp.closeSingleTabsNav('#spWrapperTabsPart');
- sp.pagetabShiftRight();
- sp.fitHeight("iframe",$(".sp-wrapper-head").outerHeight() + $(".sp-wrapper-tabs-head").outerHeight()); //设置iframe的高度
- })
- }
- };
- /////第二种框架根据json数据生成五级菜单 20180803
- sp.dynamicLeftBar = function (jsondata) {
- var res = JSON.parse(jsondata);
- $.each(res.rows, function (index, item) {
- if (typeof item.C_H_I_L_D == "undefined" || item.C_H_I_L_D.length < 1) {
- if (item.OPENTYPE == "_blank") {
- $("#spLeftBarULTwo").append("<li class=\"sp-leftbar-first\"><a id=\"leftBar_first_" + item.PKID + "\" href=\"" + item.FILEN + "\" title=\"" + item.CNAME + "\" target=\"" + item.OPENTYPE + "\"><span class=\"sp-leftbar-first-up\"><i class=\"" + item.SRCIMG + "\"></i></span><span class=\"sp-leftbar-first-down\">" + item.CNAME + "</span></a></li>");
- } else {
- $("#spLeftBarULTwo").append("<li class=\"sp-leftbar-first\"><a id=\"leftBar_first_" + item.PKID + "\" onclick=\"sp.addTabNav('" + item.PKID + "', '" + item.CNAME + "', '" + item.FILEN + "');\" title=\"" + item.CNAME + "\"><span class=\"sp-leftbar-first-up\"><i class=\"" + item.SRCIMG + "\"></i></span><span class=\"sp-leftbar-first-down\">" + item.CNAME + "</span></a></li>");
- }
- } else {
- var setSecondAll = "";
- var setFirstMenu = "<li class=\"sp-leftbar-first\"><a id=\"leftBar_first_" + item.PKID + "\" title=\"" + item.CNAME + "\"><span class=\"sp-leftbar-first-up\"><i class=\"" + item.SRCIMG + "\"></i></span><span class=\"sp-leftbar-first-down\">" + item.CNAME + "</span></a>";
- $.each(item.C_H_I_L_D, function (index2, item2) {
- if (typeof item2.C_H_I_L_D == "undefined" || item2.C_H_I_L_D.length < 1) {
- if (item2.OPENTYPE == "_blank") {
- setSecondAll += "<li class=\"sp-leftbar-second\"><a id=\"leftBar_second_" + item2.PKID + "\" href=\"" + item2.FILEN + "\" title=\"" + item2.CNAME + "\" target=\"" + item2.OPENTYPE + "\"><i class=\"icon-right-dir ileft\"></i><span class=\"lbtitle\">" + item2.CNAME + "</span></a></li>";
- } else {
- setSecondAll += "<li class=\"sp-leftbar-second\"><a id=\"leftBar_second_" + item2.PKID + "\" onclick=\"sp.addTabNav('" + item2.PKID + "', '" + item2.CNAME + "', '" + item2.FILEN + "');\" title=\"" + item2.CNAME + "\"><i class=\"icon-right-dir ileft\"></i><span class=\"lbtitle\">" + item2.CNAME + "</span></a></li>";
- }
- } else {
- var getThrdAll = "";
- var setSecondSingle = "<li class=\"sp-leftbar-second\"><a id=\"leftBar_second_" + item2.PKID + "\" title=\"" + item2.CNAME + "\"><i class=\"icon-right-dir ileft\"></i><span class=\"lbtitle\">" + item2.CNAME + "</span><i class=\"icon-right-open iright\"></i></a>";
- $.each(item2.C_H_I_L_D, function (index3, item3) {
- if (item3.C_H_I_L_D == undefined || item3.C_H_I_L_D.length < 1) {
- if (item3.OPENTYPE == "_blank") {
- getThrdAll += "<li class=\"sp-leftbar-third\"><a id=\"leftBar_third_" + item3.PKID + "\" href=\"" + item3.FILEN + "\" target=\"" + item3.OPENTYPE + "\" title=\"" + item3.CNAME + "\"><i class=\"icon-right-dir ileft\"></i><span class=\"lbtitle\">" + item3.CNAME + "</span></a></li>";
- } else {
- getThrdAll += "<li class=\"sp-leftbar-third\"><a id=\"leftBar_third_" + item3.PKID + "\" onclick=\"sp.addTabNav('" + item3.PKID + "', '" + item3.CNAME + "', '" + item3.FILEN + "')\" title=\"" + item3.CNAME + "\"><i class=\"icon-right-dir ileft\"></i><span class=\"lbtitle\">" + item3.CNAME + "</span></a></li>";
- }
- } else {
- var setFourthAll = "";
- var getThirdSingle = "<li class=\"sp-leftbar-third\"><a id=\"leftBar_third_" + item3.PKID + "\" title=\"" + item3.CNAME + "\"><i class=\"icon-right-dir ileft\"></i><span class=\"lbtitle\">" + item3.CNAME + "</span><i class=\"icon-right-open iright\"></i></a>";
- $.each(item3.C_H_I_L_D, function (index4, item4) {
- if (item4.C_H_I_L_D == undefined || item4.C_H_I_L_D.length < 1) {
- if (item4.OPENTYPE == "_blank") {
- setFourthAll += "<li class=\"sp-leftbar-fourth\"><a id=\"leftBar_fourth_" + item4.PKID + "\" href=\"" + item4.FILEN + "\" target=\"" + item4.OPENTYPE + "\" title=\"" + item4.CNAME + "\"><i class=\"icon-right-dir ileft\"></i><span class=\"lbtitle\">" + item4.CNAME + "</span></a></li>";
- } else {
- setFourthAll += "<li class=\"sp-leftbar-fourth\"><a id=\"leftBar_fourth_" + item4.PKID + "\" onclick=\"sp.addTabNav('" + item4.PKID + "', '" + item4.CNAME + "', '" + item4.FILEN + "');\" title=\"" + item4.CNAME + "\"><i class=\"icon-right-dir ileft\"></i><span class=\"lbtitle\">" + item4.CNAME + "</span></a></li>";
- }
- } else {
- var setFifthAll = "";
- var setFourthSingle = "<li class=\"sp-leftbar-fourth\"><a id=\"leftBar_fourth_" + item4.PKID + "\" title=\"" + item4.CNAME + "\"><i class=\"icon-right-dir ileft\"></i><span class=\"lbtitle\">" + item4.CNAME + "</span><i class=\"icon-right-open iright\"></i></a>";
- $.each(item4.C_H_I_L_D, function (index5, item5) {
- if (item5.OPENTYPE == "_blank") {
- setFifthAll += "<li class=\"sp-leftbar-fifth\"><a id=\"leftBar_fifth_" + item5.PKID + "\" href=\"" + item5.FILEN + "\" target=\"" + item5.OPENTYPE + "\" title=\"" + item5.CNAME + "\"><i class=\"icon-right-dir ileft\"></i><span class=\"lbtitle\">" + item5.CNAME + "</span></a></li>";
- } else {
- setFifthAll += "<li class=\"sp-leftbar-fifth\"><a id=\"leftBar_fifth_" + item5.PKID + "\" onclick=\"sp.addTabNav('" + item5.PKID + "', '" + item5.CNAME + "', '" + item5.FILEN + "');\" title=\"" + item5.CNAME + "\"><i class=\"icon-right-dir ileft\"></i><span class=\"lbtitle\">" + item5.CNAME + "</span></a></li>";
- }
- });
- setFourthAll += setFourthSingle + "<ul>" + setFifthAll + "</ul></li>";
- }
- });
- getThrdAll += getThirdSingle + "<ul>" + setFourthAll + "</ul></li>";
- }
- });
- setSecondAll += setSecondSingle + "<ul>" + getThrdAll + "</ul></li>";
- }
- });
- var setChild = setFirstMenu + "<ul>" + setSecondAll + "</ul></li>";
- //console.log(setChild);
- $("#spLeftBarULTwo").append(setChild);
- }
- });
- //////让菜单中的排序为第一个的页面以及页面名称显示到第一个,且没有右上关闭图标-----start
- if (typeof res.rows[0].C_H_I_L_D == "undefined" || res.rows[0].C_H_I_L_D.length < 1) {
- ///若没有子节点
- var title = res.rows[0].CNAME;
- var id = res.rows[0].PKID;
- var src = res.rows[0].FILEN;
- sp.addhometabnav(id, title, src); ///将左侧菜单第一个设为home的tab签
- } else if (typeof res.rows[0].C_H_I_L_D[0].C_H_I_L_D == "undefined" || res.rows[0].C_H_I_L_D[0].C_H_I_L_D.length < 1) {
- ///如有子节点-二级
- var title = res.rows[0].C_H_I_L_D[0].CNAME;
- var id = res.rows[0].C_H_I_L_D[0].PKID;
- var src = res.rows[0].C_H_I_L_D[0].FILEN;
- sp.addhometabnav(id, title, src);///将左侧菜单第一个设为home的tab签
- } else {
- //三级
- var title = res.rows[0].C_H_I_L_D[0].C_H_I_L_D[0].CNAME;
- var id = res.rows[0].C_H_I_L_D[0].C_H_I_L_D[0].PKID;
- var src = res.rows[0].C_H_I_L_D[0].C_H_I_L_D[0].FILEN;
- sp.addhometabnav(id, title, src);///将左侧菜单第一个设为home的tab签
- }
- ///////-----end
- //延时
- setTimeout(function () {
- //sp.loadmenufilesTwo(); ///加载记录菜单文件
- ////点击leftbar时一级菜单加上选中
- $(".sp-leftbar .sp-leftbar-first").each(function () {
- $(this).click(function () {
- $(this).addClass("leftbarTwoActive").siblings().removeClass("leftbarTwoActive");
- });
- });
- ///点击后记录其标题id存入localStorage
- $("#spLeftBarULTwo a").each(function () {
- $(this).click(function () {
- var get_clickID = $(this).attr("id");
- localStorage.setItem("GlWorkPlatform-setLeftBarClickID", get_clickID);
- //为子菜单标题加上选中
- if ($(this).find(".lbtitle").length > 0) {
- $(this).parents(".sp-leftbar-first").find("a").removeClass("leftbartitleActive");
- $(this).parents(".sp-leftbar-first").siblings().find("a").removeClass("leftbartitleActive");
- $(this).addClass("leftbartitleActive");
- //判断其上面父级菜单,若有父级菜单则选中
- var getparentclass = $(this).parent("li").attr("class");
- if (getparentclass.indexOf("sp-leftbar-third") != -1) {
- $(this).parents(".sp-leftbar-second").children("a").addClass("leftbartitleActive");
- } else if (getparentclass.indexOf("sp-leftbar-fourth") != -1) {
- $(this).parents(".sp-leftbar-second").children("a").addClass("leftbartitleActive");
- $(this).parents(".sp-leftbar-third").children("a").addClass("leftbartitleActive");
- } else if (getparentclass.indexOf("sp-leftbar-fifth") != -1) {
- $(this).parents(".sp-leftbar-second").children("a").addClass("leftbartitleActive");
- $(this).parents(".sp-leftbar-third").children("a").addClass("leftbartitleActive");
- $(this).parents(".sp-leftbar-fourth").children("a").addClass("leftbartitleActive");
- } else { return; }
- } else {
- return;
- }
- });
- });
- }, 300);
- };
- ////页签太多时点击左移按钮向左移动部分20180807
- sp.pagetabShiftLeft = function () {
- var tabsheadwidth = $(".sp-wrapper-tabs-head").outerWidth();
- var getlen1 = $(".sp-wrapper-tabs-menu").children("li").length;
- var settabsheadwidth = parseInt(tabsheadwidth - 190);
- //alert(tabsheadwidth);
- var tabsmenuliwidth = parseInt(getlen1 * 90);
- //alert(tabsmenuliwidth);
- if (tabsmenuliwidth < settabsheadwidth) {
- return false;
- } else {
- $(".sp-wrapper-tabs-menu").animate({
- marginLeft: "40px"
- }, "fast");
- }
- };
- ////页签太多时点击左移按钮向右移动部分20180807
- sp.pagetabShiftRight = function () {
- var tabsheadwidth = $(".sp-wrapper-tabs-head").outerWidth();
- var getlen1 = $(".sp-wrapper-tabs-menu").children("li").length;
- var settabsheadwidth = parseInt(tabsheadwidth - 190);
- //alert(tabsheadwidth);
- var tabsmenuliwidth = parseInt(getlen1 * 90);
- //alert(tabsmenuliwidth);
- if (tabsmenuliwidth < settabsheadwidth) {
- return false;
- } else {
- var getmorenum = Math.ceil(parseInt(tabsmenuliwidth - settabsheadwidth) / 90);
- //alert(getmorenum);
- var shiftleftwidth = getmorenum * 90 + 50;
- $(".sp-wrapper-tabs-menu").animate({
- marginLeft: 0 - shiftleftwidth + "px"
- }, "fast");
- }
- };
- ////获取字符串的长度2018-7-27
- sp.getlength = function (str) {
- ///<summary>获得字符串实际长度,中文2,英文1</summary>
- ///<param name="str">要获得长度的字符串</param>
- var realLength = 0, len = str.length, charCode = -1;
- for (var i = 0; i < len; i++) {
- charCode = str.charCodeAt(i);
- if (charCode >= 0 && charCode <= 128) realLength += 1;
- else realLength += 2;
- }
- return realLength;
- };
- /**
- * js截取字符串,中英文都能用
- * @param str:需要截取的字符串
- * @param len: 需要截取的长度
- */
- sp.cutstr = function (str, len) {
- var str_length = 0;
- var str_len = 0;
- var str_cut = new String();
- str_len = str.length;
- for (var i = 0; i < str_len; i++) {
- a = str.charAt(i);
- str_length++;
- if (escape(a).length > 4) {
- //中文字符的长度经编码之后大于4
- str_length++;
- }
- str_cut = str_cut.concat(a);
- if (str_length >= len) {
- str_cut = str_cut.concat("..");
- return str_cut;
- }
- }
- //如果给定字符串小于指定长度,则返回源字符串;
- if (str_length < len) {
- return str;
- }
- }
- ////清空cookie: $.cookie('cookie_myskin',null,{expires: -1,path: '/'});
- ////加上cookie: $.cookie("cookie_myskin", "123456", { path: '/', expires: 2 });
- ////接收cookie: var getCookie=$.cookie("cookie_myskin");
- jQuery.cookie = function (name, value, options) {
- /// <summary>设置cookie</summary>
- if (typeof value != 'undefined') { // name and value given, set cookie
- options = options || {};
- if (value === null) {
- value = '';
- options.expires = -1;
- }
- var expires = '';
- if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
- var date;
- if (typeof options.expires == 'number') {
- date = new Date();
- date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
- } else {
- date = options.expires;
- }
- expires = '; expires=' + date.toUTCString();
- }
- var path = options.path ? '; path=' + (options.path) : '';
- var domain = options.domain ? '; domain=' + (options.domain) : '';
- var secure = options.secure ? '; secure' : '';
- document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
- } else {
- var cookieValue = null;
- if (document.cookie && document.cookie != '') {
- var cookies = document.cookie.split(';');
- for (var i = 0; i < cookies.length; i++) {
- var cookie = jQuery.trim(cookies[i]);
- if (cookie.substring(0, name.length + 1) == (name + '=')) {
- cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
- break;
- }
- }
- }
- return cookieValue;
- }
- }
- ////Tabs方法 切换tab选项卡
- /// <summary>选项卡</summary>
- ; (function ($) {
- $.fn.extend({
- settabs: function (options) {
- // 处理参数
- options = $.extend({
- event: 'mouseover',
- timeout: 0,
- auto: 0,
- callback: null
- }, options);
- var self = $(this),
- tabBox = self.children('div.sp-tab-box').children('div'),
- menu = self.children('ul.sp-tab-menu'),
- items = menu.find('li'),
- timer;
- var tabHandle = function (elem) {
- elem.siblings('li').removeClass('sp-tab-current').end().addClass('sp-tab-current');
- tabBox.siblings('div').addClass('sp-tab-hide').end().eq(elem.index()).removeClass('sp-tab-hide');
- },
- delay = function (elem, time) {
- time ? setTimeout(function () { tabHandle(elem); }, time) : tabHandle(elem);
- },
- start = function () {
- if (!options.auto) return;
- timer = setInterval(autoRun, options.auto);
- },
- autoRun = function () {
- var current = menu.find('li.sp-tab-current'),
- firstItem = items.eq(0),
- len = items.length,
- index = current.index() + 1,
- item = index === len ? firstItem : current.next('li'),
- i = index === len ? 0 : index;
- current.removeClass('sp-tab-current');
- item.addClass('sp-tab-current');
- tabBox.siblings('div').addClass('sp-tab-hide').end().eq(i).removeClass('sp-tab-hide');
- };
- items.bind(options.event, function () {
- delay($(this), options.timeout);
- if (options.callback) {
- options.callback(self);
- }
- });
- if (options.auto) {
- start();
- self.hover(function () {
- clearInterval(timer);
- timer = undefined;
- }, function () {
- start();
- });
- }
- sp.settableft();
- sp.settabright();
- return this;
- }
- });
- })(jQuery);
- //////进度条横向20180606
- ;(function ($) {
- if (typeof ($.fn.myProgress) != 'undefined') {
- return false;
- }
- $.fn.myProgress = function (options) {
- initOptions(options);
- $(this).each(function () {
- var this_ = $(this);
- var $percent = $(this).find("div.percent-show>span");
- var progress_in = $(this).find("div.progress-in");
- initCss(options, $(this));
- var t = setInterval(function () {
- $percent.html(parseInt(progress_in.width() / this_.width() * 100))
- }, options.speed / 100);
- progress_in.animate({
- width: options.percent + "%"
- }, options.speed, function () {
- clearInterval(t);
- t = null;
- $percent.html(options.percent);
- options.percent == 100 && progress_in.css("border-sp-radius", 0);
- });
- });
- return $(this);
- }
- function initOptions(options) {
- (!options.hasOwnProperty("speed") || isNaN(options.speed)) && (options.speed = 1000);
- (!options.hasOwnProperty("percent") || isNaN(options.percent)) && (options.percent = 100);
- !options.hasOwnProperty("width") && (options.width = '180px');
- !options.hasOwnProperty("height") && (options.height = '15px');
- !options.hasOwnProperty("direction") && (options.direction = 'left');
- options.fontSize = Math.floor(parseInt(options.height) * 6 / 10) + "px";
- options.lineHeight = options.height;
- }
- function initCss(options, obj) {
- //////设置百分比的数字显示位置
- var setleft = 0;
- if (options.percent == 0) {
- setleft = 0;
- }
- if (options.percent > 0 && options.percent <= 90) {
- setleft = options.percent + "%";
- }
- if (options.percent > 90) {
- setleft = options.percent - 8 + "%";
- }
- obj.css({
- "width": options.width,
- "height": options.height
- }).find("div.percent-show").css({
- "lineHeight": options.lineHeight,
- "fontSize": options.fontSize,
- "left": setleft
- });
- if (options.direction == "right") {
- obj.find("div.progress-in").addClass("direction-right");
- } else {
- obj.find("div.progress-in").addClass("direction-left");
- }
- }
- })(jQuery);
- //
- /*
- *点击非当前显示元素时, 当前显示元素自动隐藏 chenhao 2018/3/15
- * 使用方法
- $('#btn').on("click",function(){
- $('.menu').toggle().autoHide();
- return false;
- });
- * autoHide(speed,callback)
- * speed
- 可选。规定元素从可见到隐藏的速度。默认为 "0"。
- 可能的值:
- 毫秒 (比如 1500)
- "slow"
- "normal"
- "fast"
- 在设置速度的情况下,元素从可见到隐藏的过程中,会逐渐地改变其高度、宽度、外边距、内边距和透明度。
- * callback
- 可选。autoHide 函数执行完之后,要执行的函数。
- **** !! 除非设置了 speed 参数,否则不能设置该参数。
- */
- (function ($) {
- $.fn.autoHide = function (speed, callback) {
- var ele = $(this);
- $(document).on('click', function (e) {
- var e = e || window.event; //浏览器兼容性
- e.target = e.target || e.srcElement;
- if (ele.is(':visible') && (!$(e.target)[0].isEqualNode(ele[0]) && ele.has(e.target).length === 0)) {
- ele.hide(speed, callback);
- }
- // e.stopPropagation();
- // return false;
- });
- return this;
- }
- })(jQuery);
- //iframe自适应内容长度 2016.08.07 setiframe(id);是定义的方法 window.setInterval("setiframe('id')", 10);功能:按照指定的周期(以毫秒计)来调用函数或计算表达式。
- sp.setiframe = function (id) {
- /// <summary>设置iframe自适应嵌套页高度</summary>
- window.setInterval("sp.setiframe_getPageHight('" + id + "')", 10);
- }
- sp.setiframe_getPageHight = function (id) {
- /// <summary>得到iframe嵌套的内容页高度</summary>
- var Iframe = document.getElementById(id);
- try {
- // 声明变量取值
- var bHeight = Iframe.contentWindow.document.body.scrollHeight;
- var dHeight = Iframe.contentWindow.document.documentElement.scrollHeight;
- var height = Math.max(bHeight, dHeight); // 取最大值
- Iframe.height = height;
- } catch (ex) { }
- }
- //javascript 解决IE8兼容 placeholder属性 含password 时间:20160811
- sp.set_placeholder = function () {
- if (!('placeholder' in document.createElement('input'))) {
- function GetStringNumValue(pxstr) {
- return pxstr.substring(0, pxstr.length - 2);
- }
- $('input[placeholder],textarea[placeholder]').each(function () {
- var $element = $(this),
- placeholder = $element.attr('placeholder');
- if ($element.attr('type') != 'password') {//非密码
- $element.css('color', '#cccccc');//placeholder定义文字颜色
- if ($element.val() === "") {
- $element.val(placeholder).addClass('placeholder');
- }
- $element.focus(function () {
- if ($element.val() === placeholder) {
- $element.val("").removeClass('placeholder');
- $element.css('color', '#000'); //获取焦点输入文字颜色
- }
- }).blur(function () { //失去焦点进行判断
- if ($element.val() === "") {
- $element.val(placeholder).addClass('placeholder');
- $element.css('color', '#ccc');
- } else if ($element.val() == placeholder) {
- $element.css('color', '#000');
- } else {
- $element.css('color', '#000');
- }
- }).closest('form').submit(function () {
- if ($element.val() === placeholder) {
- $element.val('');
- }
- });
- }
- //密码框的样式
- else {
- if (placeholder) {
- var elementId = $element.attr('id');
- if (!elementId) {
- var now = new Date();
- elementId = 'lbl_placeholder' + now.getSeconds() + now.getMilliseconds();
- $element.attr('id', elementId);
- }
- }
- // 添加label标签,用于显示placeholder的值
- var $label = $('<label>', {
- html: $element.val() ? '' : placeholder,
- 'for': elementId,
- css: {
- position: 'absolute',
- color: '#cccccc',
- fontSize: $element.css('fontSize'),
- fontFamily: $element.css('fontFamily')
- }
- }, '</label>').insertAfter($element);
- // 绑定事件
- var width = $element.width();
- var width2 = width - 3 + "px";
- var width3 = "-" + width2;
- //alert(width3);
- var _setPosition = function () {
- $label.css({
- position: 'relative',
- top: '',
- left: width3
- });
- };
- var _resetPlaceholder = function () {
- if ($element.val()) { $label.html(null); }
- else {
- _setPosition();
- $label.html(placeholder);
- }
- };
- _setPosition();
- $element.on('focus blur input keyup propertychange resetplaceholder', _resetPlaceholder);
- }
- });
- }
- }
- /**sp.CutTableTd(name);//给Table的Td加3个点和鼠标指向文字去除的文字都显示出来**/
- sp.cutgrid = function (TableID, Len) {
- /// <summary>截取table的文字长度</summary>
- /// <param name="TableID">表格的ID</param>
- /// <param name="Len">需要截取的长度</param>
- /// <returns></returns>
- $(TableID + " tr td").each(function (index, value) {
- var GetText = "";
- if ($(this).children().length > 0) {
- GetText = $(this).contents().text();//获取td中的内容
- GetText = GetText.cutstr(Len); //截取字符串
- $(this).contents().text(GetText);//赋值td中的内容
- }
- else {
- GetText = $(this).text();//获取td中的内容
- GetText = GetText.cutstr(Len); //截取字符串
- $(this).text(GetText);//赋值td中的内容
- }
- });
- };
- //通过正则表达式获取地址栏的参数 var get_name = sp.getUrlName("name");
- sp.getUrlName = function (name) {
- /// <summary>
- /// 获取url中特定的参数
- /// </summary>
- /// <param name="name">具体参数变量名</param>
- /// <returns>返回变量值</returns>
- var result = location.search.match(new RegExp("[\?\&]" + name + "=([^\&]+)", "i"));
- if (result == null || result.length < 1) {
- return "";
- }
- return result[1];
- }
- sp.geturl = function () {
- /// <summary>
- /// 获取url中全部参数
- /// </summary>
- /// <returns>返回数组格式</returns>
- var str = location.href; //取得整个地址栏
- var num = str.indexOf("?")
- str = str.substr(num + 1); //取得所有参数
- var loastr = "";
- var loc = "";
- $.each(str.split('&'), function (index, item) {
- item = item.split('=');
- var name = item[0];
- var val = item[1];
- loastr = "\"" + name + "\":\"" + val + "\",";
- loc += loastr;
- });
- loc = loc.substring(0, loc.length - 1);
- loc = "{" + loc + "}";
- var obj = JSON.parse(loc); //将字符型数组转换为对象
- return obj;
- }
- //设置折叠面板
- sp.setPanel = function () {
- /// <summary>折叠面板</summary>
- if ($("body").find(".sp-panel-folder").length > 0) {
- $('.sp-panel-folder').each(function () {
- $('.sp-panel-head', this).on('click', function () {
- if ($(this).hasClass('click')) {
- $(this).parent().children('.sp-panel-body').slideUp(230);
- $(this).removeClass('click');
- } else {
- $(this).parent().children('.sp-panel-body').slideDown(230);
- $(this).parent().siblings('.sp-panel-folder').children('.sp-panel-body').slideUp(230);
- $(this).parent().siblings('.sp-panel-folder').children('.sp-panel-head').removeClass('click');
- $(this).addClass('click');
- }
- });
- });
- }
- }
- //获取json串的长度 var jsonLen=sp.getJsonLen(jsonData);
- sp.getJsonLen = function (json) {
- /// <summary>获取json串长度</summary>
- var Length = 0;
- for (var item in json) {
- Length++;
- }
- return Length;
- }
- //删除含有特定文字的table某列 table:id或class名,str:特定文字
- sp.delCol = function (table, str) {
- /// <summary>removeTD("#tableTD", "编号");</summary>
- var getindex;
- $("" + table + " thead tr th").each(function () {
- var gettext = $(this).text();
- if (gettext == str) {
- getindex = $(this).index();
- $(this).remove();
- }
- });
- $("" + table + " tbody tr").each(function () {
- $("td:eq(" + getindex + ")", this).remove();
- });
- }
- ////组织事件
- sp.stopPropagation = function (e) {
- /// <summary>阻止浏览器的冒泡</summary>
- var ev = e || window.event;
- if (ev.stopPropagation) {
- ev.stopPropagation();
- }
- else if (window.event) {
- window.event.cancelBubble = true;//兼容IE
- }
- }
- //点击一个按钮显示div,点击div之外的地方div隐藏,点击div之内的地方div不隐藏
- sp.clickDomCloseDiv = function (btn, div) {
- /// <summary>点击按钮显示div,点击页面其他地方div隐藏,点击div阻止冒泡</summary>
- $(btn).on("click", function (e) {
- if ($(btn).hasClass("clickDom")) {
- $(btn).removeClass("clickDom");
- $(div).hide();
- sp.stopPropagation(e);
- } else {
- $(btn).addClass("clickDom");
- $(div).show();
- sp.stopPropagation(e);
- }
- });
- $(document).bind('click', function () {
- $(btn).removeClass("clickDom");
- $(div).hide();
- });
- $(div).click(function (e) {
- sp.stopPropagation(e);
- });
- }
- //类似:[{name:"张三", val:"111"},{name:"张三", val:"111"}]
- sp.serializeJSON = function (str) {
- /// <summary>将序列化的值转成json格式</summary>
- var testJson = decodeURIComponent(str, true);//将数据解码,调用decodeURIComponent(XXX,true);中文会乱码,需要将乱码解码
- var loastr = "";
- var loc = "";
- $.each(testJson.split('&'), function (index, item) {
- item = item.split('=');
- var name = item[0], val = item[1];
- loastr = "{\"dname\":\"" + name + "\", \"dval\":\"" + val + "\"},";
- loc += loastr;
- });
- loc = loc.substring(0, loc.length - 1);
- loc = "[" + loc + "]";
- var obj = JSON.parse(loc);//将字符型数组转换为对象
- return obj;
- }
- //遍历某行下的所有的td,然后将其内容以数组形式返回
- sp.eachTDtoArray = function (rowid) {
- /// <summary>遍历该行td的内容,返回数组</summary>
- var alltdText = "";
- $("#" + rowid + " td").each(function () {
- var getText = $.trim($(this).text());
- alltdText += getText + ",";
- });
- var alltdText2 = alltdText.substring(0, alltdText.length - 2);
- var obj = alltdText2.split(",");
- return obj;
- }
- //设置select框的年月, 程序自动跟据当前年显示20170310
- //赋值年份
- sp.selectYear = function (name) {
- /// <summary>设置select框的年份</summary>
- var getyear = new Date().getFullYear(); //今年
- for (var i = (getyear - 20); i < (getyear + 20); i++) //以今年为准,前30年,后30年
- {
- $(name).append("<option value='" + i + "'>" + i + "</option>");
- }
- $(name).find("option[value='" + getyear + "']").attr("selected", true);
- $(name).val(getyear);
- }
- //赋值月份
- sp.selectMonth = function (name) {
- /// <summary>设置select框的月份</summary>
- var getMonth = new Date().getMonth() + 1; //当前月
- for (var i = 1; i < 13; i++) {
- $(name).append("<option value='" + i + "'>" + i + "</option>");
- }
- $(name).find("option[value='" + getMonth + "']").attr("selected", true);
- $(name).val(getMonth);
- }
- sp.showLocalTime = function (divname) {
- /// <summary>动态显示当地时间</summary>
- var objDate = new Date();
- var str, colorhead, colorfoot;
- var yy = objDate.getYear();
- if (yy < 1900) yy = yy + 1900;
- var MM = objDate.getMonth() + 1;
- if (MM < 10) MM = '0' + MM;
- var dd = objDate.getDate();
- if (dd < 10) dd = '0' + dd;
- var hh = objDate.getHours();
- if (hh < 10) hh = '0' + hh;
- var mm = objDate.getMinutes();
- if (mm < 10) mm = '0' + mm;
- var ss = objDate.getSeconds();
- if (ss < 10) ss = '0' + ss;
- var ww = objDate.getDay();
- if (ww == 0) ww = "星期日";
- if (ww == 1) ww = "星期一";
- if (ww == 2) ww = "星期二";
- if (ww == 3) ww = "星期三";
- if (ww == 4) ww = "星期四";
- if (ww == 5) ww = "星期五";
- if (ww == 6) ww = "星期六";
- str = yy + "年" + MM + "月" + dd + "日 " + hh + ":" + mm + ":" + ss + " " + ww;
- var get_time = str;
- $(divname).html(get_time);
- window.setTimeout("sp.showLocalTime('" + divname + "')", 1000); ///延时1秒执行
- };
- //获取当前时间,格式:2018-1-27 10:47:15
- sp.getLocalDate = function () {
- var objDate = new Date();
- var str, colorhead, colorfoot;
- var yy = objDate.getFullYear();
- var MM = objDate.getMonth() + 1;
- if (MM < 10) MM = '0' + MM;
- var dd = objDate.getDate();
- if (dd < 10) dd = '0' + dd;
- var hh = objDate.getHours();
- if (hh < 10) hh = '0' + hh;
- var mm = objDate.getMinutes();
- if (mm < 10) mm = '0' + mm;
- var ss = objDate.getSeconds();
- if (ss < 10) ss = '0' + ss;
- str = yy + "-" + MM + "-" + dd + " " + hh + ":" + mm + ":" + ss;
- return str;
- };
- //利用当前时间生成yyyymmddhhmmss这样的字符串
- sp.setNumRandom = function () {
- var date = new Date();
- var yyyy = date.getFullYear().toString();
- var MM = date.getMonth() + 1;
- if (MM < 10) MM = '0' + MM;
- var dd = date.getDate();
- if (dd < 10) dd = '0' + dd;
- var hh = date.getHours();
- if (hh < 10) hh = '0' + hh;
- var mm = date.getMinutes();
- if (mm < 10) mm = '0' + mm;
- var ss = date.getSeconds();
- if (ss < 10) ss = '0' + ss;
- var millisecond = date.getMilliseconds(); //获取当前毫秒数(0-999)
- var setTimeStr = yyyy + MM + dd + hh + mm + ss + millisecond;
- return setTimeStr;
- };
- //格式化日期 如:2017-10-10 22:33:32
- sp.format = function (str) {
- if (str == "1900-01-01T00:00:00") {
- str = "";
- return str;
- } else if (str == "0001-01-01T00:00:00") {
- ///这种情况是在做滨旅建管系统时用sqlserver数据库时遇到的
- str = "";
- return str;
- } else if (str == "-") {
- ///在做滨旅建管时存的是—,然后就让其显示—
- str = "-";
- return str;
- } else if (str != undefined && str != "" && str != null) {
- /////如果找到"-",不等于负1
- if (str.toString().indexOf('-') != -1) {
- str = str.replace(/-/g, "/"); //将-替换为/,因为ios与ie浏览器中不支持-和T
- }
- /////如果找到T,不等于负1
- if (str.toString().indexOf('T') != -1) {
- str = str.replace(/T/g, ' '); ///去掉日期中的T,因为ios与ie浏览器中不支持-和T
- }
- /////如果找到".",不等于负1
- if (str.toString().indexOf('.') != -1) {
- str = str.slice(0, str.indexOf(".")); ///如果含有毫秒,就将毫秒去掉
- }
- var formatDate = new Date(Date.parse(str));
- var yy = formatDate.getFullYear();
- var MM = formatDate.getMonth() + 1;
- if (MM < 10) { MM = '0' + MM; }
- var dd = formatDate.getDate();
- if (dd < 10) { dd = '0' + dd; }
- var setDate = yy + "-" + MM + "-" + dd;
- return setDate;
- } else {
- str = "";
- return str;
- }
- };
- ///格式化时间,为年月日时分秒
- sp.formatMinute = function (str) {
- if (str == "1900-01-01T00:00:00") {
- str = "";
- return str;
- } else if (str == "0001-01-01T00:00:00") {
- ///这种情况是在做滨旅建管系统时用sqlserver数据库时遇到的
- str = "";
- return str;
- }
- else if (str != undefined && str != "" && str != null) {
- /////如果找到"-",不等于负1
- if (str.toString().indexOf('-') != -1) {
- str = str.replace(/-/g, "/"); //将-替换为/,因为ios与ie浏览器中不支持-和T
- }
- /////如果找到T,不等于负1
- if (str.toString().indexOf('T') != -1) {
- str = str.replace(/T/g, ' '); ///去掉日期中的T,因为ios与ie浏览器中不支持-和T
- }
- /////如果找到".",不等于负1
- if (str.toString().indexOf('.') != -1) {
- str = str.slice(0, str.indexOf(".")); ///如果含有毫秒,就将毫秒去掉
- }
- var formatDate = new Date(Date.parse(str));
- var yy = formatDate.getFullYear();
- var MM = formatDate.getMonth() + 1;
- if (MM < 10) { MM = '0' + MM; } //去掉前面加0,是为了便于后续的格式化得到年月
- var dd = formatDate.getDate();
- if (dd < 10) { dd = '0' + dd; } //去掉前面加0,是为了便于后续的格式化得到年月
- var hh = formatDate.getHours();
- if (hh < 10) { hh = '0' + hh; }
- var mm = formatDate.getMinutes();
- if (mm < 10) { mm = '0' + mm; }
- var ss = formatDate.getSeconds();
- if (ss < 10) { ss = '0' + ss; }
- var setDate = yy + "-" + MM + "-" + dd + " " + hh + ":" + mm + ":" + ss;
- return setDate;
- } else {
- str = "";
- return str;
- }
- };
- ///格式化时间,显示当前月第一天
- sp.monthfirst = function (str) {
- if (str == "1900-01-01T00:00:00") {
- str = "";
- return str;
- } else if (str == "0001-01-01T00:00:00") {
- ///这种情况是在做滨旅建管系统时用sqlserver数据库时遇到的
- str = "";
- return str;
- }
- else if (str != undefined && str != "" && str != null) {
- /////如果找到"-",不等于负1
- if (str.toString().indexOf('-') != -1) {
- str = str.replace(/-/g, "/"); //将-替换为/,因为ios与ie浏览器中不支持-和T
- }
- /////如果找到T,不等于负1
- if (str.toString().indexOf('T') != -1) {
- str = str.replace(/T/g, ' '); ///去掉日期中的T,因为ios与ie浏览器中不支持-和T
- }
- /////如果找到".",不等于负1
- if (str.toString().indexOf('.') != -1) {
- str = str.slice(0, str.indexOf(".")); ///如果含有毫秒,就将毫秒去掉
- }
- var formatDate = new Date(Date.parse(str));
- var yy = formatDate.getFullYear();
- var MM = formatDate.getMonth() + 1;
- if (MM < 10) { MM = '0' + MM; }
- var returnData = yy + "-" + MM + "-01";
- return returnData;
- } else {
- str = "";
- return str;
- }
- };
- ///格式化时间,显示当前月最后一天
- sp.formatMonthLast = function (str) {
- if (str == "1900-01-01T00:00:00") {
- str = "";
- return str;
- } else if (str == "0001-01-01T00:00:00") {
- ///这种情况是在做滨旅建管系统时用sqlserver数据库时遇到的
- str = "";
- return str;
- }
- else if (str != undefined && str != "" && str != null) {
- /////如果找到"-",不等于负1
- if (str.toString().indexOf('-') != -1) {
- str = str.replace(/-/g, "/"); //将-替换为/,因为ios与ie浏览器中不支持-和T
- }
- /////如果找到T,不等于负1
- if (str.toString().indexOf('T') != -1) {
- str = str.replace(/T/g, ' '); ///去掉日期中的T,因为ios与ie浏览器中不支持-和T
- }
- /////如果找到".",不等于负1
- if (str.toString().indexOf('.') != -1) {
- str = str.slice(0, str.indexOf(".")); ///如果含有毫秒,就将毫秒去掉
- }
- var formatDate = new Date(Date.parse(str));
- var yy = formatDate.getFullYear();
- var MM = formatDate.getMonth() + 1;
- var returnData = sp.getLastDayOfMonth(yy, MM);
- return returnData;
- } else {
- str = "";
- return str;
- }
- };
- /**
- * 获取某年某月的最后一天
- */
- sp.getLastDayOfMonth = function (year, month) {
- //获取本年本月的第一天日期
- var date = new Date(year, month - 1, '01');
- //设置日期
- date.setDate(1);
- //设置月份
- date.setMonth(date.getMonth() + 1);
- //获取本月的最后一天
- cdate = new Date(date.getTime() - 1000 * 60 * 60 * 24);
- //打印某年某月的最后一天
- //alert(cdate.getFullYear() + "年" + (Number(cdate.getMonth()) + 1) + "月最后一天的日期:" + cdate.getDate() + "日");
- var yy = cdate.getFullYear();
- var MM = cdate.getMonth() + 1;
- if (MM < 10) { MM = '0' + MM; }
- var setData = yy + "-" + MM + "-" + cdate.getDate();
- //返回结果
- return setData;
- }
- ////格式化日期获取其年份
- sp.formatGetYear = function (str) {
- var formatDate = new Date(sp.format(str));
- var yy = formatDate.getFullYear();
- return yy;
- }
- ////格式化日期获取其月份
- sp.formatGetMonth = function (str) {
- var formatDate = new Date(sp.format(str));
- var MM = formatDate.getMonth() + 1;
- return MM;
- }
- ////获取当前年份
- sp.currentYear = function () {
- var date = new Date();
- var yyyy = date.getFullYear().toString();
- return yyyy;
- }
- ////获取当前月份
- sp.currentMonth = function () {
- var date = new Date();
- var MM = date.getMonth() + 1;
- return MM;
- }
- /**************************************时间格式化处理************************************/
- ///format格式化缩写为fmt,两个参数,前者是日期格式,后者是日期
- sp.datefmt = function (fmt, date) {
- ///console.log(date);
- if (date == "1900-01-01T00:00:00") {
- date = "";
- return date;
- } else if (date == "0001-01-01T00:00:00") {
- ///这种情况是在做滨旅建管系统时用sqlserver数据库时遇到的
- date = "";
- return date;
- } else if (date == "-") {
- ///在做滨旅建管时存的是—,然后就让其显示—
- date = "-";
- return date;
- } else if (date != undefined && date != "" && date != null) {
- /////如果找到"-",不等于负1
- if (date.toString().indexOf('-') != -1) {
- date = date.replace(/-/g, "/"); //将-替换为/,因为ios与ie浏览器中不支持-和T
- }
- /////如果找到T,不等于负1
- if (date.toString().indexOf('T') != -1) {
- date = date.replace(/T/g, ' '); ///去掉日期中的T,因为ios与ie浏览器中不支持-和T
- }
- /////如果找到".",不等于负1
- if (date.toString().indexOf('.') != -1) {
- date = date.slice(0, date.indexOf(".")); ///如果含有毫秒,就将毫秒去掉
- }
- var formatDate = new Date(Date.parse(date));
- var o = {
- "M+": formatDate.getMonth() + 1, //月份
- "d+": formatDate.getDate(), //日
- "H+": formatDate.getHours(), //小时
- "m+": formatDate.getMinutes(), //分
- "s+": formatDate.getSeconds(), //秒
- "q+": Math.floor((formatDate.getMonth() + 3) / 3), //季度
- "S": formatDate.getMilliseconds() //毫秒
- };
- if (/(y+)/.test(fmt))
- fmt = fmt.replace(RegExp.$1, (formatDate.getFullYear() + "").substr(4 - RegExp.$1.length));
- for (var k in o)
- if (new RegExp("(" + k + ")").test(fmt))
- fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
- return fmt;
-
- } else {
- date = "";
- return date;
- }
- };
- ////得到后几天的日期2019-10-26
- ///sp.dateCount(7);//得到7天后的日子
- sp.dateCount = function (AddDayCount) {
- var dd = new Date();
- dd.setDate(dd.getDate() + AddDayCount);//获取AddDayCount天后的日期
- var y = dd.getFullYear();
- var m = (dd.getMonth() + 1) < 10 ? "0" + (dd.getMonth() + 1) : (dd.getMonth() + 1);//获取当前月份的日期,不足10补0
- var d = dd.getDate() < 10 ? "0" + dd.getDate() : dd.getDate();//获取当前几号,不足10补0
- return y + "-" + m + "-" + d;
- }
- /// 2019-12-20
- // 往前数monthNum月份:sp.getPreMonthDay("2019-12-20",-10),往后数monthNum :sp.getPreMonthDay("2019-12-20",20);
- sp.getPreMonthDay = function (date, monthNum) {
- var dd = new Date(new Date(date).setMonth((new Date(date).getMonth() + monthNum)));
- var y = dd.getFullYear();
- var m = (dd.getMonth() + 1) < 10 ? "0" + (dd.getMonth() + 1) : (dd.getMonth() + 1);//获取当前月份的日期,不足10补0
- var d = dd.getDate() < 10 ? "0" + dd.getDate() : dd.getDate();//获取当前几号,不足10补0
- return y + "-" + m + "-" + d;
- },
- ///2019-12-21得到几天前和几天后的日期 getday(7);//7天后的日期 getday(17);//7天前的日期
- sp.getday = function (aa) {
- var date1 = new Date(),
- time1 = date1.getFullYear() + "-" + (date1.getMonth() + 1) + "-" + date1.getDate();//time1表示当前时间
- var date2 = new Date(date1);
- date2.setDate(date1.getDate() + aa);
- var y = date2.getFullYear();
- var m = (date2.getMonth() + 1) < 10 ? "0" + (date2.getMonth() + 1) : (date2.getMonth() + 1);//获取当前月份的日期,不足10补0
- var d = date2.getDate() < 10 ? "0" + date2.getDate() : date2.getDate();//获取当前几号,不足10补0
- var time2 = y + "-" + m + "-" + d;
- return time2;
- }
- ////实时保存,实时保存表单数据 【2018-3-25】
- ///用法:sp.localStorage("#formPlan",85);
- //从localStorage中加载数据记得删除:
- //var setId = "localStorage_formPlan_" + dataID;
- //localStorage.removeItem(setId);
- sp.localStorage = function (formId, dataID) {
- /// <summary>formId:为form定义的id</summary>
- /// <summary>dataID:表单数据的ID,目的防止重复</summary>
- var get_formid = $(formId).attr("id");
- ////声明本地存储localStorage的名称
- var set_localStorage = 'localStorage_' + get_formid + "_" + dataID;
- ///声明变量,得到form下面的带有name的所有控件
- var formControls = $(formId).find("input:text[name],textarea[name],select[name]");
- //从本地取localStorage
- var storage = localStorage.getItem(set_localStorage);
- ////如果,本地从本地取localStorage不为null,
- ///遍历localStorage中的值,
- if (storage != null) {
- var myData = JSON.parse(storage);
- formControls.each(function (i, e) {
- var name = $(e).attr("name");
- if (myData[name] != null) {
- $(e).val(myData[name]);
- $(e).change();
- }
- });
- }
- //绑定change事件,监听onchage事件
- formControls.each(function (i, el) {
- var name = $(el).attr('name');
- if (name) {
- $(el).on('change', function () {
- onchange(this);
- });
- }
- });
- //触发onchange事件时,保存到本地存储,或者更新本地存储中的值
- function onchange(el) {
- var storage = localStorage.getItem(set_localStorage);
- if (storage == null) {
- var formDataDb = new Object();
- var key = $(el).attr("name");
- var value = $(el).val();
- formDataDb[key] = value;
- localStorage.setItem(set_localStorage, JSON.stringify(formDataDb));
- } else {
- var myData = JSON.parse(storage);
- var key = $(el).attr("name");
- var value = $(el).val();
- myData[key] = value;
- localStorage.setItem(set_localStorage, JSON.stringify(myData));
- }
- }
- }
- //只冻结表格头部首行 调用方式 fixTableHead('#TableId', 0),只能调用table的ID table表的宽度应该限制为固定宽度,width:100%;
- sp.fixTableHead = function (table, rows) {
- /// <summary>只冻结表格头部首行</summary>
- if ($("#" + table + "_tableLayout").length != 0) {
- $("#" + table + "_tableLayout").before($("#" + table));
- $("#" + table + "_tableLayout").html('<div id="' + table + '_fixedHead" style="overflow:hidden"></div><div id="' + table + '_tableBody" style="overflow:auto"></div>');
- } else {
- $("#" + table).after('<div id="' + table + '_tableLayout" style="position:relative;height:100%;overflow:hidden"><div id="' + table + '_fixedHead" style="overflow:hidden"></div><div id="' + table + '_tableBody" style="overflow:auto"></div></div>');
- }
- var $tableLayout = $("#" + table + "_tableLayout");
- var $fixedHead = $("#" + table + "_fixedHead");
- var $tableBody = $("#" + table + "_tableBody");
- var rows = rows || 1; //默认固定1行
- var $table = $("#" + table);
- var $tableClone = $table.clone(true).removeAttr("id");
- $table.appendTo($tableBody);
- $tableClone.appendTo($fixedHead);
- $tableLayout.find('table').css("margin", "0");
- var theadHeight = 0;
- if ($table.find('thead').length != 0) {
- theadHeight = $table.find('thead').height();
- } else {
- for (var i = 0; i < rows; i++) {
- theadHeight += $table.find('tr').eq(i).height
- }
- }
- $fixedHead.height(theadHeight);
- $tableBody.height($tableLayout.height() - theadHeight);
- var tableWidth = $table.outerWidth();
- $table.css("marginTop", -theadHeight)
- if ($table.height() - theadHeight > $tableBody.height()) {
- $fixedHead.width($tableLayout.width() - 18)
- $tableLayout.append('<div id="' + table + '_gutter" style="position:absolute;top:1px;right:0;width:17px;border-bottom:1px solid #E1E6EB;background: #f1f1f1;height:' + (theadHeight - 1) + 'px"></div>')
- }
- $tableBody.scroll(function () {
- $fixedHead.scrollLeft($tableBody.scrollLeft());
- });
- var resizeTimer = null;
- $(window).resize(function () {
- if (resizeTimer) clearTimeout(resizeTimer);
- resizeTimer = setTimeout(function () {
- $fixedHead.height(theadHeight);
- $tableBody.height($tableLayout.height() - theadHeight);
- if ($table.height() - theadHeight > $tableBody.height()) {
- $fixedHead.width($tableLayout.width() - 18);
- if ($tableLayout.find('#' + table + '_gutter').length == 0) {
- $tableLayout.append('<div id="' + table + '_gutter" style="position:absolute;top:1px;right:0;width:17px;border-bottom:1px solid #E1E6EB;background: #f1f1f1;height:' + (theadHeight - 1) + 'px"></div>')
- }
- } else {
- $fixedHead.width($tableLayout.width() - 1);
- $tableLayout.find('#' + table + '_gutter').remove();
- }
- }, 100);
- });
- }
- //冻结头和列 调用: fixTable("MyTable", 1, 600, 300); 锁定表头和列: Table的ID、列的个数、显示的宽度、显示的高度,宽度不固定
- /// 锁定表头和列. table表的宽度是不能限制为固定,min-width:100%;
- sp.fixTable = function (TableID, FixColumnNumber, width, height) {
- /// <summary>冻结表头和列</summary>
- $(document).ready(function () {
- if ($("#" + TableID + "_tableLayout").length != 0) {
- $("#" + TableID + "_tableLayout").before($("#" + TableID)); $("#" + TableID + "_tableLayout").empty();
- }
- else {
- $("#" + TableID).after("<div id=\"" + TableID + "_tableLayout\" style=\"overflow:hidden;height:" + height + "px; width:" + width + "px;\"></div>");
- }
- $("<div id=\"" + TableID + "_tableFix\"></div>" + "<div id=\"" + TableID + "_tableHead\"></div>" + "<div id=\"" + TableID + "_tableColumn\"></div>" + "<div id=\"" + TableID + "_tableData\"></div>").appendTo("#" + TableID + "_tableLayout");
- var oldtable = $("#" + TableID);
- var tableFixClone = oldtable.clone(true);
- tableFixClone.attr("id", TableID + "_tableFixClone");
- $("#" + TableID + "_tableFix").append(tableFixClone);
- var tableHeadClone = oldtable.clone(true);
- tableHeadClone.attr("id", TableID + "_tableHeadClone");
- $("#" + TableID + "_tableHead").append(tableHeadClone);
- var tableColumnClone = oldtable.clone(true);
- tableColumnClone.attr("id", TableID + "_tableColumnClone");
- $("#" + TableID + "_tableColumn").append(tableColumnClone);
- $("#" + TableID + "_tableData").append(oldtable);
- $("#" + TableID + "_tableLayout table").each(function () {
- $(this).css("margin", "0");
- });
- var HeadHeight = $("#" + TableID + "_tableHead thead").height();
- HeadHeight += 2;
- $("#" + TableID + "_tableHead").css("height", HeadHeight);
- $("#" + TableID + "_tableFix").css("height", HeadHeight);
- var ColumnsWidth = 0;
- var ColumnsNumber = 0;
- $("#" + TableID + "_tableColumn tr:last td:lt(" + FixColumnNumber + ")").each(function () {
- ColumnsWidth += $(this).outerWidth(true);
- ColumnsNumber++;
- });
- ColumnsWidth += 2;
- if ($.browser.msie) {
- switch ($.browser.version) {
- case "7.0":
- if (ColumnsNumber >= 3) ColumnsWidth--;
- break;
- case "8.0":
- if (ColumnsNumber >= 2) ColumnsWidth--;
- break;
- }
- }
- $("#" + TableID + "_tableColumn").css("width", ColumnsWidth);
- $("#" + TableID + "_tableFix").css("width", ColumnsWidth);
- $("#" + TableID + "_tableData").scroll(function () {
- $("#" + TableID + "_tableHead").scrollLeft($("#" + TableID + "_tableData").scrollLeft());
- $("#" + TableID + "_tableColumn").scrollTop($("#" + TableID + "_tableData").scrollTop());
- });
- $("#" + TableID + "_tableFix").css({ "overflow": "hidden", "position": "relative", "z-index": "50", "background-color": "Silver" });
- $("#" + TableID + "_tableHead").css({ "overflow": "hidden", "width": width - 17, "position": "relative", "z-index": "45", "background-color": "#fff" });
- $("#" + TableID + "_tableColumn").css({ "overflow": "hidden", "height": height - 17, "position": "relative", "z-index": "40", "background-color": "Silver" });
- $("#" + TableID + "_tableData").css({ "overflow": "scroll", "width": width, "height": height, "position": "relative", "z-index": "35" });
- if ($("#" + TableID + "_tableHead").width() > $("#" + TableID + "_tableFix table").width()) {
- $("#" + TableID + "_tableHead").css("width", $("#" + TableID + "_tableFix table").width());
- $("#" + TableID + "_tableData").css("width", $("#" + TableID + "_tableFix table").width() + 17);
- }
- if ($("#" + TableID + "_tableColumn").height() > $("#" + TableID + "_tableColumn table").height()) {
- $("#" + TableID + "_tableColumn").css("height", $("#" + TableID + "_tableColumn table").height());
- $("#" + TableID + "_tableData").css("height", $("#" + TableID + "_tableColumn table").height() + 17);
- }
- $("#" + TableID + "_tableFix").offset($("#" + TableID + "_tableLayout").offset());
- $("#" + TableID + "_tableHead").offset($("#" + TableID + "_tableLayout").offset());
- $("#" + TableID + "_tableColumn").offset($("#" + TableID + "_tableLayout").offset());
- $("#" + TableID + "_tableData").offset($("#" + TableID + "_tableLayout").offset());
- });
- }
- //获取滚动条宽度
- sp.getScrollbarWidth = function () {
- var oP = document.createElement('p'), styles = {
- width: '100px',
- height: '100px',
- overflowY: 'scroll',
- }, i, scrollbarWidth;
- for (i in styles) {
- oP.style[i] = styles[i];
- }
- document.body.appendChild(oP);
- scrollbarWidth = oP.offsetWidth - oP.clientWidth;
- oP.remove();
- return scrollbarWidth;
- }
- // ************** 使用列很多的表格
- sp.fixTab2 = function (TableID, FixColumnNumber) {
- var scrollWidth = 17
- var table = "#" + TableID;
- var $table = $(table);
- if ($(table + "_tableLayout").length != 0) {
- $(table + "_tableLayout").before($(table));
- $(table + "_tableLayout").empty();
- } else {
- $table.after('<div id="' + TableID + '_tableLayout" style="overflow:hidden;width:100%;max-height:100%;position:relative"></div>');
- }
- var $tableLayout = $(table + "_tableLayout");
- //添加外壳
- $tableLayout.append('<div id="scrollMask"></div><div id="' + TableID + '_tableFix"></div>' + '<div id="' + TableID + '_tableHead"></div>' + '<div id="columnBox"><div id="' + TableID + '_tableColumn"></div></div>' + '<div id="' + TableID + '_tableData"></div>')
- //获取外壳
- var $tableFix = $(table + "_tableFix");
- var $tableHead = $(table + "_tableHead");
- var $columnBox = $("#columnBox");
- var $tableColumn = $(table + "_tableColumn");
- var $tableData = $(table + "_tableData");
- // console.log($table.width());
- // console.log($table.outerWidth());
- // $table.width(tableWidth);
- //获取表头高度
- var HeadHeight = $(table + " thead").outerHeight() + 1;
- var ColumnsWidth = 0;
- var ColumnsNumber = 0;
- $("#" + TableID + " tr:last td:lt(" + FixColumnNumber + ")").each(function () {
- ColumnsWidth += $(this).outerWidth(true);
- ColumnsNumber++;
- });
- ColumnsWidth += 1;
- //获取原表宽度
- $tableData.append($table);
- $tableData.css({ "overflow": "scroll", "height": par_height - HeadHeight, "position": "relative", "z-index": "35", "margin-top": HeadHeight });
- var tableWidth = $(table).width();
- var par_height = $tableLayout.outerHeight();
- var par_width = $tableLayout.width();
- $tableData.height(par_height - HeadHeight);
- //左上角
- setTimeout(function () {
- var $tableFixClone = $table.clone(true);
- $tableFixClone.attr("id", TableID + "_tableFixClone").css("margin", "0").width(tableWidth);
- $tableFix.css({ "height": HeadHeight, "width": ColumnsWidth, "overflow": "hidden", "position": "absolute", "top": 0, "left": 0, "z-index": "50", "background-color": "#fff" }).append($tableFixClone);
- })
- //表头
- setTimeout(function () {
- var $tableHeadClone = $table.clone(true);
- $tableHeadClone.attr("id", TableID + "_tableHeadClone").css("margin", "0");
- $tableHead.append($tableHeadClone);
- $tableHeadClone.width(tableWidth);
- $tableHead.css({ "height": HeadHeight, "overflow": "hidden", "width": par_width - 17, "position": "absolute", "top": 0, "left": 0, "z-index": "45", "background-color": "#fff" });
- })
- //列
- setTimeout(function () {
- var $tableColumnClone = $table.clone(true);
- $tableColumnClone.attr("id", TableID + "_tableColumnClone").css("margin", "0");
- $tableColumn.append($tableColumnClone);
- $tableColumnClone.width(tableWidth);
- $columnBox.css({ "width": ColumnsWidth, "overflow": "hidden", "height": par_height - 17, "position": "absolute", "top": 0, "left": 0, "z-index": "40", "background-color": "#fff" });
- $tableColumn.css({ "width": ColumnsWidth + scrollWidth, "overflow-x": "hidden", "overflow-y": "scroll", "height": par_height - 17, "position": "absolute", "top": 0, "left": 0, "z-index": "40" });
- var scrollFlag = false;
- $tableData.on('scroll', function () {
- if (scrollFlag) {
- return;
- }
- $tableHead.scrollLeft($tableData.scrollLeft());
- $tableColumn.scrollTop($tableData.scrollTop());
- }).on('mouseover', function () {
- scrollFlag = false;
- })
- $tableColumn.on('scroll', function () {
- if (!scrollFlag) {
- return;
- }
- $tableData.scrollTop($tableColumn.scrollTop());
- }).on('mouseover', function () {
- scrollFlag = true;
- })
- });
- $("#scrollMask").css({ 'position': "absolute", "top": 0, "right": 0, "width": scrollWidth, "height": HeadHeight, "background": "#E1E6EB", border: "solid #E1E6EB", "border-width": "1px 1px 1px 0" })
- $table.css("margin-top", -HeadHeight);
- var flag = false;
- $(window).resize(function () {
- if (flag) {
- return;
- }
- setTimeout(function () {
- par_height = $tableLayout.height();
- par_width = $tableLayout.width();
- // $columnBox.css({"width":ColumnsWidth,"height": par_height - 17});
- // $tableColumn.css({"width": ColumnsWidth+scrollWidth,"height": par_height - 17});
- // $tableData.css({"width":par_width-17,"height": par_height-HeadHeight});
- $tableHead.width(par_width - 17);
- $columnBox.height(par_height - 17);
- $tableColumn.height(par_height - 17);
- $tableData.height(par_height - HeadHeight);
- flag = false;
- }, 100);
- flag = true;
- });
- // return $("#" + TableID + "_tableLayout").html();
- }
- ///*************************************************************
- /* 为保证angularjs的显示效果,判断ie浏览器版本是否过低*/
- sp.getMyBrowser = function () {
- var userAgent = window.navigator.userAgent; //取得浏览器的userAgent字符串
- var isOpera = userAgent.indexOf("Opera") > -1; //判断是否Opera浏览器
- var isIE = userAgent.indexOf("compatible") > -1 && userAgent.indexOf("MSIE") > -1 && !isOpera; //判断是否IE浏览器
- if (!isIE) {
- isIE = userAgent.indexOf("Windows NT") > -1 && userAgent.indexOf("BOIE") > -1 && !isOpera; //判断是否IE浏览器
- }
- var is360 = isIE && ((window.navigator.userProfile + '') == 'null');//判断是否360浏览器
- var isFF = userAgent.indexOf("Firefox") > -1; //判断是否Firefox浏览器
- var isChrome = userAgent.indexOf("Chrome") > -1; //判断是否Safari浏览器
- var isSafari = userAgent.indexOf("Safari") > -1 && !isChrome; //判断是否Safari浏览器
- if (isIE && !is360) {
- var IE5 = IE55 = IE6 = IE7 = IE8 = false;
- var reIE = new RegExp("MSIE (\\d+\\.\\d+);");
- reIE.test(userAgent);
- var fIEVersion = parseFloat(RegExp["$1"]);
- IE55 = fIEVersion == 5.5;
- IE6 = fIEVersion == 6.0;
- IE7 = fIEVersion == 7.0;
- IE8 = fIEVersion == 8.0;
- if (IE55) {
- return "IE55|false";
- } else if (IE6) {
- return "IE6|false";
- } else if (IE7) {
- return "IE7|false";
- } else if (IE8) {
- return "IE8|false";
- } else {
- return "IE9|true";
- }
- } //isIE end
- if (is360) {
- return "360|alert";
- }
- if (isFF) {
- return "FF|true";
- }
- if (isChrome) {
- return "Chrome|true";
- }
- if (isOpera) {
- return "Opera|true";
- }
- if (isSafari) {
- return "Safari|true";
- }
- }
- /**调用监测浏览器版本方法,并进行判断与提示**/
- sp.checkIEVersion = function () {
- var mb = sp.getMyBrowser(); ///获取浏览器判断返回的值
- if (mb == undefined || mb == null || mb == "") {
- sp.dialog("您正在使用兼容模式,网站的样式可能会发生变化,请您更换Google Chrome浏览器或IE9以上版本浏览器进行浏览。");
- } else {
- var mbArray = mb.split("|");
- if (mbArray[1] == "alert") {
- sp.dialog("您正在使用360浏览器浏览,网站的样式可能会发生变化,请您更换Google Chrome浏览器或IE9以上版本浏览器进行浏览。");
- } else if (mbArray[1] == "false") {
- sp.dialog("您正在使用低版本IE浏览器浏览,网站的样式可能会发生变化,请您更换Google Chrome浏览器或IE9以上版本浏览器进行浏览。");
- } else {
- }
- }
- }
- sp.getExplorerInfo = function () {
- var explorer = window.navigator.userAgent.toLowerCase();
- //ie
- if (explorer.indexOf("msie") >= 0) {
- var ver = explorer.match(/msie ([\d.]+)/)[1];
- return { type: "IE", version: ver };
- }
- ////ie11有点特殊,ie11执行这句话
- if (explorer.indexOf("rv:11") > -1) {
- var ver = explorer.match(/rv:([\d.]+)/)[1];
- return { type: "IE", version: ver };
- }
- //firefox
- else if (explorer.indexOf("firefox") >= 0) {
- var ver = explorer.match(/firefox\/([\d.]+)/)[1];
- return { type: "Firefox", version: ver };
- }
- //Chrome
- else if (explorer.indexOf("chrome") >= 0) {
- var ver = explorer.match(/chrome\/([\d.]+)/)[1];
- return { type: "Chrome", version: ver };
- }
- //Opera
- else if (explorer.indexOf("opera") >= 0) {
- var ver = explorer.match(/opera.([\d.]+)/)[1];
- return { type: "Opera", version: ver };
- }
- //Safari
- else if (explorer.indexOf("Safari") >= 0) {
- var ver = explorer.match(/version\/([\d.]+)/)[1];
- return { type: "Safari", version: ver };
- }
- }
- /////2018.7.12禁用ctrl+s快捷键
- sp.disablesaving = function () {
- document.onkeydown = function (e) {
- e = window.event || e;
- var key = e.keyCode;
- if (key == 83 && e.ctrlKey == true) {
- return false;
- }
- };
- };
- /////2018.9.27
- ///***给字符串添加属性************************************************************
- //2016-11-14 截取字符串两侧的空格 JavaScript
- sp.trim = function (str) {
- ///<summary>去掉字符串所有空格</summary>
- return str.replace(/\s+/g, "");
- };
- sp.trimleft = function (str) {
- ///<summary>去掉左边的空格</summary>
- return str.replace(/^\s*/, "");
- };
- sp.trimright = function (str) {
- ///<summary>去除右边的空格</summary>
- return str.replace(/\s*$/, "");
- };
- sp.trimin = function (str) {
- ///<summary>去除内的空格</summary>
- return str.replace(/\s/g, "");
- };
- ///截取字符串
- sp.cutfirst = function (str, num) {
- /// <summary>去掉第一个字符 </summary>
- if (sp.isval(num)) {
- return str.substr(num);
- } else { return str.substr(1); }
- }
- sp.cutlast = function (str, num) {
- /// <summary>去掉最后一个字符 </summary>
- if (sp.isval(num)) {
- if (num < 1) {
- sp.dialog("截取尾部字符的数量须大于0");
- } else {
- return str.substr(0, str.length - num);
- }
- } else {
- return str.substr(0, str.length - 1);
- }
- };
- ///给数组添加属性
- //strMin();获取数组中最小值
- sp.arraymin = function (strArr) {
- /// <summary> 获取数组中最小值 </summary>
- var strMin = strArr[0];
- var len = strArr.length;
- for (var i = 1; i < len; i++) {
- if (strArr[i] < strMin) {
- strMin = strArr[i];
- }
- }
- return strMin;
- }
- //strMax();获取数组中最大值
- sp.arraymax = function (strArr) {
- /// <summary> 获取数组中最大值 </summary>
- var strMax = strArr[0];
- var len = strArr.length;
- for (var i = 1; i < len; i++) {
- if (strArr[i] > strMax) {
- strMax = strArr[i];
- }
- }
- return strMax;
- }
- //arrayAscend将数字升序排序();
- sp.arrayAscend = function (strArr) {
- /// <summary>冒泡排序:将数字从小到大排序升序</summary>
- //var arr = new Array;
- var arr = new Array;
- arr = strArr;
- var length = arr.length;
- for (var i = 0; i < length; i++) {
- for (var j = i; j < length; j++) {
- if (arr[i] > arr[j]) {
- Temp = arr[i];
- arr[i] = arr[j];
- arr[j] = Temp;
- }
- }
- }
- return arr;
- };
- //arrayDescend将数字降序排序();
- sp.arrayDescend = function (strArr) {
- /// <summary>冒泡排序:降序排序</summary>
- var arr = new Array;
- arr = strArr;
- var Temp = 0;
- var length = arr.length;
- for (var i = 0; i < length; i++) {
- for (var j = i + 1; j < length; j++) {
- if (arr[i] < arr[j]) {
- Temp = arr[i];
- arr[i] = arr[j];
- arr[j] = Temp;
- }
- }
- }
- return arr;
- };
- ///设置左右布局的tab选项卡,左右两边高度一致201809
- sp.settableft = function () {
- if ($("body").find(".sp-tab-left").length > 0) {
- $(".sp-tab-left").each(function () {
- if ($(".sp-tab-menu", this).height() > $(".sp-tab-box", this).height()) {
- $(".sp-tab-box", this).css("height", $(".sp-tab-menu", this).outerHeight());
- } else {
- $(".sp-tab-menu", this).css("height", $(".sp-tab-box", this).outerHeight());
- }
- });
- };
- };
- sp.settableft();
- sp.settabright = function () {
- if ($("body").find(".sp-tab-right").length > 0) {
- $(".sp-tab-right").each(function () {
- if ($(".sp-tab-menu", this).height() > $(".sp-tab-box", this).height()) {
- $(".sp-tab-box", this).css("height", $(".sp-tab-menu", this).outerHeight());
- } else {
- $(".sp-tab-menu", this).css("height", $(".sp-tab-box", this).outerHeight());
- }
- });
- };
- };
- sp.settabright();
- //201810
- /////判断这个变量不为空、null、undefined,即判断这个变量是有值存在
- sp.isval = function (vars) {
- if (typeof (vars) != undefined && vars != null && vars != "") {
- return true;
- }
- };
- ///201810
- ////利用checkbox的多选情况
- sp.selectmore = function () {
- if ($("body").find(".sp-selectmore").length > 0) {
- $(".sp-selectmore").each(function () {
- $(".sp-selectmore-bottom span", this).each(function () {
- $(this).on("click", function () {
- var getmoreup = $(this).parents(".sp-selectmore").children(".sp-selectmore-up");
- if ($(this).hasClass("sp-selectmore-active")) {
- $(this).removeClass("sp-selectmore-active");
- getmoreup.find("span[data-value='" + $(this).attr("data-value") + "']").remove();
- } else {
- $(this).addClass("sp-selectmore-active");
- getmoreup.append("<span data-value='" + $(this).attr("data-value") + "'><label onclick='sp.selectmoreclose(this)'>×</label>" + $(this).text() + "</span>");
- }
- });
- });
- //判断是否有赋值
- if ($(".sp-selectmore-up", this).find("span").length > 0) {
- $(this).children(".sp-selectmore-up").find("span").each(function () {
- var getvalue = $(this).attr("data-value");
- $(this).parents(".sp-selectmore").children(".sp-selectmore-bottom").find("span[data-value='" + getvalue + "']").addClass("sp-selectmore-active");
- });
- };
- /////点击上下两个div层控制显示隐藏切换
- $(this).find(".sp-selectmore-up").on("click", function (e) {
- if ($(this).hasClass("sp-selectmore-up-hasclick")) {
- $(this).removeClass("sp-selectmore-up-hasclick");
- $(this).parents(".sp-selectmore").children(".sp-selectmore-bottom").hide();
- sp.stopPropagation(e);
- } else {
- $(this).addClass("sp-selectmore-up-hasclick");
- $(this).parents(".sp-selectmore").children(".sp-selectmore-bottom").show();
- sp.stopPropagation(e);
- }
- });
- $(document).bind('click', function () {
- $(".sp-selectmore-up", this).removeClass("sp-selectmore-up-hasclick");
- $(".sp-selectmore-bottom",this).hide()
- });
- $(this).children(".sp-selectmore-bottom").click(function (e) {
- sp.stopPropagation(e);
- });
-
- });
- };
- };
- ////更多插件的上部叉号关闭按钮
- sp.selectmoreclose = function (obj,e) {
- var getvalue = $(obj).parent().attr("data-value");
- var bottom = $(obj).parents(".sp-selectmore").children(".sp-selectmore-bottom");
- bottom.find("span[data-value='" + getvalue + "']").removeClass("sp-selectmore-active");
- $(obj).parent().remove();
- sp.stopPropagation(e);
- };
- ////2019-5-7
- // 字符串转base64
- sp.strToBase64 = function (str){
- return btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, function(match, p1) {
- return String.fromCharCode('0x' + p1);
- }));
- };
- // base64转字符串
- sp.base64ToStr = function (base64){
- return decodeURIComponent(atob(base64).split('').map(function(c) {
- return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
- }).join(''));
- };
- //2020-1-2 格式化文件大小显示
- sp.filesize = function (limit) {
- var size = "";
- if (limit < 0.1 * 1024) { //如果小于0.1KB转化成B
- size = limit.toFixed(2) + "B";
- } else if (limit < 0.1 * 1024 * 1024) {//如果小于0.1MB转化成KB
- size = (limit / 1024).toFixed(2) + "KB";
- } else if (limit < 0.1 * 1024 * 1024 * 1024) { //如果小于0.1GB转化成MB
- size = (limit / (1024 * 1024)).toFixed(2) + "MB";
- } else { //其他转化成GB
- size = (limit / (1024 * 1024 * 1024)).toFixed(2) + "GB";
- }
- var sizestr = size + "";
- var len = sizestr.indexOf("\.");
- var dec = sizestr.substr(len + 1, 2);
- if (dec == "00") {//当小数点后为00时 去掉小数部分
- return sizestr.substring(0, len) + sizestr.substr(len + 3, 2);
- }
- return sizestr;
- }
- ///2020-1-7
- //自定义变形函数
- sp.dateFtt = function(fmt, date) {
- var o = {
- "M+": date.getMonth() + 1, //月份
- "d+": date.getDate(), //日
- "h+": date.getHours(), //小时
- "m+": date.getMinutes(), //分
- "s+": date.getSeconds(), //秒
- "q+": Math.floor((date.getMonth() + 3) / 3), //季度
- "S": date.getMilliseconds() //毫秒
- };
- if (/(y+)/.test(fmt))
- fmt = fmt.replace(RegExp.$1, (date.getFullYear() + "").substr(4 - RegExp.$1.length));
- for (var k in o)
- if (new RegExp("(" + k + ")").test(fmt))
- fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
- return fmt;
- }
- //判断所选日期是第几周 传入时间对象 //调用方式getWeekNumber(new Date())
- sp.getWeekNumber = function (obj) {
- var year = obj.getFullYear(); //年
- var month = obj.getMonth(); //月
- var days = obj.getDate(); //日
- var nowTime = obj.getTime(); //毫秒
- var day = obj.getDay(); //星期几
- //那一天是那一年中的第多少天
- for (var i = 0; i < month; i++) {
- days += sp.getMonthDays(year, i);
- }
- //那一年第一天是星期几
- var yearFirstDay = new Date(year, 0, 1).getDay() || 7;
- var week = null;
- if (yearFirstDay == 1) {
- week = Math.ceil(days / 7);
- } else {
- days -= (7 - yearFirstDay + 1);
- week = Math.ceil(days / 7) + 1;
- }
- var oneDayLong = 24 * 60 * 60 * 1000;
- if (day == 0) {
- var MondayTime = nowTime - 6 * oneDayLong;
- var SundayTime = nowTime;
- } else {
- var MondayTime = nowTime - (day - 1) * oneDayLong;
- var SundayTime = nowTime + (7 - day) * oneDayLong;
- }
- var dateString = "";
- for (var i = 0; i < 7; i++) {
- var time = MondayTime + (oneDayLong) * i;
- dateString += sp.dateFtt("MM.dd", new Date(time)) + ","
- }
- var monday = sp.dateFtt("yyyy-MM-dd", new Date(MondayTime));
- var sunday = sp.dateFtt("yyyy-MM-dd", new Date(SundayTime));
- return {
- begin: monday,
- end: sunday,
- week: week,
- dateString: dateString.substring(0, dateString.length - 1),
- weekday: ["周日", "周一", "周二", "周三", "周四", "周五", "周六"][day]
- }
- }
- ///判断是否为闰年
- sp.isLeapYear = function (year) {
- return (year % 400 == 0) || (year % 4 == 0 && year % 100 != 0);
- }
- //判断每个月的天数
- sp.getMonthDays = function (year, month) {
- return [31, null, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month] || (sp.isLeapYear(year) ? 29 : 28);
- }
- ///判断是否为json字符串
- sp.isJSON = function (str) {
- if (typeof str == 'string') {
- try {
- var obj = JSON.parse(str);
- if (typeof obj == 'object' && obj) {
- return true;
- } else {
- return false;
- }
- } catch (e) {
- return false;
- }
- }
- }
- ///【2020-2-26】js获取指定日期的前一天/后一天
- // date 代表指定的日期,格式:2018-09-27
- // day 传-1表始前一天,传1表始后一天
- // JS获取指定日期的前一天,后一天
- sp.getNextDate = function (date, day) {
- var dd = new Date(date);
- dd.setDate(dd.getDate() + day);
- var y = dd.getFullYear();
- var m = dd.getMonth() + 1 < 10 ? "0" + (dd.getMonth() + 1) : dd.getMonth() + 1;
- var d = dd.getDate() < 10 ? "0" + dd.getDate() : dd.getDate();
- return y + "-" + m + "-" + d;
- };
- ////getNextDate("2018-09-27", -1);
- //获取本机ip地址
- sp.myIP = function () {
- var ip = "";
- $.ajax({
- url: apiurljs.login + "g2app/dataabase/getClientIP",
- type: 'post',
- async: false,
- contentType: "application/json",
- beforeSend: function (request) {
- request.setRequestHeader("Authorization", "Bearer " + localStorage.getItem("GlWorkPlatform-AccessToken"));
- },
- dataType: "json",
- success: function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data));
- ip = res.data;
- }
- })
- return ip
- }
- //获取本机操作系统
- sp.detectOS = function () {
- var sUserAgent = navigator.userAgent;
-
- var isWin = (navigator.platform == "Win32") || (navigator.platform == "Windows");
- var isMac = (navigator.platform == "Mac68K") || (navigator.platform == "MacPPC") || (navigator.platform == "Macintosh") || (navigator.platform == "MacIntel");
- if (isMac) return "Mac";
- var isUnix = (navigator.platform == "X11") && !isWin && !isMac;
- if (isUnix) return "Unix";
- var isLinux = (String(navigator.platform).indexOf("Linux") > -1);
-
- var bIsAndroid = sUserAgent.toLowerCase().match(/android/i) == "android";
- if (isLinux) {
- if(bIsAndroid) return "Android";
- else return "Linux";
- }
- if (isWin) {
- if (sUserAgent.indexOf("Windows NT 5") != -1) {
- return "Windows XP";
- } else if (sUserAgent.indexOf("Windows NT 7") != -1) {
- return "Windows 7";
- } else if (sUserAgent.indexOf("Windows NT 10") != -1) {
- return "Windows 10";
- }
- }
- return "other";
- }
- //获取本机浏览器类型
- sp.browser = function () {
- var userAgent = navigator.userAgent;
- if (navigator.userAgent.indexOf('Firefox') > -1)
- return "火狐浏览器"
- if (navigator.userAgent.indexOf('Chrome') > -1 )
- return "谷歌浏览器"
- if (navigator.userAgent.indexOf('Opera') > -1)
- return "Opera"
- if (userAgent.indexOf("compatible") > -1 && userAgent.indexOf("MSIE") > -1 && !isOpera)
- return "IE浏览器"
- }
- //获取当前时间(带毫秒),格式:2021-11-23 10:47:15.165
- sp.getLocalDate1 = function () {
- var objDate = new Date();
- var str, date, colorhead, colorfoot;
- var yy = objDate.getFullYear();
- var MM = objDate.getMonth() + 1;
- if (MM < 10) MM = '0' + MM;
- var dd = objDate.getDate();
- if (dd < 10) dd = '0' + dd;
- var hh = objDate.getHours();
- if (hh < 10) hh = '0' + hh;
- var mm = objDate.getMinutes();
- if (mm < 10) mm = '0' + mm;
- var ss = objDate.getSeconds();
- if (ss < 10) ss = '0' + ss;
- date = yy + "-" + MM + "-" + dd + " " + hh + ":" + mm + ":" + ss;
- var mins = objDate.getTime() - new Date(date).getTime();
- mins < 10 ? '00' + mins : mins < 100 ? '0' + mins : mins;
- str = yy + "-" + MM + "-" + dd + " " + hh + ":" + mm + ":" + ss + "." + mins;
- return str;
- };
- //提醒登录超时
- sp.addDLTX = function () {
- if ($('body').find(".DLTX").length < 1) {
- $('body').prepend("<div class=\"DLTX\"></div>");
- }
- }
- sp.openDLTX = function (Name) {
- $('.DLTX').fadeIn(200);
- sp.setCenter(Name);
- }
- //毫秒转日期格式
- sp.minsToDate = function (fmt, str) {
- var date = new Date(str);
- var o = {
- "M+": date.getMonth() + 1, //月份
- "d+": date.getDate(), //日
- "h+": date.getHours(), //小时
- "m+": date.getMinutes(), //分
- "s+": date.getSeconds(), //秒
- "q+": Math.floor((date.getMonth() + 3) / 3), //季度
- "S": date.getMilliseconds() //毫秒
- };
- if (/(y+)/.test(fmt))
- fmt = fmt.replace(RegExp.$1, (date.getFullYear() + "").substr(4 - RegExp.$1.length));
- for (var k in o)
- if (new RegExp("(" + k + ")").test(fmt))
- fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
- return fmt;
- }
- //拖动
- sp.drag = function (id) {
- var box = document.querySelector(id);
- var title = document.querySelector(id).children[0];
- title.addEventListener("mousedown", function (event) {
- var x = event.pageX - box.offsetLeft;
- var y = event.pageY - box.offsetTop;
- document.addEventListener("mousemove", boxMove)
- function boxMove(event) {
- box.style.left = (event.pageX - x) + "px"
- box.style.top = (event.pageY - y) + "px"
- }
- document.addEventListener("mouseup", function () {
- document.removeEventListener("mousemove", boxMove)
- })
- })
- }
|