special_hd.js 185 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854
  1. //归结主要方法有: 居中显示,关闭、打开层,自适应高度,冻结表头、冻结头和列,
  2. //首先: special命名为sp
  3. var sp = window.NameSpace || {};
  4. if (typeof (SM4Util) != "undefined") {
  5. var s4 = new SM4Util();
  6. }
  7. /*禁用右键*/
  8. if (window.parent.location.href.indexOf("tpl/index/index2.html") > -1) {
  9. console.log(window.location.href)
  10. $("body").attr("oncontextmenu", "return false").attr("onselectstart", "return false")
  11. }
  12. //在页面dom加载完之后执行
  13. $(document).ready(function () {
  14. sp.addMask(); //为body添加上遮罩层
  15. sp.setClass(); //为自定义class类添加功能操作
  16. sp.table(); //操作table,为table加上隔行变色、
  17. sp.setPanel(); //面板
  18. sp.disablesaving(); //禁止ctrl+s
  19. sp.setdisabled();
  20. sp.setreadonly();
  21. sp.addDLTX(); //为body添加上点击不会隐藏的遮罩层
  22. //文字不可被选中
  23. //document.body.onselectstart = function () {
  24. // return false;
  25. //}
  26. });
  27. // $(document).click(function (e) {
  28. // var className = ["sp-menu-item", "sp-menu-tab", "icon-menu", "sp-menu-switch"], n = 0;
  29. // className.forEach(function (item) {
  30. // if (e.target.className.indexOf(item) != -1 || ($(e.target).parents("." + item).length > 0 && e.target.className.indexOf('fa-close') == -1)) {
  31. // n = 1;
  32. // return;
  33. // }
  34. // })
  35. // if (n == 0) {
  36. // $(".sp-menu-tab", window.parent.document).removeClass("fadeInLeft").addClass("fadeOutLeft");
  37. // setTimeout(function () {
  38. // $(".sp-menu-tab", window.parent.document).hide()
  39. // }, 500)
  40. // }
  41. // if (n == 1) {
  42. // $(".sp-menu-tab", window.parent.document).removeClass("fadeOutLeft").addClass("fadeInLeft")
  43. // $(".sp-menu-tab", window.parent.document).show()
  44. // }
  45. // })
  46. sp.addMask = function () {
  47. //1.为每个页面的body加上遮罩层,样式为不可见
  48. if ($('body').find(".sp-bgMask").length < 1) {
  49. $('body').prepend("<div class=\"sp-bgMask\"></div>");
  50. }
  51. //2.如果body中含有对话框 sp-dialog类名,就为其加上温馨提示和关闭按钮
  52. if ($('body').find(".sp-dialog").length < 1) {
  53. $('body').prepend("<div class=\"sp-dialog\"></div>");
  54. }
  55. //3.点击遮罩层,对话框、弹出层、遮罩层均淡出
  56. $(".sp-bgMask").bind("click", function () {
  57. $(this).fadeOut(200);
  58. if ($(".sp-dialog").is(":visible")) { //若对话框显示则淡出
  59. $(".sp-dialog").fadeOut(200);
  60. }
  61. if ($(".sp-layer").is(":visible")) { //若中间层显示则淡出
  62. $(".sp-layer").fadeOut(200);
  63. }
  64. if ($(".sp-layer2").is(":visible")) { //若中间层显示则淡出
  65. $(".sp-layer2").fadeOut(200);
  66. }
  67. });
  68. }
  69. //sp.dialog("身份证号不能为空!");
  70. sp.dialog = function (tip, state) {
  71. /// <summary>显示对话框</summary>
  72. var dialogHead = "<span class=\"sp-dialog-head\"><span class=\"sp-dialog-tip\">温馨提示</span><span class=\"sp-dialog-close sp-closeDialog\" title=\"关闭\">×</span></span>";
  73. if (state) {
  74. var imgState = "<span class=\"sp-dialog-logo-true\"></span>";
  75. var dialogBody = "<div class=\"sp-dialog-body\"><span class=\"sp-lh-22 sp-color-gray sp-text-center\">" + tip + "</span>" + imgState + "</div>";
  76. var dialogFoot = "<div class=\"sp-dialog-foot\"><input type=\"button\" value=\"确 定\" class=\"sp-dialog-btnClose sp-closeDialog\" style=\"float:none;\" /></div>";
  77. }else if(state==false){
  78. var imgState = "<span class=\"sp-dialog-logo-false\"></span>";;
  79. var dialogBody = "<div class=\"sp-dialog-body\"><span class=\"sp-lh-22 sp-color-gray sp-text-center\">" + tip + "</span>" + imgState + "</div>";
  80. var dialogFoot = "<div class=\"sp-dialog-foot\"><input type=\"button\" value=\"确 定\" class=\"sp-dialog-btnClose sp-closeDialog\" style=\"float:none;\" /></div>";
  81. } else {
  82. var dialogBody = "<div class=\"sp-dialog-body\">" + tip + "</div>";
  83. var dialogFoot = "<div class=\"sp-dialog-foot\"><input type=\"button\" id=\"dialogClose\" value=\"关 闭\" class=\"sp-dialog-btnClose sp-closeDialog\" /></div>";
  84. }
  85. $('.sp-dialog').html(dialogHead + dialogBody + dialogFoot);
  86. sp.openCenter(".sp-dialog");
  87. $('.sp-closeDialog').click(function (event) {
  88. //sp.closeCenter(".sp-dialog");
  89. $(".sp-dialog").fadeOut(200);
  90. var layerNum = 0;
  91. $(".sp-layer").each(function () {
  92. if ($(this).css("display") == "none") {
  93. layerNum++;
  94. }
  95. })
  96. if (layerNum == $(".sp-layer").length) {
  97. $('.sp-bgMask').fadeOut(200);
  98. }
  99. event.preventDefault(); event.stopPropagation();
  100. });
  101. }
  102. sp.dialoghide = function () {
  103. /// <summary>关闭对话框</summary>
  104. var layerNum = 0;
  105. $(".sp-dialog").fadeOut(200);
  106. $(".sp-layer").each(function () {
  107. if ($(this).css("display") == "none") {
  108. layerNum++;
  109. }
  110. })
  111. if (layerNum == $(".sp-layer").length) {
  112. $('.sp-bgMask').fadeOut(200);
  113. }
  114. };
  115. //加载loading演示
  116. sp.load = function () {
  117. /// <summary>加载loading</summary>
  118. if ($('body').find(".sp-load").length < 1) {
  119. $('body').append("<div class=\"sp-load\"><span class=\"sp-load-img\"></span><span class=\"sp-load-title\">请稍等,正努力加载中......</span></div>");
  120. }
  121. sp.setCenter(".sp-load");
  122. };
  123. sp.loadhide = function () {
  124. /// <summary>关闭loading</summary>
  125. $(".sp-load").fadeOut(200);
  126. };
  127. //打开后 居中,并且后有遮罩层
  128. sp.layer = function (Name) {
  129. /// <summary>打开弹出层</summary>
  130. //3.如果body中含有对话框sp-layer类名,就为其加上关闭按钮
  131. if ($('body').find(".sp-layer").length > 0) {
  132. $('.sp-layer').hide();//为对话框样式是可见的,加载时设置隐藏
  133. $('.sp-layer').each(function () {
  134. if ($(this).find(".sp-layer-head").length < 1) {
  135. $(this).prepend("<div class=\"sp-layer-head\"></div>");
  136. if ($(this).attr("data-title") != undefined) {
  137. var getTitle = $(this).attr("data-title");
  138. $(".sp-layer-head", this).prepend("<span class=\"sp-layer-title\">" + getTitle + "</span>");
  139. }
  140. }
  141. if ($(this).find(".sp-layer-close").length < 1) {
  142. $('.sp-layer-head', this).append("<span class=\"sp-layer-close\" title=\"关闭\" onclick=\"sp.closeCenter('.sp-layer')\">×</span>");
  143. }
  144. });
  145. };
  146. ///查看图片大图遮罩层
  147. if ($("body").find(".sp-layer2").length > 0) {
  148. $('.sp-layer2').each(function () {
  149. if ($(this).find(".sp-layer2-close").length < 1) {
  150. $(this).prepend("<span class=\"sp-layer2-close\" title=\"关闭\" onclick=\"sp.closeCenter('.sp-layer2')\"></span>");
  151. }
  152. });
  153. };
  154. $('.sp-bgMask').fadeIn(200);
  155. $("body").attr("onselectstart", "return false")
  156. setTimeout(function () {
  157. sp.setCenter(Name);
  158. sp.drag(Name)
  159. },1)
  160. }
  161. sp.layerhide = function () {
  162. /// <summary>关闭弹出层</summary>
  163. $(".sp-layer").fadeOut(200);
  164. $('.sp-bgMask').fadeOut(200);
  165. }
  166. sp.setClass = function () {
  167. //1.实现初始获取焦点 根据class="focus"用法
  168. $('.sp-focus').focus();
  169. //2. jquery实现input文本框禁用效果 根据class="banInput"用法
  170. $('.banInput').css({ 'background': '#ebebe4', 'border': '1px solid #a9a9a9', 'cursor': 'default' });
  171. $('.banInput').focus(function () {
  172. $('.banInput').blur();
  173. });
  174. //4.中间弹出层
  175. $('.openCenter').click(function () {
  176. sp.openCenter(".sp-layer");
  177. });
  178. $('.closeCenter').click(function () {
  179. sp.closeCenter(".sp-layer");
  180. });
  181. $('.sp-closeCenter').click(function () {
  182. sp.closeCenter(".sp-layer");
  183. });
  184. }
  185. //5.添加禁用方法
  186. sp.setdisabled = function () {
  187. $('.sp-disabled').attr("disabled", "disabled");
  188. $('.sp-disabled').click(function (event) {
  189. return false;
  190. event.preventDefault();
  191. });//禁止a标签链接跳转
  192. }
  193. ///6.为只读加上属性
  194. sp.setreadonly = function () {
  195. $('.sp-readonly').attr("readonly", "readonly");
  196. };
  197. //////下面是让层居中显示的js代码,
  198. ///页面调用方法 setCenter("#DivCeng"); 让DivCeng这个层打开并且居中显示 setCenter(".DivCeng");
  199. sp.setCenter = function (divName) {
  200. /// <summary>居中显示</summary>
  201. $(document).ready(function () {
  202. var top = ($(window).height() - $(divName).height()) / 2;
  203. var left = ($(window).width() - $(divName).width()) / 2;
  204. var scrollTop = $(document).scrollTop();
  205. var scrollLeft = $(document).scrollLeft();
  206. var zIndex = divName == ".sp-dialog" ? 100001 : 100000;
  207. $(divName).css({ position: 'absolute', 'top': top + scrollTop, left: left + scrollLeft, 'z-index': zIndex }).fadeIn(200);
  208. });
  209. //浏览器窗口大小改变时
  210. $(window).resize(function () {
  211. var top = ($(window).height() - $(divName).height()) / 2;
  212. var left = ($(window).width() - $(divName).width()) / 2;
  213. var scrollTop = $(document).scrollTop();
  214. var scrollLeft = $(document).scrollLeft();
  215. var zIndex = divName == ".sp-dialog" ? 100001 : 100000;
  216. $(divName).css({ position: 'absolute', 'top': top + scrollTop, left: left + scrollLeft, 'z-index': zIndex });
  217. });
  218. //浏览器有滚动条时的操作、
  219. $(window).scroll(function () {
  220. var top = ($(window).height() - $(divName).height()) / 2;
  221. var left = ($(window).width() - $(divName).width()) / 2;
  222. var scrollTop = $(document).scrollTop();
  223. var scrollLeft = $(document).scrollLeft();
  224. var zIndex = divName == ".sp-dialog" ? 100001 : 100000;
  225. $(divName).css({ position: 'absolute', 'top': top + scrollTop, left: left + scrollLeft, 'z-index': zIndex });
  226. });
  227. }
  228. ///单纯的打开、关闭 调用:close('#id')或 Close('.class')
  229. sp.open = function (name) {
  230. $(name).fadeIn(200);
  231. }
  232. sp.close = function (name) {
  233. $(name).fadeOut(200);
  234. }
  235. //打开后 居中,并且后有遮罩层
  236. sp.openCenter = function (Name) {
  237. /// <summary>打开后居中后有遮罩层</summary>
  238. $('.sp-bgMask').fadeIn(200);
  239. sp.setCenter(Name);
  240. }
  241. sp.closeCenter = function (Name) {
  242. /// <summary>关闭居中层</summary>
  243. $(Name).fadeOut(200);
  244. $('.sp-bgMask').fadeOut(200);
  245. $("body").attr("onselectstart", "")
  246. }
  247. //操作radio
  248. sp.funRadio = function (radioDiv, radioClass, radioCheckClass) {
  249. //三个参数
  250. $(radioDiv).each(function () {
  251. if (radioDiv != ".sp-radio-none") {
  252. $("input[type='radio']", this).hide();
  253. }
  254. $("input[type='radio']", this).parent("label").addClass(radioClass);
  255. $("input[type='radio']", this).click(function () {
  256. $(this).attr("checked", true).parent().siblings().find("input[type='radio']").removeAttr("checked");
  257. $(this).parent("label").addClass(radioCheckClass).siblings("label").removeClass(radioCheckClass);
  258. });
  259. $("input[type='radio']", this).each(function () {
  260. if ($(this).attr("checked")) {
  261. $(this).attr("checked", true).parent("label").addClass(radioCheckClass).siblings().removeClass(radioCheckClass);
  262. }
  263. });
  264. });
  265. }
  266. sp.radio = function () {
  267. /// <summary>美化radio</summary>
  268. //灰色radio
  269. if ($("body").find(".sp-radio-default").length > 0) {
  270. sp.funRadio(".sp-radio-default", "rd-default", "rd-default-checked");
  271. }
  272. //橙色radio
  273. if ($("body").find(".sp-radio-orange").length > 0) {
  274. sp.funRadio(".sp-radio-orange", "rd-orange", "rd-orange-checked");
  275. }
  276. //蓝色radio
  277. if ($("body").find(".sp-radio-blue").length > 0) {
  278. sp.funRadio(".sp-radio-blue", "rd-blue", "rd-blue-checked");
  279. }
  280. //无皮肤radio
  281. if ($("body").find(".sp-radio-none").length > 0) {
  282. sp.funRadio(".sp-radio-none", "rd-none", "rd-none-checked");
  283. }
  284. }
  285. //操作checkbox
  286. sp.funcheckbox = function (chbDiv, chbClass, chbchecked) {
  287. /// <summary>操作checkbox</summary>
  288. $(chbDiv).each(function () {
  289. if (chbDiv != ".sp-checkbox-none") {
  290. $("input[type='checkbox']", this).hide();
  291. }
  292. $("input[type='checkbox']", this).parent("label").addClass(chbClass);
  293. $("input[type='checkbox']", this).click(function () {
  294. if ($(this).parent("label").hasClass(chbchecked)) {
  295. $(this).removeAttr("checked").parent("label").removeClass(chbchecked);
  296. } else {
  297. $(this).attr("checked", true).parent("label").addClass(chbchecked);
  298. }
  299. });
  300. $("input[type='checkbox']", this).each(function () {
  301. if ($(this).attr("checked")) {
  302. $(this).attr("checked", true).parent("label").addClass(chbchecked);
  303. }
  304. });
  305. if ($(this).children(".sp-checkbox-all").length = 1) {
  306. $(".sp-checkbox-all", this).click(function () {
  307. if ($(this).hasClass("hasClick")) {
  308. $(this).removeClass("hasClick");
  309. $(this).parent().parent().find("input[type='checkbox']").removeAttr("checked");
  310. $(this).parent().parent().find("label").removeClass(chbchecked);
  311. } else {
  312. $(this).addClass("hasClick");
  313. $(this).parent().parent().find("input[type='checkbox']").attr("checked", true);
  314. $(this).parent().parent().find("label").addClass(chbchecked);
  315. }
  316. });
  317. }
  318. });
  319. }
  320. sp.checkbox = function () {
  321. /// <summary>美化checkbox</summary>
  322. if ($("body").find(".sp-checkbox-gray").length > 0) {
  323. sp.funcheckbox(".sp-checkbox-gray", "chb-gray", "chb-gray-checked"); //蓝色checkbox
  324. }
  325. if ($("body").find(".sp-checkbox-blue").length > 0) {
  326. sp.funcheckbox(".sp-checkbox-blue", "chb-blue", "chb-blue-checked"); //蓝色checkbox
  327. }
  328. if ($("body").find(".sp-checkbox-orange").length > 0) {
  329. sp.funcheckbox(".sp-checkbox-orange", "chb-orange", "chb-orange-checked");//橙色checkbox
  330. }
  331. if ($("body").find(".sp-checkbox-none").length > 0) {
  332. sp.funcheckbox(".sp-checkbox-none", "chb-none", "chb-none-checked");//无皮肤checkbox
  333. }
  334. }
  335. //设置upload 文件上传file控件--原生调用
  336. ////图片是转成base64,文件上传是模拟假的
  337. sp.upload = function () {
  338. /// <summary>美化file控件</summary>
  339. if ($("body").find(".sp-upload-file").length > 0) {
  340. $(".sp-upload .sp-upload-file").change(function () {
  341. if ($(this).parent().children(".sp-upload-url").length > 0) {
  342. var file = this.files[0];
  343. if (file.size > 52428800) {
  344. alert("文件大小不能大于50M");
  345. file = null;
  346. return false;
  347. } else {
  348. var fileUrl = $(this).val();
  349. $(this).parent().children(".sp-upload-url").val(fileUrl);
  350. }
  351. } else if ($(this).parent().children(".sp-upload-btn-single").length > 0) {
  352. var file = this.files[0];
  353. if (file.size > 52428800) {
  354. alert("文件大小不能大于50M");
  355. file = null;
  356. return false;
  357. } else {
  358. var fileUrl = $(this).val();
  359. var urlArr = fileUrl.split("\\");
  360. var getName = urlArr[urlArr.length - 1];//截取路径并获取文件的名字
  361. var setdiv = "<div class='sp-lh-20'>" + getName + "</div>";
  362. $(this).parent().children(".sp-upload-tip").show(200).append(setdiv);
  363. }
  364. }
  365. });
  366. }
  367. ////图片上传组件
  368. if ($("body").find(".sp-upload-file-img").length > 0) {
  369. $(".sp-upload-file-img").each(function () {
  370. var getimgWidth = $(this).prev(".sp-upload-img").outerWidth();
  371. $(this).css({ width: getimgWidth });
  372. });
  373. $(".sp-upload .sp-upload-file-img").change(function () {
  374. var file = this.files[0];
  375. if (file.size > 5242880) {
  376. alert("图片大小不能大于5M");
  377. file = null;
  378. return false;
  379. }
  380. var fileName = file.name;
  381. var postfix = fileName.substring(fileName.lastIndexOf(".") + 1).toLowerCase();
  382. if (postfix != "jpg" && postfix != "png" && postfix != "jpeg" && postfix != "gif") {
  383. alert("图片仅支持png、jpg、jpeg、gif类型的文件");
  384. fileName = "";
  385. file = null;
  386. return false;
  387. }
  388. var fileUrl = $(this).val();
  389. $(this).parent().children(".sp-upload-img").attr("data-url", fileUrl);
  390. var getimg = $(this).parent().children(".sp-upload-img");
  391. var filereader = new FileReader();
  392. filereader.readAsDataURL(file);
  393. $(filereader).load(function () {
  394. getimg.attr("src", this.result);
  395. });
  396. });
  397. }
  398. }
  399. ////图片上传组件---正式利用ajax连接后端服务的真实功能,谨慎用,记得检查各个项目的端口地址【20180921zyg】
  400. ///sp.uploadimg("http://103.233.7.57:8080/GoldFile/image/upload");
  401. sp.uploadimg = function (imgUpUrl) {
  402. if (!imgUpUrl) {
  403. alert("您好,图片上传组件的数据库路径不能为空");
  404. } else if ($("body").find(".sp-upload-file-img").length > 0) {
  405. //此是设置图片上传file控件跟其上部的img宽度设为一致,解决点击img右侧外部区域触发上传事件的bug
  406. $(".sp-upload-file-img").each(function () {
  407. var getimgWidth = $(this).prev(".sp-upload-img").outerWidth();
  408. $(this).css({ width: getimgWidth });
  409. });
  410. $(".sp-upload .sp-upload-file-img").change(function () {
  411. var file = this.files[0];
  412. if (file.size > 5242880) {
  413. //5M:5242880,10M:10485760,20M:2097120,30M:31457280,40M:41943040,50M:52428800,100M:104857600
  414. alert("图片大小不能大于5M");
  415. file = null;
  416. return false;
  417. }
  418. var fileName = file.name;
  419. var postfix = fileName.substring(fileName.lastIndexOf(".") + 1).toLowerCase();
  420. if (postfix != "jpg" && postfix != "png" && postfix != "jpeg" && postfix != "gif") {
  421. alert("图片仅支持png、jpg、jpeg、gif类型的文件");
  422. fileName = "";
  423. file = null;
  424. return false;
  425. }
  426. var fileUrl = $(this).val();
  427. $(this).parent().children(".sp-upload-img").attr("data-url", fileUrl).attr("data-name", fileName);
  428. var getimg = $(this).parent().children(".sp-upload-img");
  429. var filereader = new FileReader();
  430. filereader.readAsDataURL(file);
  431. $(filereader).load(function () {
  432. //getimg.attr("src", this.result);
  433. /////post给另外一个服务器生成一个文件地址,再返回
  434. var picBase = this.result;
  435. var picName = file.name;
  436. var str = "base64,"
  437. var begin = picBase.indexOf(str) + str.length;
  438. picBase = picBase.substring(begin, picBase.length);
  439. var data = {
  440. "filename": picName,
  441. "filedata": picBase
  442. }
  443. ////将base64和文件名传给后台
  444. $.ajax({
  445. url: imgUpUrl,
  446. type: 'post',
  447. contentType: "application/json",
  448. data: JSON.stringify(data),
  449. dataType: "json",
  450. success: function (res) {
  451. if (res.success) {
  452. //sp.dialog("图片上传成功");
  453. //$("#eventIMG").attr("src", res.url);
  454. getimg.attr("src", res.url); ///将文件路径赋给图片
  455. } else {
  456. alert("你好,图片上传失败");
  457. }
  458. }
  459. });
  460. });
  461. });
  462. } else { return;}
  463. };
  464. ////小文件上传组件---正式利用ajax连接后端服务的真实功能,谨慎用,记得检查各个项目的端口地址【20180921zyg】
  465. ///sp.uploadfile("http://103.233.7.57:8080/GoldFile/stream/upload");
  466. sp.uploadfile = function (fileUpUrl) {
  467. //$("#fbMainTableProgress_13").show();
  468. //$("#fbMainTableProgress_13").myProgress({ speed: 1000, percent: 30, width: "100%", height: "10px" });
  469. if (!fileUpUrl) {
  470. alert("您好,附件上传的数据库路径不能为空");
  471. } else if ($("body").find(".sp-upload-file-single").length > 0) {
  472. $(".sp-upload .sp-upload-file-single").change(function () {
  473. ////按钮风格
  474. var tip = $(this).parent().children(".sp-upload-tip");////获取显示文件及进度条的区域元素
  475. tip.show();///发生变化,让其显示
  476. var getfiles = this.files;
  477. var setindex = 0;
  478. sp.uploadfile_submit(tip, setindex, getfiles, fileUpUrl); ///调用方法,
  479. });
  480. } else { return;}
  481. };
  482. sp.uploadfile_submit = function (tip, index, getfiles, fileUpUrl) {
  483. ///传递三个变量,tip元素,index递归顺序量,getfiles全部文件
  484. var setindex = index;
  485. var fileItem = getfiles[setindex];///声明文件流中的第几个文件
  486. var getName = fileItem.name;//声明文件的名字
  487. var fileItemSize = fileItem.size; ////声明文件的大小
  488. var hasfilevar = 0;///声明变量记录是否有重复文件
  489. tip.find(".sp-upload-tip-lh").each(function () {
  490. if (getName == $(this).attr("data-name")) {
  491. alert("文件<" + getName + ">不能重复上传");
  492. hasfilevar = 1;
  493. //fileItem = null;
  494. };
  495. });
  496. if (hasfilevar != 1) {
  497. ////不含重复上传的重名文件
  498. if (fileItemSize > 10485760) {
  499. //5M:5242880,10M:10485760,20M:2097120,30M:31457280,40M:41943040,50M:52428800,100M:104857600
  500. alert("文件<" + getName + ">大小不能大于10M"); ///目前为了防止恶意上传,限制10M;后期根据项目需要进行更改
  501. fileItem = null;
  502. return false;
  503. } else {
  504. var fileSize = 0;
  505. if (fileItemSize > 1024 * 1024) {
  506. fileSize = (Math.round(fileItemSize * 100 / (1024 * 1024)) / 100).toString() + 'MB';
  507. }
  508. else {
  509. fileSize = (Math.round(fileItemSize * 100 / 1024) / 100).toString() + 'KB';
  510. }
  511. //往tip中append---sp-upload-tip-lh
  512. 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>";
  513. tip.append(settiplh);
  514. var eqtiplh = tip.find(".sp-upload-tip-lh:last-child");//得到刚添加的最后一个.sp-upload-tip-lh元素
  515. var fileProgress = eqtiplh.children(".sp-progress");////其下进度条
  516. fileProgress.show();
  517. //eqtiplh.show();
  518. var formData = new FormData();///声明FormData
  519. formData.append("streamFile", fileItem); ///将存放在参数名streamFile中的file中的数据一起append到formData
  520. var date1 = new Date();
  521. $.ajax({
  522. url: fileUpUrl,
  523. type: 'POST',
  524. cache: false, //上传文件无需缓存
  525. data: formData,
  526. async: true, ///异步true,同步false
  527. processData: false,// 是否序列化data属性,默认true(注意:false时type必须是post)
  528. contentType: false,// 当有文件要上传时,此项是必须的,否则后台无法识别文件流的起始位置
  529. xhr: function () {
  530. //这是关键 获取原生的xhr对象
  531. var xhr = jQuery.ajaxSettings.xhr();
  532. /////监测上传进度
  533. xhr.upload.onprogress = function (ev) {
  534. if (ev.lengthComputable) {
  535. var percent = 100 * ev.loaded / ev.total;
  536. fileProgress.myProgress({ speed: 0, percent: percent.toFixed(0), width: "100%", height: "10px" });
  537. //console.log(percent, ev); ///打印百分比以及进度
  538. }
  539. }
  540. ////上传完成后
  541. xhr.upload.onload = function () {
  542. setTimeout(function () {
  543. fileProgress.hide();
  544. eqtiplh.children(".sp-upload-tip-info").show().append("" + getName + "(" + fileSize + ")-上传成功<i class='fa fa-close sp-upload-tip-close'> 删除</i>");
  545. $(".sp-upload .sp-upload-tip-lh").each(function () {
  546. $(".fa-close", this).click(function () {
  547. $(this).parents(".sp-upload-tip-lh").remove();
  548. });
  549. });
  550. }, 200);
  551. }
  552. return xhr;
  553. },
  554. success: function (res) {
  555. eqtiplh.attr("data-url", res.url).attr("data-size", fileItemSize);
  556. },
  557. error: function (data, status, e) {
  558. alert("您好,附件上传失败");
  559. console.log(e);
  560. }
  561. });
  562. }
  563. }
  564. ///递归循环调用此方法,加个延时防止异步加载返回值冲突
  565. setTimeout(function () {
  566. if (setindex < getfiles.length - 1) {
  567. setindex++;
  568. sp.uploadfile_submit(tip, setindex, getfiles); ///调用方法
  569. };
  570. }, 100);
  571. };
  572. ///div自适应分辨率高度 使用: fitHeight('#id', 50);fitHeight('.class', 50);
  573. sp.fitHeight = function (Name, Height) {
  574. /// <summary>自适应分辨率的高度</summary>
  575. $(document).ready(function () { //DOM加载后就执行
  576. var WindowHeight = $(window).height();
  577. $(Name).css('height', WindowHeight - Height);
  578. });
  579. $(window).resize(function () { //改变窗体大小时 *resize()变化或者改变事件
  580. var WindowHeight = $(window).height();
  581. $(Name).css('height', WindowHeight - Height);
  582. });
  583. $(window).scroll(function () { //浏览器有滚动条时的操作 scroll()滚动事件
  584. var WindowHeight = $(window).height();
  585. $(Name).css('height', WindowHeight - Height);
  586. });
  587. }
  588. ///div自适应分辨率高度 使用: fitWidth('#id', 50);fitWidth('.class', 50);
  589. sp.fitWidth = function (Name, width) {
  590. /// <summary>自适应分辨率宽度</summary>
  591. $(document).ready(function () { //DOM加载后就执行
  592. var WindownWidth = $(window).width();
  593. $(Name).css('width', (WindownWidth - width) + 'px');
  594. });
  595. $(window).resize(function () { //改变窗体大小时 *resize()变化或者改变事件
  596. var WindownWidth = $(window).width();
  597. $(Name).css('width', (WindownWidth - width) + 'px');
  598. });
  599. $(window).scroll(function () { //浏览器有滚动条时的操作 scroll()滚动事件
  600. var WindownWidth = $(window).width();
  601. $(Name).css('width', (WindownWidth - width) + 'px');
  602. });
  603. }
  604. //操作table
  605. sp.table = function () {
  606. /// <summary>设置table</summary>
  607. if ($('body').find(".sp-grid").length > 0) {
  608. $('.sp-grid-striped tbody tr:odd').addClass('evenTr');//奇数行背景色
  609. $('.sp-grid tbody tr:last-child td').css('border-bottom', '0');
  610. $('.sp-grid-select tbody tr').click(function () {
  611. if ($(this).hasClass('sp-grid-trselected')) {
  612. $(this).removeClass('sp-grid-trselected')
  613. }
  614. else {
  615. $(this).addClass('sp-grid-trselected').siblings().removeClass('sp-grid-trselected');
  616. }
  617. });
  618. }
  619. //$('.grid tbody tr td').each(function () {
  620. // $(this).attr("title", $(this).text());//加上title属性
  621. //});
  622. }
  623. /**sp.getPage(URL, ID);调用Ajax获取数据集 <param name="URL">URL地址</param>**/
  624. sp.getPage = function (URL, ID) {
  625. /// 调用Ajax获取数据集 <param name="URL">URL地址</param> <returns>返回数据集</returns>
  626. sp.AjaxControl(URL, function (result) {
  627. $(ID).html(result);
  628. });
  629. };
  630. /**Common.AjaxControl(URL, callBack);调用Ajax操作**/
  631. sp.AjaxControl = function (URL, callBack) {
  632. /// 调用Ajax操作数据库(底层方法)
  633. /// <param name="URL">URL地址</param>
  634. /// <param name="callBack">回调函数的作用就是在Ajax成功执行之后可以执行一个函数</param>
  635. /// <returns>返回数据集</returns>
  636. $.ajax({
  637. url: URL, //这里是静态页的地址
  638. type: "GET", //静态页用get方法,否则服务器会抛出405错误
  639. //cache: false,
  640. async: false,
  641. success: function (result) {
  642. callBack(result);
  643. },
  644. //请求执行异常后,执行的方法
  645. error: function (XMLHttpRequest, textStatus, errorThrown) {
  646. alert("没有找到页面源!");
  647. }
  648. });
  649. };
  650. //操作5级菜单
  651. sp.setLeftMenu = function () {
  652. $(".sp-leftmenu-first").children("a").on("click", function () {
  653. if ($(this).hasClass("hasclick")) {
  654. $(this).removeClass("hasclick").parents(".sp-leftmenu-first").find(".sp-leftmenu-second").slideUp(300);
  655. if ($(this).children(".sp-leftmenu-icon").length > 0) {
  656. $('.sub-logo', this).show();
  657. $('.sub-logo-hide', this).hide();
  658. }
  659. } else {
  660. //点击一级菜单时,如果已经折叠,取消折叠样式,
  661. if ($('#spWrapperLeftBar').hasClass('sp-leftmenu-fold')) {
  662. $('#spWrapperLeftBar').removeClass("sp-leftmenu-fold");
  663. $("#setLeftMenu_fold").removeClass("hasclick");
  664. $('.sp-wrapper-left').css('width', '140px');
  665. $('.sp-wrapper-right').css('left', '140px');
  666. }
  667. $(this).addClass("hasclick").addClass("sp-leftmenu-active");
  668. var leftmenufirst = $(this).parents(".sp-leftmenu-first");
  669. leftmenufirst.siblings().children("a").removeClass('sp-leftmenu-active').removeClass("hasclick");
  670. if ($(this).children(".sp-leftmenu-icon").length > 0) {
  671. //含有子菜单
  672. $('.sub-logo', this).hide();
  673. $('.sub-logo-hide', this).show();
  674. leftmenufirst.find(".sp-leftmenu-second").slideDown(300);//其下二级菜单展开
  675. } else {
  676. //不含子菜单
  677. var get_clickID = $(this).attr('id');//获取menuClick的id
  678. localStorage.setItem("GlWorkPlatform-setLeftBarClickID", get_clickID);
  679. }
  680. leftmenufirst.siblings().find('.sub-logo').show(); //其他一级菜单下右侧图标恢复
  681. leftmenufirst.siblings().find('.sub-logo-hide').hide();//其他一级菜单下右侧图标恢复
  682. leftmenufirst.siblings('li').find('li').slideUp(300);
  683. }
  684. });
  685. $(".sp-leftmenu-second").children("a").on("click", function () {
  686. if ($(this).hasClass("hasclick")) {
  687. $(this).removeClass("hasclick").removeClass("leftmenuClick").parents(".sp-leftmenu-second").find(".sp-leftmenu-third").slideUp(300);
  688. if ($(this).children(".sp-leftmenu-icon").length > 0) {
  689. $('.sub-logo', this).show();
  690. $('.sub-logo-hide', this).hide();
  691. }
  692. } else {
  693. $(this).addClass("hasclick").addClass("leftmenuClick");
  694. var leftmenufirst = $(this).parents(".sp-leftmenu-first");
  695. var leftmenuSecond = $(this).parents(".sp-leftmenu-second");
  696. if ($(this).children(".sp-leftmenu-icon").length > 0) {
  697. ///含有子菜单时
  698. $('.sub-logo', this).hide();
  699. $('.sub-logo-hide', this).show();
  700. leftmenuSecond.find(".sp-leftmenu-third").slideDown(300); ///当前级别三级菜单打开
  701. } else {
  702. //其下不含有子菜单
  703. var get_clickID = $(this).attr('id');//获取menuClick的id
  704. localStorage.setItem("GlWorkPlatform-setLeftBarClickID", get_clickID);
  705. }
  706. leftmenuSecond.siblings().find("li").slideUp(300); //其他二级菜单下三级菜单折叠
  707. leftmenuSecond.siblings().children("a").removeClass("hasclick").removeClass("leftmenuClick"); //其他二级菜单去掉样式
  708. leftmenuSecond.siblings().find('.sub-logo').show(); //其他二级菜单下右侧图标恢复
  709. leftmenuSecond.siblings().find('.sub-logo-hide').hide();//其他二级菜单下右侧图标恢复
  710. leftmenufirst.siblings().find("a").removeClass("hasclick").removeClass("leftmenuClick");///其他一级下菜单去掉样式
  711. }
  712. });
  713. $(".sp-leftmenu-third").children("a").on("click", function () {
  714. if ($(this).hasClass("hasclick")) {
  715. $(this).removeClass("hasclick").removeClass("leftmenuClick").parents(".sp-leftmenu-third").find(".sp-leftmenu-fourth").slideUp(300);
  716. if ($(this).children(".sp-leftmenu-icon").length > 0) {
  717. $('.sub-logo', this).show();
  718. $('.sub-logo-hide', this).hide();
  719. }
  720. } else {
  721. $(this).addClass("hasclick").addClass("leftmenuClick");
  722. var leftmenufirst = $(this).parents(".sp-leftmenu-first");
  723. var leftmenuSecond = $(this).parents(".sp-leftmenu-second");
  724. var leftmenuThird = $(this).parents(".sp-leftmenu-third");
  725. if ($(this).children(".sp-leftmenu-icon").length > 0) {
  726. ///含有子菜单时
  727. $('.sub-logo', this).hide();
  728. $('.sub-logo-hide', this).show();
  729. leftmenuThird.find(".sp-leftmenu-fourth").slideDown(300); ///当前级别四级菜单打开
  730. } else {
  731. //其下不含有子菜单
  732. var get_clickID = $(this).attr('id');//获取menuClick的id
  733. localStorage.setItem("GlWorkPlatform-setLeftBarClickID", get_clickID);
  734. }
  735. leftmenuThird.siblings().find("li").slideUp(300); //其他三级菜单下四级菜单折叠
  736. leftmenuThird.siblings().find("a").removeClass("hasclick").removeClass("leftmenuClick"); //其他三级菜单去掉样式
  737. leftmenuThird.siblings().find('.sub-logo').show(); //其他同级菜单下右侧图标恢复
  738. leftmenuThird.siblings().find('.sub-logo-hide').hide();//其他同级菜单下右侧图标恢复
  739. leftmenuSecond.siblings().find("a").removeClass("hasclick").removeClass("leftmenuClick");///其他二级下菜单去掉样式
  740. leftmenufirst.siblings().find("a").removeClass("hasclick").removeClass("leftmenuClick");///其他一级下菜单去掉样式
  741. leftmenuSecond.children("a").removeClass("leftmenuClick");///父级二级菜单去掉样式
  742. };
  743. });
  744. $(".sp-leftmenu-fourth").children("a").on("click", function () {
  745. if ($(this).hasClass("hasclick")) {
  746. $(this).removeClass("hasclick").removeClass("leftmenuClick").parents(".sp-leftmenu-fourth").find(".sp-leftmenu-fifth").slideUp(300);
  747. if ($(this).children(".sp-leftmenu-icon").length > 0) {
  748. $('.sub-logo', this).show();
  749. $('.sub-logo-hide', this).hide();
  750. }
  751. } else {
  752. $(this).addClass("hasclick").addClass("leftmenuClick");
  753. var leftmenufirst = $(this).parents(".sp-leftmenu-first");
  754. var leftmenuSecond = $(this).parents(".sp-leftmenu-second");
  755. var leftmenuThird = $(this).parents(".sp-leftmenu-third");
  756. var leftmenuFourth = $(this).parents(".sp-leftmenu-fourth");
  757. if ($(this).children(".sp-leftmenu-icon").length > 0) {
  758. ///含有子菜单时
  759. $('.sub-logo', this).hide();
  760. $('.sub-logo-hide', this).show();
  761. leftmenuFourth.find(".sp-leftmenu-fifth").slideDown(300); ///当前级别四级菜单打开
  762. } else {
  763. //其下不含有子菜单
  764. var get_clickID = $(this).attr('id');//获取menuClick的id
  765. localStorage.setItem("GlWorkPlatform-setLeftBarClickID", get_clickID);
  766. }
  767. leftmenuFourth.siblings().find("li").slideUp(300); //其他四级菜单下五级菜单折叠
  768. leftmenuFourth.siblings().find("a").removeClass("hasclick").removeClass("leftmenuClick"); //其他四级菜单去掉样式
  769. leftmenuFourth.siblings().find('.sub-logo').show(); //其他同级菜单下右侧图标恢复
  770. leftmenuFourth.siblings().find('.sub-logo-hide').hide();//其他同级菜单下右侧图标恢复
  771. leftmenuThird.siblings().find("a").removeClass("hasclick").removeClass("leftmenuClick");///其他三级下菜单去掉样式
  772. leftmenuSecond.siblings().find("a").removeClass("hasclick").removeClass("leftmenuClick");///其他二级下菜单去掉样式
  773. leftmenufirst.siblings().find("a").removeClass("hasclick").removeClass("leftmenuClick");///其他一级下菜单去掉样式
  774. leftmenuThird.children("a").removeClass("leftmenuClick");///父级三级菜单去掉样式
  775. leftmenuSecond.children("a").removeClass("leftmenuClick");///父级二级菜单去掉样式
  776. };
  777. });
  778. $(".sp-leftmenu-fifth").children("a").on("click", function () {
  779. if ($(this).hasClass("hasclick")) {
  780. $(this).removeClass("hasclick").removeClass("leftmenuClick");
  781. } else {
  782. $(this).addClass("hasclick").addClass("leftmenuClick");
  783. var leftmenufirst = $(this).parents(".sp-leftmenu-first");
  784. var leftmenuSecond = $(this).parents(".sp-leftmenu-second");
  785. var leftmenuThird = $(this).parents(".sp-leftmenu-third");
  786. var leftmenuFourth = $(this).parents(".sp-leftmenu-fourth");
  787. var leftmenuFifth = $(this).parents(".sp-leftmenu-fifth");
  788. if ($(this).children(".sp-leftmenu-icon").length > 0) {
  789. ///含有子菜单时
  790. $('.sub-logo', this).hide();
  791. $('.sub-logo-hide', this).show();
  792. leftmenuFourth.find(".sp-leftmenu-fifth").slideDown(300); ///当前级别四级菜单打开
  793. } else {
  794. //其下不含有子菜单
  795. var get_clickID = $(this).attr('id');//获取menuClick的id
  796. localStorage.setItem("GlWorkPlatform-setLeftBarClickID", get_clickID);
  797. }
  798. leftmenuFifth.siblings().find("a").removeClass("hasclick").removeClass("leftmenuClick"); //其他五级菜单去掉样式
  799. leftmenuFourth.siblings().find("a").removeClass("hasclick").removeClass("leftmenuClick");///其他四级下菜单去掉样式
  800. leftmenuThird.siblings().find("a").removeClass("hasclick").removeClass("leftmenuClick");///其他三级下菜单去掉样式
  801. leftmenuSecond.siblings().find("a").removeClass("hasclick").removeClass("leftmenuClick");///其他二级下菜单去掉样式
  802. leftmenufirst.siblings().find("a").removeClass("hasclick").removeClass("leftmenuClick");///其他一级下菜单去掉样式
  803. leftmenuFourth.children("a").removeClass("leftmenuClick");///父级四级菜单去掉样式
  804. leftmenuThird.children("a").removeClass("leftmenuClick");///父级三级菜单去掉样式
  805. leftmenuSecond.children("a").removeClass("leftmenuClick");///父级二级菜单去掉样式
  806. };
  807. });
  808. //左侧最上折叠/打开左侧菜单 按钮
  809. $("#setLeftMenu_fold").on("click", function () {
  810. if ($(this).hasClass("hasclick")) {
  811. $(this).removeClass("hasclick");
  812. $('#spWrapperLeftBar').removeClass("sp-leftmenu-fold");
  813. $('.sp-wrapper-left').css('width', '140px');
  814. $(".sp-wrapper-right").css("left", "140px");
  815. }
  816. else {
  817. $(this).addClass("hasclick");
  818. $('#spWrapperLeftBar').addClass("sp-leftmenu-fold");
  819. $('.sp-wrapper-left').css('width', '40px');
  820. $(".sp-wrapper-right").css("left", "40px");
  821. }
  822. });
  823. };
  824. //操作皮肤变色,将变色id加到localStorage中
  825. sp.setCssSkin = function () {
  826. //选择皮肤
  827. if ($("body").find(".sp-skin-box").length > 0) {
  828. var li = $(".sp-skin-box span");
  829. li.click(function () {
  830. var id = $(this).attr('id');
  831. $(this).addClass("sp-skin-current").siblings().removeClass("sp-skin-current");
  832. $("#skin_color").attr("href", "AFrontEnd/css/skin/" + id + ".css");
  833. localStorage.setItem("GlWorkPlatform-cssSkin", id);
  834. });
  835. var cookieSkin = localStorage.getItem("GlWorkPlatform-cssSkin");
  836. if (cookieSkin) {
  837. $("#" + cookieSkin).addClass("sp-skin-current").siblings().removeClass("sp-skin-current");
  838. $("#skin_color").attr("href", "AFrontEnd/css/skin/" + cookieSkin + ".css");
  839. localStorage.setItem("GlWorkPlatform-cssSkin", cookieSkin);
  840. }
  841. }
  842. }
  843. sp.setCssSkinTwo = function () {
  844. //选择皮肤
  845. if ($("body").find(".sp-skin-box").length > 0) {
  846. var li = $(".sp-skin-box span");
  847. li.click(function () {
  848. var id = $(this).attr('id');
  849. $(this).addClass("sp-skin-current").siblings().removeClass("sp-skin-current");
  850. $("#skin_color").attr("href", "AFrontEnd/css/skintwo/" + id + ".css");
  851. localStorage.setItem("GlWorkPlatform-cssSkin", id);
  852. });
  853. var cookieSkin = localStorage.getItem("GlWorkPlatform-cssSkin");
  854. if (cookieSkin) {
  855. $("#" + cookieSkin).addClass("sp-skin-current").siblings().removeClass("sp-skin-current");
  856. $("#skin_color").attr("href", "AFrontEnd/css/skintwo/" + cookieSkin + ".css");
  857. localStorage.setItem("GlWorkPlatform-cssSkin", cookieSkin);
  858. }
  859. }
  860. }
  861. ///根据localStorage中存的菜单id,加载到设置中 20180801改
  862. sp.setLeftMenuActiveByCookie = function () {
  863. //判断存到的ID 然后进行一级、二级、三级的判断
  864. var cookie_clickID = localStorage.getItem("GlWorkPlatform-setLeftBarClickID");
  865. //加上条件,在其不能为空或者null时方可执行
  866. if (cookie_clickID != "" && cookie_clickID != null) {
  867. localStorage.setItem("GlWorkPlatform-setLeftBarClickID", cookie_clickID);
  868. //获取ID的class,然后进行一级、二级、三级的判断
  869. var get_className = $("#" + cookie_clickID).parent().attr('class');
  870. if (get_className != "" && get_className != null && get_className != undefined) {
  871. if (get_className.indexOf('sp-leftmenu-first') != -1) {
  872. ///仅有一级菜单时
  873. sp.restoreHomeFirst("#" + cookie_clickID);
  874. }
  875. else if (get_className.indexOf('sp-leftmenu-second') != -1) {
  876. ///含有有二级菜单时
  877. sp.restoreHomeSecond("#" + cookie_clickID);
  878. }
  879. else if (get_className.indexOf("sp-leftmenu-third") != -1) {
  880. //三级three
  881. sp.restoreHomeThird("#" + cookie_clickID);
  882. }
  883. else if (get_className.indexOf('sp-leftmenu-fourth') != -1) {///四级 .four
  884. sp.restoreHomeFourth("#" + cookie_clickID);
  885. }
  886. else if (get_className.indexOf('sp-leftmenu-fifth') != -1) {///五级 .five
  887. sp.restoreHomeFifth("#" + cookie_clickID);
  888. } else { return; }
  889. }
  890. }
  891. }
  892. ///当首页文件处在一级时
  893. sp.restoreHomeFirst = function (getfileid) {
  894. $(getfileid).addClass("hasclick").addClass("sp-leftmenu-active");
  895. var leftmenufirst = $(getfileid).parents(".sp-leftmenu-first");
  896. leftmenufirst.siblings().children("a").removeClass('sp-leftmenu-active').removeClass("hasclick");
  897. leftmenufirst.siblings().find('.sub-logo').show(); //其他一级菜单下右侧图标恢复
  898. leftmenufirst.siblings().find('.sub-logo-hide').hide();//其他一级菜单下右侧图标恢复
  899. leftmenufirst.siblings('li').find('li').slideUp(300);
  900. leftmenufirst.children("a").find('.sub-logo').hide(); //右侧图标变化
  901. leftmenufirst.children("a").find('.sub-logo-hide').show();
  902. };
  903. ///当首页文件处在二级时
  904. sp.restoreHomeSecond = function (getfileid) {
  905. $(getfileid).addClass("hasclick").addClass("leftmenuClick");
  906. var leftmenufirst = $(getfileid).parents(".sp-leftmenu-first");
  907. var leftmenuSecond = $(getfileid).parents(".sp-leftmenu-second");
  908. leftmenuSecond.siblings().find("li").slideUp(300); //其他二级菜单下三级菜单折叠
  909. leftmenuSecond.siblings().children("a").removeClass("hasclick").removeClass("leftmenuClick"); //其他二级菜单去掉样式
  910. leftmenuSecond.siblings().find('.sub-logo').show(); //其他二级菜单下右侧图标恢复
  911. leftmenuSecond.siblings().find('.sub-logo-hide').hide();//其他二级菜单下右侧图标恢复
  912. leftmenufirst.find(".sp-leftmenu-second").slideDown(300); ///当前级别二级菜单打开
  913. leftmenufirst.children("a").find('.sub-logo').hide();
  914. leftmenufirst.children("a").find('.sub-logo-hide').show();///右侧图标变化
  915. leftmenufirst.children("a").addClass("sp-leftmenu-active");
  916. leftmenufirst.siblings().find('li').slideUp(300);
  917. leftmenufirst.siblings().find('.sub-logo').show();
  918. leftmenufirst.siblings().find('.sub-logo-hide').hide(); //其他一级菜单下右侧图标恢复
  919. leftmenufirst.siblings().find("a").removeClass("hasclick").removeClass("leftmenuClick").removeClass("sp-leftmenu-active");///其他一级下菜单去掉样式
  920. };
  921. ///当首页文件 处在三级时
  922. sp.restoreHomeThird = function (getfileid) {
  923. //三级three
  924. $(getfileid).addClass("hasclick").addClass("leftmenuClick");
  925. var leftmenufirst = $(getfileid).parents(".sp-leftmenu-first");
  926. var leftmenuSecond = $(getfileid).parents(".sp-leftmenu-second");
  927. var leftmenuThird = $(getfileid).parents(".sp-leftmenu-third");
  928. leftmenuThird.siblings().find("li").slideUp(300); //其他三级菜单下四级菜单折叠
  929. leftmenuThird.siblings().find("a").removeClass("hasclick").removeClass("leftmenuClick"); //其他三级菜单去掉样式
  930. leftmenuThird.children("a").find('.sub-logo').hide();
  931. leftmenuThird.children("a").find('.sub-logo-hide').show(); ///右侧图标变化
  932. leftmenuThird.siblings().find('.sub-logo').show();
  933. leftmenuThird.siblings().find('.sub-logo-hide').hide(); //其他同级菜单下右侧图标恢复
  934. leftmenuSecond.find(".sp-leftmenu-third").slideDown(300); ///当前级别三级菜单打开
  935. leftmenuSecond.siblings().find("li").slideUp(300); //其他二级菜单下三级菜单折叠
  936. leftmenuSecond.siblings().children("a").removeClass("hasclick").removeClass("leftmenuClick"); //其他二级菜单去掉样式
  937. leftmenuSecond.children("a").find('.sub-logo').hide();
  938. leftmenuSecond.children("a").find('.sub-logo-hide').show(); //其右侧标变化
  939. leftmenuSecond.siblings().find('.sub-logo').show();
  940. leftmenuSecond.siblings().find('.sub-logo-hide').hide(); //其他二级菜单下右侧图标恢复
  941. leftmenufirst.siblings().find("a").removeClass("hasclick").removeClass("leftmenuClick").removeClass("sp-leftmenu-active");///其他一级下菜单去掉样式
  942. leftmenufirst.find(".sp-leftmenu-second").slideDown(300); ///当前级别二级菜单打开
  943. leftmenufirst.children("a").find('.sub-logo').hide();
  944. leftmenufirst.children("a").find('.sub-logo-hide').show();
  945. leftmenufirst.children("a").addClass("sp-leftmenu-active");
  946. leftmenufirst.siblings().find('li').slideUp(300);
  947. leftmenufirst.siblings().find('.sub-logo').show();
  948. leftmenufirst.siblings().find('.sub-logo-hide').hide(); //其他一级菜单下右侧图标恢复
  949. };
  950. ///当首页文件处在四级时
  951. sp.restoreHomeFourth = function (getfileid) {
  952. $(getfileid).addClass("hasclick").addClass("leftmenuClick");
  953. var leftmenufirst = $(getfileid).parents(".sp-leftmenu-first");
  954. var leftmenuSecond = $(getfileid).parents(".sp-leftmenu-second");
  955. var leftmenuThird = $(getfileid).parents(".sp-leftmenu-third");
  956. var leftmenuFourth = $(getfileid).parents(".sp-leftmenu-fourth");
  957. leftmenuFourth.siblings().find("li").slideUp(300); //其他四级菜单下五级菜单折叠
  958. leftmenuFourth.siblings().find("a").removeClass("hasclick").removeClass("leftmenuClick"); //其他四级菜单去掉样式
  959. leftmenuFourth.children("a").find('.sub-logo').hide();
  960. leftmenuFourth.children("a").find('.sub-logo-hide').show(); //其右侧标变化
  961. leftmenuFourth.siblings().find('.sub-logo').show().find('.sub-logo-hide').hide(); //其他同级菜单下右侧图标恢复
  962. leftmenufirst.find(".sp-leftmenu-second").slideDown(300);//其下二级菜单展开
  963. leftmenufirst.siblings('li').find('li').slideUp(300);
  964. leftmenufirst.siblings().find("a").removeClass("hasclick").removeClass("leftmenuClick").removeClass("sp-leftmenu-active");///其他一级下菜单去掉样式
  965. leftmenufirst.children("a").addClass("sp-leftmenu-active");
  966. leftmenufirst.children("a").find('.sub-logo').hide();
  967. leftmenufirst.children("a").find('.sub-logo-hide').show();
  968. leftmenufirst.siblings().find('.sub-logo').show();
  969. leftmenufirst.siblings().find('.sub-logo-hide').hide(); //其他一级菜单下右侧图标恢复
  970. leftmenuSecond.find(".sp-leftmenu-third").slideDown(300); ///当前级别三级菜单打开
  971. leftmenuSecond.siblings().find("a").removeClass("hasclick").removeClass("leftmenuClick");///其他二级下菜单去掉样式
  972. leftmenuSecond.siblings().children("a").removeClass("hasclick").removeClass("leftmenuClick"); //其他二级菜单去掉样式
  973. leftmenuSecond.children("a").find('.sub-logo').hide();
  974. leftmenuSecond.children("a").find('.sub-logo-hide').show(); //其右侧标变化
  975. leftmenuSecond.siblings().find('.sub-logo').show();
  976. leftmenuSecond.siblings().find('.sub-logo-hide').hide(); //其他二级菜单下右侧图标恢复
  977. leftmenuThird.find(".sp-leftmenu-fourth").slideDown(300); ///当前级别四级菜单打开
  978. leftmenuThird.siblings().find("a").removeClass("hasclick").removeClass("leftmenuClick");///其他三级下菜单去掉样式
  979. leftmenuThird.children("a").removeClass("leftmenuClick");///父级三级菜单去掉样式
  980. leftmenuThird.children("a").find('.sub-logo').hide();
  981. leftmenuThird.children("a").find('.sub-logo-hide').show(); //其右侧标变化
  982. leftmenuThird.siblings().find('.sub-logo').show();
  983. leftmenuThird.siblings().find('.sub-logo-hide').hide(); //其他同级菜单下右侧图标恢复
  984. };
  985. ///当首页文件处在五级时
  986. sp.restoreHomeFifth = function (getfileid) {
  987. $(getfileid).addClass("hasclick").addClass("leftmenuClick");
  988. var leftmenufirst = $(getfileid).parents(".sp-leftmenu-first");
  989. var leftmenuSecond = $(getfileid).parents(".sp-leftmenu-second");
  990. var leftmenuThird = $(getfileid).parents(".sp-leftmenu-third");
  991. var leftmenuFourth = $(getfileid).parents(".sp-leftmenu-fourth");
  992. var leftmenuFifth = $(getfileid).parents(".sp-leftmenu-fifth");
  993. leftmenuFifth.siblings().find("a").removeClass("hasclick").removeClass("leftmenuClick"); //其他五级菜单去掉样式
  994. leftmenufirst.find(".sp-leftmenu-second").slideDown(300);//其下二级菜单展开
  995. leftmenufirst.siblings('li').find('li').slideUp(300);
  996. leftmenufirst.siblings().find("a").removeClass("hasclick").removeClass("leftmenuClick").removeClass("sp-leftmenu-active");///其他一级下菜单去掉样式
  997. leftmenufirst.children("a").addClass("sp-leftmenu-active");
  998. leftmenufirst.children("a").find('.sub-logo').hide();
  999. leftmenufirst.children("a").find('.sub-logo-hide').show();//其右侧标变化
  1000. leftmenufirst.siblings().find('.sub-logo').show().find('.sub-logo-hide').hide(); //其他一级菜单下右侧图标恢复
  1001. leftmenuSecond.find(".sp-leftmenu-third").slideDown(300); ///当前级别三级菜单打开
  1002. leftmenuSecond.siblings().find("a").removeClass("hasclick").removeClass("leftmenuClick");///其他二级下菜单去掉样式
  1003. leftmenuSecond.siblings().children("a").removeClass("hasclick").removeClass("leftmenuClick"); //其他二级菜单去掉样式
  1004. leftmenuSecond.children("a").find('.sub-logo').hide();
  1005. leftmenuSecond.children("a").find('.sub-logo-hide').show(); //其右侧标变化
  1006. leftmenuSecond.siblings().find('.sub-logo').show();
  1007. leftmenuSecond.siblings().find('.sub-logo-hide').hide(); //其他二级菜单下右侧图标恢复
  1008. leftmenuThird.find(".sp-leftmenu-fourth").slideDown(300); ///当前级别四级菜单打开
  1009. leftmenuThird.siblings().find("a").removeClass("hasclick").removeClass("leftmenuClick");///其他三级下菜单去掉样式
  1010. leftmenuThird.children("a").removeClass("leftmenuClick");///父级三级菜单去掉样式
  1011. leftmenuThird.children("a").find('.sub-logo').hide();
  1012. leftmenuThird.children("a").find('.sub-logo-hide').show(); //其右侧标变化
  1013. leftmenuThird.siblings().find('.sub-logo').show();
  1014. leftmenuThird.siblings().find('.sub-logo-hide').hide(); //其他同级菜单下右侧图标恢复
  1015. leftmenuFourth.find(".sp-leftmenu-fifth").slideDown(300); ///当前级别四级菜单打开
  1016. leftmenuFourth.siblings().find("li").slideUp(300); //其他四级菜单下五级菜单折叠
  1017. leftmenuFourth.siblings().find("a").removeClass("hasclick").removeClass("leftmenuClick"); //其他四级菜单去掉样式
  1018. leftmenuFourth.children("a").find('.sub-logo').hide();
  1019. leftmenuFourth.children("a").find('.sub-logo-hide').show(); //其右侧标变化
  1020. leftmenuFourth.siblings().find('.sub-logo').show();
  1021. leftmenuFourth.siblings().find('.sub-logo-hide').hide(); //其他同级菜单下右侧图标恢复
  1022. };
  1023. /////记录打开的菜单文件20180730
  1024. /////保存打开的菜单中的文件路径,存入本地存储中,
  1025. sp.savemenufile = function (idstr, title, src) {
  1026. var fileJsonObj = { "id": idstr, "title": title, "src": src };
  1027. if (localStorage.getItem("GlWorkPlatform-openfileArray") == undefined || localStorage.getItem("GlWorkPlatform-openfileArray") == null) {
  1028. var openFileArray = [];
  1029. openFileArray.push(fileJsonObj);
  1030. localStorage.setItem("GlWorkPlatform-openfileArray", JSON.stringify(openFileArray)); //localStorage默认的是字符型,因此需要将json串转成字符型
  1031. } else {
  1032. var getopenfilearry = localStorage.getItem("GlWorkPlatform-openfileArray");//取出菜单文件数据
  1033. //console.log(getopenfilearry);
  1034. var setfilearry = JSON.parse(getopenfilearry);//把字符串转换成JSON对象
  1035. var sethasfileno = 0; ///设置是否存有问价的标识
  1036. var oldfiledata = ""; //旧得数据
  1037. $.each(setfilearry, function (index, item) {
  1038. if (item.id == idstr) {
  1039. sethasfileno = 1; ///说明菜单文件中已经存在该文件
  1040. oldfiledata = { "id": idstr, "title": item.title, "src": item.src };
  1041. }
  1042. });
  1043. if (sethasfileno == 0) {
  1044. //没有重复时push
  1045. setfilearry.push(fileJsonObj);
  1046. } else {
  1047. ///重复时应该更新该条数据
  1048. var updatedataarray = JSON.stringify(setfilearry);
  1049. var updatereplaceArray = updatedataarray.replace(JSON.stringify(oldfiledata), JSON.stringify(fileJsonObj));
  1050. setfilearry = JSON.parse(updatereplaceArray);
  1051. }
  1052. ///未找到,没有重复的
  1053. //if (getopenfilearry.indexOf(JSON.stringify(fileJsonObj)) == -1) {
  1054. // setfilearry.push(fileJsonObj);
  1055. //};
  1056. localStorage.setItem("GlWorkPlatform-openfileArray", JSON.stringify(setfilearry)); //localStorage默认的是字符型,因此需要将json串转成字符型
  1057. //console.log(JSON.stringify(setfilearry));
  1058. }
  1059. };
  1060. //首页tab签导航条
  1061. sp.clickTabNavActive = function (obj) {
  1062. var get_child_id = $(obj).attr("data-href");
  1063. $(obj).addClass("sp-wrapper-tabs-current").siblings().removeClass("sp-wrapper-tabs-current");
  1064. $(get_child_id).show().addClass("sp-wrapper-tabs-box-current");
  1065. $(get_child_id).siblings().removeClass("sp-wrapper-tabs-box-current").hide();
  1066. }
  1067. sp.closeSingleTabsNav = function (obj) {
  1068. //点击上面的叉号时
  1069. var get_child_id = $(obj).parent().attr("data-href"); //获取对应id
  1070. var getid = get_child_id.substring(get_child_id.lastIndexOf("_") + 1, get_child_id.length);
  1071. var temp = localStorage.getItem("GlWorkPlatform-openfileArray");//取出文件数据
  1072. var tempObj = JSON.parse(temp);//把字符串转换成JSON对象
  1073. var fileJsonObj = "";
  1074. $.each(tempObj, function (index, item) {
  1075. if (item.id == getid) {
  1076. fileJsonObj = { "id": item.id, "title": item.title, "src": item.src }
  1077. }
  1078. });
  1079. var setItemStr = "," + JSON.stringify(fileJsonObj);
  1080. //console.log(setItemStr);
  1081. var replaceArray = temp.replace(setItemStr, "");
  1082. //console.log(replaceArray);
  1083. localStorage.setItem("GlWorkPlatform-openfileArray", replaceArray); //localStorage默认的是字符型,因此需要将json串转成字符型
  1084. if ($(obj).parent().hasClass("sp-wrapper-tabs-current")) {
  1085. //若此列是当前显示的列,让其前一列显示
  1086. $(obj).parent().prev("li").addClass("sp-wrapper-tabs-current").show();
  1087. $(get_child_id).prev(".sp-wrapper-tabs-box-col").addClass("sp-wrapper-tabs-box-current").show();
  1088. $(obj).parent().remove();
  1089. $(get_child_id).remove();
  1090. } else {
  1091. //若不是当前列,则直接移除
  1092. $(obj).parent().remove();
  1093. $(get_child_id).remove();
  1094. }
  1095. ////当关闭到只剩下首页页签时,要将菜单定位到首页
  1096. if (JSON.parse(replaceArray).length == 1) {
  1097. var gethomefilecutid = JSON.parse(replaceArray)[0].id;
  1098. if ($("body").find(".sp-wrapper-left").length > 0) {
  1099. $("#spWrapperLeftBarUl li:eq(0) .sp-leftmenu-ltitle").each(function (index, item) {
  1100. var getfileid = $(this).parent().attr("id");
  1101. var getfilecutid = getfileid.substring(getfileid.lastIndexOf("_") + 1, getfileid.length);
  1102. if (getfilecutid == gethomefilecutid) {
  1103. if ($("#" + getfileid).parent().attr("class").indexOf("sp-leftmenu-first") != -1) {
  1104. ///仅有一级菜单时
  1105. sp.restoreHomeFirst("#" + getfileid);
  1106. } else if ($("#" + getfileid).parent().attr("class").indexOf("sp-leftmenu-second") != -1) {
  1107. ///含有二级菜单时
  1108. sp.restoreHomeSecond("#" + getfileid);
  1109. } else if ($("#" + getfileid).parent().attr("class").indexOf("sp-leftmenu-third") != -1) { //三级three
  1110. //含有三级菜单时three
  1111. sp.restoreHomeThird("#" + getfileid);
  1112. } else { return; }
  1113. }
  1114. });
  1115. } else if ($("body").find(".sp-wrapper-left-second").length > 0) {
  1116. $("#spLeftBarULTwo li").removeClass("leftbarTwoActive");
  1117. $("#spLeftBarULTwo li:eq(0)").addClass("leftbarTwoActive");
  1118. ///遍历第一级菜单下面的子菜单,分处于二级和三级
  1119. $("#spLeftBarULTwo li:eq(0) a").each(function () {
  1120. if ($(this).find(".lbtitle").length > 0) {
  1121. var getfileid = $(this).attr("id")
  1122. var getfilecutid = getfileid.substring(getfileid.lastIndexOf("_") + 1, getfileid.length);
  1123. if (getfilecutid == gethomefilecutid) {
  1124. var getparentclass = $(this).parent("li").attr("class");
  1125. if (getparentclass.indexOf("sp-leftbar-second") != -1) {
  1126. $(this).parents(".sp-leftbar-first").find("a").removeClass("leftbartitleActive");
  1127. $(this).parents(".sp-leftbar-first").siblings().find("a").removeClass("leftbartitleActive");
  1128. $(this).addClass("leftbartitleActive");
  1129. } else if (getparentclass.indexOf("sp-leftbar-third") != -1) {
  1130. $(this).parents(".sp-leftbar-first").find("a").removeClass("leftbartitleActive");
  1131. $(this).parents(".sp-leftbar-first").siblings().find("a").removeClass("leftbartitleActive");
  1132. $(this).addClass("leftbartitleActive");
  1133. $(this).parents(".sp-leftbar-second").children("a").addClass("leftbartitleActive");
  1134. } else { return; }
  1135. } else {
  1136. return;
  1137. }
  1138. }
  1139. });
  1140. } else {
  1141. return;
  1142. }
  1143. }
  1144. };
  1145. //onclick事件时引用,向首页添加tabs切换书签
  1146. //sp.addTabNav = function (id, title, src) {
  1147. // /// <summary>
  1148. // /// 向首页添加tabs切换书签
  1149. // /// </summary>
  1150. // /// <param name="id">唯一id编码</param>
  1151. // /// <param name="title">标题</param>
  1152. // /// <param name="src">文件路径</param>
  1153. // /// <returns>会生成tabs标题及文件iframe一个</returns>
  1154. // var setID = "wrapper_tabs_box_col_" + id;
  1155. // var set_title = "";
  1156. // var getLen2 = sp.getlength(title); ///汉字算2个字符
  1157. // if (getLen2 > 9) {
  1158. // set_title = sp.cutstr(title, 8);
  1159. // //set_title = title.substring(0, 8) + "..";
  1160. // } else {
  1161. // set_title = title;
  1162. // }
  1163. // if ($("#spWrapperTabsPart .sp-wrapper-tabs-box").children("#" + setID).length < 1) {
  1164. // $("#spWrapperTabsPart ul li").removeClass("sp-wrapper-tabs-current");
  1165. // $(".sp-wrapper-tabs-box-current").hide();
  1166. // $("#spWrapperTabsPart .sp-wrapper-tabs-box .sp-wrapper-tabs-box-col").removeClass("sp-wrapper-tabs-box-current");
  1167. // $("#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>");
  1168. // $("#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>");
  1169. // $("#" + setID).show();
  1170. // sp.savemenufile(id, title, src); ///记录打开的菜单文件
  1171. // sp.pagetabShiftRight();
  1172. // } else {
  1173. // $("#spWrapperTabsPart ul li").removeClass("sp-wrapper-tabs-current");
  1174. // $(".sp-wrapper-tabs-box-current").hide();
  1175. // $("#spWrapperTabsPart .sp-wrapper-tabs-box .sp-wrapper-tabs-box-col").removeClass("sp-wrapper-tabs-box-current");
  1176. // $("#wrapper_tabs_menu_li_" + id).addClass("sp-wrapper-tabs-current").show();
  1177. // $("#" + setID).addClass("sp-wrapper-tabs-box-current").show();
  1178. // $("#" + setID + " iframe").attr("src", src); ////然后让里面的iframe重新加载点击后的页面
  1179. // }
  1180. // sp.fitHeight("iframe",$(".sp-wrapper-head").outerHeight() + $(".sp-wrapper-tabs-head").outerHeight()); //设置iframe的高度
  1181. //};
  1182. //onclick事件时引用,向首页添加tabs切换书签
  1183. /// <summary>
  1184. /// 本方法目的:适应菜单在上侧显示框架----20230224
  1185. /// </summary>
  1186. //sp.addTabNav = function (id, title, src) {
  1187. // $("#indexhd_iframe_fileurl").attr("src", src);
  1188. //}
  1189. sp.addTabNav = function (id, title, src) {
  1190. /// <summary>
  1191. /// 向首页添加tabs切换书签
  1192. /// </summary>
  1193. /// <param name="id">唯一id编码</param>
  1194. /// <param name="title">标题</param>
  1195. /// <param name="src">文件路径</param>
  1196. /// <returns>会生成tabs标题及文件iframe一个</returns>
  1197. var setID = "wrapper_tabs_box_col_" + id;
  1198. if ($("#spWrapperTabsPart .sp-wrapper-tabs-box").find("#" + setID).length < 1) {
  1199. //$(".sp-wrapper-tabs-box-col").hide();
  1200. $("#spWrapperTabsPart .sp-wrapper-tabs-box .sp-wrapper-tabs-box-col").removeClass("sp-wrapper-tabs-box-current");
  1201. $("#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>");
  1202. //$("#" + setID).show();
  1203. sp.fitHeight("#iframe_" + setID + "", $(".sp-wrapper-head").outerHeight() + 30); //设置iframe的高度
  1204. //alert($(".sp-wrapper-head").outerHeight() + 35);
  1205. } else {
  1206. //$(".sp-wrapper-tabs-box-current").hide();
  1207. $(".sp-wrapper-tabs-box-col").removeClass("sp-wrapper-tabs-box-current");
  1208. var get_oldurl = $("#iframe_" + setID + "").attr("src");
  1209. if (get_oldurl != src) {
  1210. $("#" + setID).addClass("sp-wrapper-tabs-box-current");
  1211. //$("#" + setID).show();
  1212. $("#" + setID + " iframe").attr("src", src); ////然后让里面的iframe重新加载点击后的页面
  1213. } else {
  1214. $("#" + setID).addClass("sp-wrapper-tabs-box-current");
  1215. }
  1216. sp.fitHeight("#iframe_" + setID + "", $(".sp-wrapper-head").outerHeight() + 30); //设置iframe的高度
  1217. }
  1218. };
  1219. //根据左侧菜单json动态加载首页第一个home文件20180801
  1220. //让菜单中的排序为第一个的页面以及页面名称显示到第一个,且没有右上关闭图标
  1221. sp.addhometabnav = function (id, title, src) {
  1222. var set_title = "";
  1223. var getLen2 = sp.getlength(title);///汉字算2个字符
  1224. if (getLen2 > 9) {
  1225. set_title = sp.cutstr(title, 8);
  1226. //set_title = title.substring(0, 4) + "..";
  1227. } else {
  1228. set_title = title;
  1229. }
  1230. $("#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>");
  1231. $("#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>");
  1232. sp.fitHeight("iframe",$(".sp-wrapper-head").outerHeight() + $(".sp-wrapper-tabs-head").outerHeight()); //设置iframe的高度
  1233. ////加载第一个菜单作为home文件时都判断并添加home文件--start,
  1234. var fileJsonObj = { "id": id, "title": title, "src": src };
  1235. if (localStorage.getItem("GlWorkPlatform-openfileArray") == undefined || localStorage.getItem("GlWorkPlatform-openfileArray") == null) {
  1236. var openFileArray = [];
  1237. openFileArray.push(fileJsonObj);
  1238. localStorage.setItem("GlWorkPlatform-openfileArray", JSON.stringify(openFileArray)); //localStorage默认的是字符型,因此需要将json串转成字符型
  1239. } else {
  1240. var hashomechange = 0;
  1241. var getopenfilearry = localStorage.getItem("GlWorkPlatform-openfileArray");//取出菜单文件数据
  1242. $.each(JSON.parse(getopenfilearry), function (index, item) {
  1243. if (item.id == id) {
  1244. //说明存在第一个页签
  1245. hashomechange = 1;
  1246. }
  1247. });
  1248. ///home文件已经发生变化
  1249. if (hashomechange == 0) {
  1250. var openFileArray = [];
  1251. openFileArray.push(fileJsonObj);
  1252. localStorage.removeItem("GlWorkPlatform-openfileArray");
  1253. localStorage.setItem("GlWorkPlatform-openfileArray", JSON.stringify(openFileArray)); //localStorage默认的是字符型,因此需要将json串转成字符型
  1254. } else {
  1255. sp.savemenufile(id, title, src);
  1256. }
  1257. }
  1258. ////--end
  1259. ///将home文件所在的左侧菜单进行激活并展开-start
  1260. setTimeout(function () {
  1261. if ($("body").find(".sp-wrapper-left").length > 0) {
  1262. $("#spWrapperLeftBarUl li:eq(0) .sp-leftmenu-ltitle").each(function (index, item) {
  1263. var get_left_bar_id = $(this).parent().attr("id");
  1264. var getleftbarcutid = get_left_bar_id.substring(get_left_bar_id.lastIndexOf("_") + 1, get_left_bar_id.length);
  1265. if (getleftbarcutid == id) {
  1266. var get_className = $("#" + get_left_bar_id).parent().attr('class');
  1267. if (get_className.indexOf('sp-leftmenu-first') != -1) {
  1268. sp.restoreHomeFirst("#" + get_left_bar_id);
  1269. } else if (get_className.indexOf('sp-leftmenu-second') != -1) {
  1270. ///二级 .two
  1271. sp.restoreHomeSecond("#" + get_left_bar_id);
  1272. } else if (get_className.indexOf('sp-leftmenu-third') != -1) {
  1273. sp.restoreHomeThird("#" + get_left_bar_id);
  1274. } else { return; }
  1275. };
  1276. });
  1277. } else if ($("body").find(".sp-wrapper-left-second").length > 0) {
  1278. $("#spLeftBarULTwo li:eq(0)").addClass("leftbarTwoActive");
  1279. ///遍历第一级菜单下面的子菜单,分处于二级和三级
  1280. $("#spLeftBarULTwo li:eq(0) a").each(function () {
  1281. if ($(this).find(".lbtitle").length > 0) {
  1282. var getfileid = $(this).attr("id")
  1283. var getfilecutid = getfileid.substring(getfileid.lastIndexOf("_") + 1, getfileid.length);
  1284. //var getlbtitle = $(".lbtitle", this).text();
  1285. if (getfilecutid == id) {
  1286. var getparentclass = $(this).parent("li").attr("class");
  1287. if (getparentclass.indexOf("sp-leftbar-second") != -1) {
  1288. $(this).parents(".sp-leftbar-first").find("a").removeClass("leftbartitleActive");
  1289. $(this).parents(".sp-leftbar-first").siblings().find("a").removeClass("leftbartitleActive");
  1290. $(this).addClass("leftbartitleActive");
  1291. } else if (getparentclass.indexOf("sp-leftbar-third") != -1) {
  1292. $(this).parents(".sp-leftbar-first").find("a").removeClass("leftbartitleActive");
  1293. $(this).parents(".sp-leftbar-first").siblings().find("a").removeClass("leftbartitleActive");
  1294. $(this).addClass("leftbartitleActive");
  1295. $(this).parents(".sp-leftbar-second").children("a").addClass("leftbartitleActive");
  1296. } else { return;}
  1297. } else {
  1298. return;
  1299. }
  1300. }
  1301. });
  1302. } else {
  1303. }
  1304. },5);
  1305. //-end
  1306. };
  1307. ////根据传过来的json数据动态生成框架风格一五级菜单
  1308. sp.dynamicLeftMenu = function (jsondata) {
  1309. var res = JSON.parse(jsondata);
  1310. $.each(res.rows, function (index, item) {
  1311. if (typeof item.C_H_I_L_D == "undefined" || item.C_H_I_L_D.length < 1) {
  1312. if (item.OPENTYPE == "_blank") {
  1313. $("#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>");
  1314. } else {
  1315. $("#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>");
  1316. }
  1317. } else {
  1318. var setSecondAll = "";
  1319. 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>";
  1320. $.each(item.C_H_I_L_D, function (index2, item2) {
  1321. //alert(item2.C_H_I_L_D);
  1322. if (typeof item2.C_H_I_L_D == "undefined" || item2.C_H_I_L_D.length < 1) {
  1323. if (item2.OPENTYPE == "_blank") {
  1324. 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>";
  1325. } else {
  1326. 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>";
  1327. }
  1328. } else {
  1329. var getThrdAll = "";
  1330. 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>";
  1331. $.each(item2.C_H_I_L_D, function (index3, item3) {
  1332. //alert(item3.C_H_I_L_D);
  1333. if (item3.C_H_I_L_D == undefined || item3.C_H_I_L_D.length < 1) {
  1334. if (item3.OPENTYPE == "_blank") {
  1335. 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>"
  1336. } else {
  1337. 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>"
  1338. }
  1339. } else {
  1340. var setFourthAll = "";
  1341. 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>";
  1342. $.each(item3.C_H_I_L_D, function (index4, item4) {
  1343. if (item4.C_H_I_L_D == undefined || item4.C_H_I_L_D.length < 1) {
  1344. if (item4.OPENTYPE == "_blank") {
  1345. 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>";
  1346. } else {
  1347. 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>";
  1348. }
  1349. } else {
  1350. var setFifthAll = "";
  1351. 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>";
  1352. $.each(item4.C_H_I_L_D, function (index5, item5) {
  1353. if (item5.OPENTYPE == "_blank") {
  1354. 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>";
  1355. } else {
  1356. 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>";
  1357. }
  1358. });
  1359. setFourthAll += setFourthSingle + "<ul>" + setFifthAll + "</ul></li>";
  1360. }
  1361. });
  1362. getThrdAll += getThirdSingle + "<ul>" + setFourthAll + "</ul></li>";
  1363. }
  1364. });
  1365. setSecondAll += setSecondSingle + "<ul>" + getThrdAll + "</ul></li>";
  1366. }
  1367. });
  1368. var setChild = setFirstMenu + "<ul>" + setSecondAll + "</ul></li>";
  1369. //console.log(setChild);
  1370. $("#spWrapperLeftBarUl").append(setChild);
  1371. }
  1372. });
  1373. //////让菜单中的排序为第一个的页面以及页面名称显示到第一个,且没有右上关闭图标-----start
  1374. if (typeof res.rows[0].C_H_I_L_D == "undefined" || res.rows[0].C_H_I_L_D.length < 1) {
  1375. ///若没有子节点
  1376. var title = res.rows[0].CNAME;
  1377. var id = res.rows[0].PKID;
  1378. var src = res.rows[0].FILEN;
  1379. sp.addhometabnav(id, title, src); ///将左侧菜单第一个设为home的tab签
  1380. } 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) {
  1381. ///如有子节点-二级
  1382. var title = res.rows[0].C_H_I_L_D[0].CNAME;
  1383. var id = res.rows[0].C_H_I_L_D[0].PKID;
  1384. var src = res.rows[0].C_H_I_L_D[0].FILEN;
  1385. sp.addhometabnav(id, title, src);///将左侧菜单第一个设为home的tab签
  1386. } else {
  1387. //三级
  1388. var title = res.rows[0].C_H_I_L_D[0].C_H_I_L_D[0].CNAME;
  1389. var id = res.rows[0].C_H_I_L_D[0].C_H_I_L_D[0].PKID;
  1390. var src = res.rows[0].C_H_I_L_D[0].C_H_I_L_D[0].FILEN;
  1391. sp.addhometabnav(id, title, src);///将左侧菜单第一个设为home的tab签
  1392. }
  1393. ///////-----end
  1394. setTimeout(function () {
  1395. //sp.loadmenufiles();//加载记录菜单文件
  1396. sp.setLeftMenu(); ///操作左侧五级菜单
  1397. }, 300);
  1398. /////----end
  1399. };
  1400. ////层里面设置多个div
  1401. sp.tabscoliframeset = function (id, title, src) {
  1402. var get_current_id = $(".sp-wrapper-tabs-box-current").attr("id").split("wrapper_tabs_box_col_")[1];
  1403. var setID = "spwrappertabsboxcoliframelayer_" + get_current_id + "_" + id;
  1404. if ($(".sp-wrapper-tabs-box-current").find("#" + setID).length < 1) {
  1405. var get_iframelength = $(".sp-wrapper-tabs-box-current").find("iframe").length;
  1406. //console.log(get_iframelength);
  1407. var set_width_1 = 0, set_width_2 = 0;
  1408. if (get_iframelength == 1) {
  1409. set_width_1 = "33.333%"; set_width_2 = "65.666%";
  1410. } else if (get_iframelength == 2) {
  1411. set_width_1 = "33.333%"; set_width_2 = "32.333%";
  1412. } else if (get_iframelength == 3) {
  1413. set_width_1 = "30%"; set_width_2 = "22.333%";
  1414. } else if (get_iframelength == 4) {
  1415. set_width_1 = "30%"; set_width_2 = "16.5%";
  1416. } else {
  1417. set_width_1 = "30%"; set_width_2 = "13%";
  1418. }
  1419. $(".sp-wrapper-tabs-box-current iframe:eq(0)").css("width", set_width_1);
  1420. $(".sp-wrapper-tabs-box-current").find(".sp-wrapper-tabs-box-col-iframelayer").removeClass("sp-wrapper-tabs-box-col-iframelayer-curent");
  1421. 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>";
  1422. $(".sp-wrapper-tabs-box-current").append(setiframe);
  1423. sp.fitHeight("iframe", $(".sp-wrapper-head").outerHeight() + $(".sp-wrapper-tabs-head").outerHeight()); //设置iframe的高度
  1424. $(".sp-wrapper-tabs-box-current").find(".sp-wrapper-tabs-box-col-iframelayer").css("width", set_width_2);
  1425. $(".sp-wrapper-tabs-box-current").find(".sp-wrapper-tabs-box-col-iframelayer").each(function () {
  1426. $(this).click(function () {
  1427. $(this).addClass("sp-wrapper-tabs-box-col-iframelayer-curent").siblings().removeClass("sp-wrapper-tabs-box-col-iframelayer-curent");
  1428. });
  1429. });
  1430. setTimeout(function () {
  1431. $("#" + setID).resizable({
  1432. handles: "e,w",
  1433. minWidth: 100,
  1434. minHeight: 300,
  1435. resize: function (event, ui) {
  1436. //self.settopWorkLayer(event.target);
  1437. //$(event.target).find('.gmt-work-mask').show();
  1438. //var set_wid = "";
  1439. //if (get_iframelength >1){
  1440. // set_wid = ($(".sp-wrapper-tabs-box-current").width() / 2 - 10 * get_iframelength - $("#" + setID).width()) / get_iframelength;
  1441. //}
  1442. //$("#" + setID).siblings(".sp-wrapper-tabs-box-col-iframelayer").css("width", "" + set_wid + "%");
  1443. },
  1444. stop: function (event, ui) {
  1445. //$(event.target).find('.gmt-work-mask').hide();
  1446. }
  1447. });
  1448. }, 1000)
  1449. }
  1450. };
  1451. sp.tabscoliframesetClose = function (idnum) {
  1452. //alert(idnum);
  1453. $(".sp-wrapper-tabs-box-current").find("#" + idnum).remove();
  1454. if ($(".sp-wrapper-tabs-box-current").find("iframe").length < 2) {
  1455. $(".sp-wrapper-tabs-box-current iframe:eq(0)").css("width", "100%");
  1456. }
  1457. };
  1458. ///打开页签操作part
  1459. sp.setpagetab = function () {
  1460. $(".sp-pagetab-close").on("click", function (e) {
  1461. if ($(".sp-pagetab-close").hasClass("hasclick")) {
  1462. $(".sp-pagetab-close").removeClass("hasclick");
  1463. $(".sp-pagetab-closepart").fadeOut(200);
  1464. } else {
  1465. $(".sp-pagetab-close").addClass("hasclick");
  1466. $(".sp-pagetab-closepart").fadeIn(200);
  1467. ///若此一直展开处于无操作时,就将页签操作part进行关闭
  1468. setTimeout(function () {
  1469. if ($(".sp-pagetab-closepart").is(":visible")) {
  1470. //alert(1);
  1471. $(".sp-pagetab-close").removeClass("hasclick");
  1472. $(".sp-pagetab-closepart").fadeOut(200);
  1473. }
  1474. }, 10000);
  1475. }
  1476. sp.stopPropagation(e);
  1477. });
  1478. $(document).on('click', function () {
  1479. $(".sp-pagetab-close").removeClass("hasclick");
  1480. $(".sp-pagetab-closepart").fadeOut(200);
  1481. });
  1482. $(".sp-pagetab-close").click(function (e) {
  1483. sp.stopPropagation(e);
  1484. });
  1485. };
  1486. sp.setpagetab();
  1487. ///关闭全部页签20180730
  1488. sp.closePagetab = function () {
  1489. var getopenfilearry = localStorage.getItem("GlWorkPlatform-openfileArray");//取出菜单文件数据
  1490. if (JSON.parse(getopenfilearry).length > 1) {
  1491. var setopenfilearry = getopenfilearry.substring(0, getopenfilearry.indexOf("},") + 1);
  1492. setopenfilearry = setopenfilearry + "]";
  1493. localStorage.setItem("GlWorkPlatform-openfileArray", setopenfilearry);
  1494. if ($(".sp-wrapper-tabs-menu li").length > 1) {
  1495. $(".sp-wrapper-tabs-menu li").each(function (index, item) {
  1496. var gettabsmenuliid = $(this).attr("id");
  1497. var getiframeid = $(this).attr("data-href");//得到iframe的id
  1498. if (index != 0) {
  1499. ///删除首页之外的菜单文件
  1500. $(this).remove();
  1501. $(getiframeid).remove();
  1502. } else {
  1503. ///为第一个加上选中样式
  1504. $("#" + gettabsmenuliid).addClass("sp-wrapper-tabs-current");
  1505. $(getiframeid).show().addClass("sp-wrapper-tabs-box-current");
  1506. var gethometitle = $(this).attr("title");
  1507. var gethomefileid = $(this).attr("id");
  1508. var gethomefilecutid = gethomefileid.substring(gethomefileid.lastIndexOf("_") + 1, gethomefileid.length);
  1509. if ($("body").find(".sp-wrapper-left").length > 0) {
  1510. $("#spWrapperLeftBarUl li:eq(0) .sp-leftmenu-ltitle").each(function (index, item) {
  1511. var getfileid = $(this).parent().attr("id");
  1512. var getfilecutid = getfileid.substring(getfileid.lastIndexOf("_") + 1, getfileid.length);
  1513. if (getfilecutid == gethomefilecutid) {
  1514. if ($("#" + getfileid).parent().attr("class").indexOf("sp-leftmenu-first") != -1) {
  1515. ///仅有一级菜单时
  1516. sp.restoreHomeFirst("#" + getfileid);
  1517. } else if ($("#" + getfileid).parent().attr("class").indexOf("sp-leftmenu-second") != -1) {
  1518. ///含有有二级菜单时
  1519. sp.restoreHomeSecond("#" + getfileid);
  1520. } else if ($("#" + getfileid).parent().attr("class").indexOf("sp-leftmenu-third") != -1) {
  1521. //三级three
  1522. sp.restoreHomeThird("#" + getfileid);
  1523. } else { return;}
  1524. }
  1525. });
  1526. } else if ($("body").find(".sp-wrapper-left-second").length > 0) {
  1527. $("#spLeftBarULTwo li").removeClass("leftbarTwoActive");
  1528. $("#spLeftBarULTwo li:eq(0)").addClass("leftbarTwoActive");
  1529. ///遍历第一级菜单下面的子菜单,分处于二级和三级
  1530. $("#spLeftBarULTwo li:eq(0) a").each(function () {
  1531. if ($(this).find(".lbtitle").length > 0) {
  1532. var getfileid = $(this).attr("id")
  1533. var getfilecutid = getfileid.substring(getfileid.lastIndexOf("_") + 1, getfileid.length);
  1534. if (getfilecutid == gethomefilecutid) {
  1535. var getparentclass = $(this).parent("li").attr("class");
  1536. if (getparentclass.indexOf("sp-leftbar-second") != -1) {
  1537. $(this).parents(".sp-leftbar-first").find("a").removeClass("leftbartitleActive");
  1538. $(this).parents(".sp-leftbar-first").siblings().find("a").removeClass("leftbartitleActive");
  1539. $(this).addClass("leftbartitleActive");
  1540. } else if (getparentclass.indexOf("sp-leftbar-third") != -1) {
  1541. $(this).parents(".sp-leftbar-first").find("a").removeClass("leftbartitleActive");
  1542. $(this).parents(".sp-leftbar-first").siblings().find("a").removeClass("leftbartitleActive");
  1543. $(this).addClass("leftbartitleActive");
  1544. $(this).parents(".sp-leftbar-second").children("a").addClass("leftbartitleActive");
  1545. } else { return;}
  1546. } else {
  1547. return;
  1548. }
  1549. }
  1550. });
  1551. }else{return;}
  1552. }
  1553. });
  1554. localStorage.removeItem("GlWorkPlatform-setLeftBarClickID");
  1555. }
  1556. }
  1557. $(".sp-pagetab-closepart").fadeOut(200);
  1558. };
  1559. ///关闭其他页签,除当前active的20180730
  1560. sp.closePagetabOthers = function () {
  1561. ///得到当前打开项的id
  1562. var get_child_id = $(".sp-wrapper-tabs-current").attr("data-href");
  1563. var getid = get_child_id.substring(get_child_id.lastIndexOf("_") + 1, get_child_id.length);
  1564. var temp = localStorage.getItem("GlWorkPlatform-openfileArray");//取出菜单文件数据
  1565. if (JSON.parse(temp).length > 1) {
  1566. ////将home文件即第一个菜单文件取出
  1567. var gethomefile = temp.substring(0, temp.indexOf("},") + 1);
  1568. gethomefile = gethomefile + "]";
  1569. var sethomefileArray = JSON.parse(gethomefile);
  1570. var gethomefileid = sethomefileArray[0].id; ///得到home文件的id编号
  1571. ////进行比对
  1572. if (getid == gethomefileid) {
  1573. ///tabs签停在首页home时,将其他删除并清空记录
  1574. if ($(".sp-wrapper-tabs-menu li").length > 1) {
  1575. $(".sp-wrapper-tabs-menu li").each(function (index, item) {
  1576. if (index != 0) {
  1577. ///删除首页之外的菜单文件
  1578. var getiframeid = $(this).attr("data-href");//得到iframe的id
  1579. $(this).remove();
  1580. $(getiframeid).remove();
  1581. }
  1582. });
  1583. }
  1584. //alert(gethomefile);
  1585. localStorage.setItem("GlWorkPlatform-openfileArray", gethomefile);
  1586. } else {
  1587. ///tabs签没有停留在首页
  1588. if ($(".sp-wrapper-tabs-menu li").length > 1) {
  1589. $(".sp-wrapper-tabs-menu li").each(function (index, item) {
  1590. if (index != 0) {
  1591. ///删除首页之外的菜单文件
  1592. var getiframeid = $(this).attr("data-href");//得到iframe的id
  1593. if (getiframeid != get_child_id) {
  1594. $(this).remove();
  1595. $(getiframeid).remove();
  1596. }
  1597. }
  1598. });
  1599. }
  1600. var tempObj = JSON.parse(temp);//把字符串转换成JSON对象
  1601. var fileJsonObj = "";
  1602. $.each(tempObj, function (index, item) {
  1603. if (item.id == getid) {
  1604. fileJsonObj = { "id": item.id, "title": item.title, "src": item.src }
  1605. }
  1606. });
  1607. var setOtherfilesarray = temp.substring(0, temp.indexOf("},") + 2) + JSON.stringify(fileJsonObj) + "]";
  1608. //alert(setOtherfilesarray);
  1609. localStorage.setItem("GlWorkPlatform-openfileArray", setOtherfilesarray);
  1610. }
  1611. }
  1612. $(".sp-wrapper-tabs-closepart").fadeOut(200);
  1613. };
  1614. //刷新当前页签
  1615. sp.reloadPagetabCurrent = function () {
  1616. var geturl = "";
  1617. var getid = $(".sp-wrapper-tabs-menu .sp-wrapper-tabs-current").attr("data-href");
  1618. geturl = $(getid + " iframe").attr("src");
  1619. if (geturl.indexOf("?") != -1 && geturl.indexOf("?time") == -1) {
  1620. //若含有?问号,并且没有找到?time,即文件路径含有其他参数,加上time时间戳加载后面
  1621. if (geturl.indexOf("&time") != -1) {
  1622. //含有时间戳
  1623. var cuturl = geturl.substring(0, geturl.indexOf("&time")); ///先截取
  1624. geturl = cuturl + "&time=" + new Date().getTime();
  1625. } else {
  1626. ///没有时间戳
  1627. geturl = geturl + "&time=" + new Date().getTime(); ///直接在后面加上时间戳
  1628. }
  1629. } else if (geturl.indexOf("?time") != -1) {
  1630. ///若第一个参数就是?time,即上次加了时间戳
  1631. var cuturl = geturl.substring(0, geturl.indexOf("?"));
  1632. geturl = cuturl + "?time=" + new Date().getTime();
  1633. } else if (geturl.indexOf("?") == -1) {
  1634. //若无参数,也无?就直接加上时间戳
  1635. geturl = geturl + "?time=" + new Date().getTime();
  1636. } else { return; }
  1637. $(getid + " iframe").attr("src", geturl);
  1638. $(".sp-pagetab-closepart").fadeOut(200);
  1639. };
  1640. ////打开页面时加载记录菜单文件20180801
  1641. sp.loadmenufiles = function () {
  1642. var temp = localStorage.getItem("GlWorkPlatform-openfileArray");//取出文件数据
  1643. var tempObj = JSON.parse(temp);//把字符串转换成JSON对象
  1644. var gethomefiletitle = tempObj[0].title;//得到home文件名称标题
  1645. if (tempObj.length > 1) {
  1646. var dialogHead = "<span class=\"sp-dialog-head\"><span class=\"sp-dialog-tip\">您好</span><span class=\"sp-dialog-close sp-closeDialog\" title=\"关闭\">×</span></span>";
  1647. var dialogBody = "<div class=\"sp-dialog-body\">是否打开上次浏览的菜单页签?</div>";
  1648. 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>";
  1649. $('.sp-dialog').html(dialogHead + dialogBody + dialogFoot);
  1650. sp.openCenter(".sp-dialog");
  1651. ///取消按钮
  1652. $('.sp-closeDialog').click(function (event) {
  1653. sp.dialoghide();
  1654. var getopenfilearry = localStorage.getItem("GlWorkPlatform-openfileArray");//取出菜单文件数据
  1655. var setopenfilearry = getopenfilearry.substring(0, getopenfilearry.indexOf("},") + 1);
  1656. setopenfilearry = setopenfilearry + "]";
  1657. localStorage.setItem("GlWorkPlatform-openfileArray", setopenfilearry);
  1658. localStorage.removeItem("GlWorkPlatform-setLeftBarClickID");
  1659. return false;
  1660. event.preventDefault();
  1661. event.stopPropagation();
  1662. });
  1663. ///确认按钮
  1664. $("#delDataTrue").click(function () {
  1665. ///从localStorage中取出点击左侧菜单的激活id
  1666. var cookiemenuid = localStorage.getItem("GlWorkPlatform-setLeftBarClickID") || 0;
  1667. var setcookiemenuid = "";
  1668. if (cookiemenuid == 0) {
  1669. setcookiemenuid == 0;
  1670. } else {
  1671. setcookiemenuid = cookiemenuid.substring(cookiemenuid.lastIndexOf("_") + 1, cookiemenuid.length);
  1672. }
  1673. sp.dialoghide();
  1674. $.each(tempObj, function (index, item) {
  1675. if (index != 0) {
  1676. var get_file_id = item.id;
  1677. var get_file_title = item.title;
  1678. var get_file_src = item.src;
  1679. var setID = "wrapper_tabs_box_col_" + get_file_id;
  1680. var set_title = "";
  1681. var getLen2 = sp.getlength(get_file_title); ///汉字算2个字符
  1682. if (getLen2 > 9) {
  1683. set_title = sp.cutstr(get_file_title, 8);
  1684. } else {
  1685. set_title = get_file_title;
  1686. }
  1687. if (get_file_id != setcookiemenuid) {
  1688. //菜单文件记录没有当前激活左侧菜单
  1689. $("#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>");
  1690. $("#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>");
  1691. } else {
  1692. ///菜单文件记录有当前激活左侧菜单
  1693. sp.setLeftMenuActiveByCookie(); ////设置左侧菜单根据localStorage而激活
  1694. $("#spWrapperTabsPart ul li").removeClass("sp-wrapper-tabs-current");
  1695. $(".sp-wrapper-tabs-box-current").hide();
  1696. $("#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>");
  1697. $("#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>");
  1698. $("#" + setID).show();
  1699. }
  1700. };
  1701. });
  1702. //sp.closeSingleTabsNav('#spWrapperTabsPart');
  1703. sp.pagetabShiftRight();
  1704. sp.fitHeight("iframe",$(".sp-wrapper-head").outerHeight() + $(".sp-wrapper-tabs-head").outerHeight()); //设置iframe的高度
  1705. });
  1706. };
  1707. };
  1708. /////第二种框架的加载记录菜单文件 20180803
  1709. sp.loadmenufilesTwo = function () {
  1710. var temp = localStorage.getItem("GlWorkPlatform-openfileArray");//取出文件数据
  1711. var tempObj = JSON.parse(temp);//把字符串转换成JSON对象
  1712. var gethomefiletitle = tempObj[0].title;//得到home文件名称标题
  1713. if (tempObj.length > 1) {
  1714. 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>";
  1715. var dialogBody = "<div class=\"sp-dialog-body\">是否打开上次浏览的菜单页签?</div>";
  1716. 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>";
  1717. $('.sp-dialog').html(dialogHead + dialogBody + dialogFoot);
  1718. sp.openCenter(".sp-dialog");
  1719. $('.sp-closeDialog').click(function (event) {
  1720. sp.dialoghide();
  1721. var getopenfilearry = localStorage.getItem("GlWorkPlatform-openfileArray");//取出菜单文件数据
  1722. var setopenfilearry = getopenfilearry.substring(0, getopenfilearry.indexOf("},") + 1);
  1723. setopenfilearry = setopenfilearry + "]";
  1724. localStorage.setItem("GlWorkPlatform-openfileArray", setopenfilearry);
  1725. ///将home文件所在的左侧菜单进行激活并展开-start
  1726. $("#spLeftBarULTwo li:eq(0)").addClass("leftbarTwoActive");
  1727. //-end
  1728. localStorage.removeItem("GlWorkPlatform-setLeftBarClickID");
  1729. return false;
  1730. event.preventDefault();
  1731. event.stopPropagation();
  1732. });
  1733. ///确认按钮
  1734. $("#delDataTrue").click(function () {
  1735. ///从localStorage中取出点击左侧菜单的激活id
  1736. var cookiemenuid = localStorage.getItem("GlWorkPlatform-setLeftBarClickID") || 0;
  1737. var setcookiemenuid = "";
  1738. if (cookiemenuid == 0) {
  1739. setcookiemenuid == 0;
  1740. } else {
  1741. setcookiemenuid = cookiemenuid.substring(cookiemenuid.lastIndexOf("_") + 1, cookiemenuid.length);
  1742. }
  1743. sp.dialoghide();
  1744. $.each(tempObj, function (index, item) {
  1745. if (index != 0) {
  1746. var get_file_id = item.id;
  1747. var get_file_title = item.title;
  1748. var get_file_src = item.src;
  1749. var setID = "wrapper_tabs_box_col_" + get_file_id;
  1750. var set_title = "";
  1751. var getLen2 = sp.getlength(get_file_title); ///汉字算2个字符
  1752. if (getLen2 > 9) {
  1753. set_title = sp.cutstr(get_file_title, 8);
  1754. } else {
  1755. set_title = get_file_title;
  1756. }
  1757. if (get_file_id != setcookiemenuid) {
  1758. //菜单文件记录没有当前激活左侧菜单
  1759. $("#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>");
  1760. $("#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>");
  1761. } else {
  1762. ////上面页签选中,对应iframe显示
  1763. $("#spWrapperTabsPart ul li").removeClass("sp-wrapper-tabs-current");
  1764. $(".sp-wrapper-tabs-box-current").hide();
  1765. $("#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>");
  1766. $("#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>");
  1767. $("#" + setID).show();
  1768. ///菜单文件记录有当前激活左侧菜单
  1769. var leftbarfirst = $("#" + cookiemenuid).parents(".sp-leftbar-first");
  1770. leftbarfirst.addClass("leftbarTwoActive").siblings().removeClass("leftbarTwoActive");
  1771. leftbarfirst.find("a").removeClass("leftbartitleActive");
  1772. leftbarfirst.siblings().find("a").removeClass("leftbartitleActive");
  1773. $("#" + cookiemenuid).addClass("leftbartitleActive");
  1774. //判断其上面父级菜单,若有父级菜单则选中
  1775. var getparentclass = $("#" + cookiemenuid).parent("li").attr("class");
  1776. if (getparentclass.indexOf("sp-leftbar-third") != -1) {
  1777. $("#" + cookiemenuid).parents(".sp-leftbar-second").children("a").addClass("leftbartitleActive");
  1778. } else if (getparentclass.indexOf("sp-leftbar-fourth") != -1) {
  1779. $("#" + cookiemenuid).parents(".sp-leftbar-second").children("a").addClass("leftbartitleActive");
  1780. $("#" + cookiemenuid).parents(".sp-leftbar-third").children("a").addClass("leftbartitleActive");
  1781. } else if (getparentclass.indexOf("sp-leftbar-fifth") != -1) {
  1782. $("#" + cookiemenuid).parents(".sp-leftbar-second").children("a").addClass("leftbartitleActive");
  1783. $("#" + cookiemenuid).parents(".sp-leftbar-third").children("a").addClass("leftbartitleActive");
  1784. $("#" + cookiemenuid).parents(".sp-leftbar-fourth").children("a").addClass("leftbartitleActive");
  1785. } else { return; }
  1786. }
  1787. };
  1788. });
  1789. //sp.closeSingleTabsNav('#spWrapperTabsPart');
  1790. sp.pagetabShiftRight();
  1791. sp.fitHeight("iframe",$(".sp-wrapper-head").outerHeight() + $(".sp-wrapper-tabs-head").outerHeight()); //设置iframe的高度
  1792. })
  1793. }
  1794. };
  1795. /////第二种框架根据json数据生成五级菜单 20180803
  1796. sp.dynamicLeftBar = function (jsondata) {
  1797. var res = JSON.parse(jsondata);
  1798. $.each(res.rows, function (index, item) {
  1799. if (typeof item.C_H_I_L_D == "undefined" || item.C_H_I_L_D.length < 1) {
  1800. if (item.OPENTYPE == "_blank") {
  1801. $("#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>");
  1802. } else {
  1803. $("#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>");
  1804. }
  1805. } else {
  1806. var setSecondAll = "";
  1807. 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>";
  1808. $.each(item.C_H_I_L_D, function (index2, item2) {
  1809. if (typeof item2.C_H_I_L_D == "undefined" || item2.C_H_I_L_D.length < 1) {
  1810. if (item2.OPENTYPE == "_blank") {
  1811. 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>";
  1812. } else {
  1813. 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>";
  1814. }
  1815. } else {
  1816. var getThrdAll = "";
  1817. 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>";
  1818. $.each(item2.C_H_I_L_D, function (index3, item3) {
  1819. if (item3.C_H_I_L_D == undefined || item3.C_H_I_L_D.length < 1) {
  1820. if (item3.OPENTYPE == "_blank") {
  1821. 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>";
  1822. } else {
  1823. 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>";
  1824. }
  1825. } else {
  1826. var setFourthAll = "";
  1827. 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>";
  1828. $.each(item3.C_H_I_L_D, function (index4, item4) {
  1829. if (item4.C_H_I_L_D == undefined || item4.C_H_I_L_D.length < 1) {
  1830. if (item4.OPENTYPE == "_blank") {
  1831. 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>";
  1832. } else {
  1833. 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>";
  1834. }
  1835. } else {
  1836. var setFifthAll = "";
  1837. 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>";
  1838. $.each(item4.C_H_I_L_D, function (index5, item5) {
  1839. if (item5.OPENTYPE == "_blank") {
  1840. 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>";
  1841. } else {
  1842. 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>";
  1843. }
  1844. });
  1845. setFourthAll += setFourthSingle + "<ul>" + setFifthAll + "</ul></li>";
  1846. }
  1847. });
  1848. getThrdAll += getThirdSingle + "<ul>" + setFourthAll + "</ul></li>";
  1849. }
  1850. });
  1851. setSecondAll += setSecondSingle + "<ul>" + getThrdAll + "</ul></li>";
  1852. }
  1853. });
  1854. var setChild = setFirstMenu + "<ul>" + setSecondAll + "</ul></li>";
  1855. //console.log(setChild);
  1856. $("#spLeftBarULTwo").append(setChild);
  1857. }
  1858. });
  1859. //////让菜单中的排序为第一个的页面以及页面名称显示到第一个,且没有右上关闭图标-----start
  1860. if (typeof res.rows[0].C_H_I_L_D == "undefined" || res.rows[0].C_H_I_L_D.length < 1) {
  1861. ///若没有子节点
  1862. var title = res.rows[0].CNAME;
  1863. var id = res.rows[0].PKID;
  1864. var src = res.rows[0].FILEN;
  1865. sp.addhometabnav(id, title, src); ///将左侧菜单第一个设为home的tab签
  1866. } 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) {
  1867. ///如有子节点-二级
  1868. var title = res.rows[0].C_H_I_L_D[0].CNAME;
  1869. var id = res.rows[0].C_H_I_L_D[0].PKID;
  1870. var src = res.rows[0].C_H_I_L_D[0].FILEN;
  1871. sp.addhometabnav(id, title, src);///将左侧菜单第一个设为home的tab签
  1872. } else {
  1873. //三级
  1874. var title = res.rows[0].C_H_I_L_D[0].C_H_I_L_D[0].CNAME;
  1875. var id = res.rows[0].C_H_I_L_D[0].C_H_I_L_D[0].PKID;
  1876. var src = res.rows[0].C_H_I_L_D[0].C_H_I_L_D[0].FILEN;
  1877. sp.addhometabnav(id, title, src);///将左侧菜单第一个设为home的tab签
  1878. }
  1879. ///////-----end
  1880. //延时
  1881. setTimeout(function () {
  1882. //sp.loadmenufilesTwo(); ///加载记录菜单文件
  1883. ////点击leftbar时一级菜单加上选中
  1884. $(".sp-leftbar .sp-leftbar-first").each(function () {
  1885. $(this).click(function () {
  1886. $(this).addClass("leftbarTwoActive").siblings().removeClass("leftbarTwoActive");
  1887. });
  1888. });
  1889. ///点击后记录其标题id存入localStorage
  1890. $("#spLeftBarULTwo a").each(function () {
  1891. $(this).click(function () {
  1892. var get_clickID = $(this).attr("id");
  1893. localStorage.setItem("GlWorkPlatform-setLeftBarClickID", get_clickID);
  1894. //为子菜单标题加上选中
  1895. if ($(this).find(".lbtitle").length > 0) {
  1896. $(this).parents(".sp-leftbar-first").find("a").removeClass("leftbartitleActive");
  1897. $(this).parents(".sp-leftbar-first").siblings().find("a").removeClass("leftbartitleActive");
  1898. $(this).addClass("leftbartitleActive");
  1899. //判断其上面父级菜单,若有父级菜单则选中
  1900. var getparentclass = $(this).parent("li").attr("class");
  1901. if (getparentclass.indexOf("sp-leftbar-third") != -1) {
  1902. $(this).parents(".sp-leftbar-second").children("a").addClass("leftbartitleActive");
  1903. } else if (getparentclass.indexOf("sp-leftbar-fourth") != -1) {
  1904. $(this).parents(".sp-leftbar-second").children("a").addClass("leftbartitleActive");
  1905. $(this).parents(".sp-leftbar-third").children("a").addClass("leftbartitleActive");
  1906. } else if (getparentclass.indexOf("sp-leftbar-fifth") != -1) {
  1907. $(this).parents(".sp-leftbar-second").children("a").addClass("leftbartitleActive");
  1908. $(this).parents(".sp-leftbar-third").children("a").addClass("leftbartitleActive");
  1909. $(this).parents(".sp-leftbar-fourth").children("a").addClass("leftbartitleActive");
  1910. } else { return; }
  1911. } else {
  1912. return;
  1913. }
  1914. });
  1915. });
  1916. }, 300);
  1917. };
  1918. ////页签太多时点击左移按钮向左移动部分20180807
  1919. sp.pagetabShiftLeft = function () {
  1920. var tabsheadwidth = $(".sp-wrapper-tabs-head").outerWidth();
  1921. var getlen1 = $(".sp-wrapper-tabs-menu").children("li").length;
  1922. var settabsheadwidth = parseInt(tabsheadwidth - 190);
  1923. //alert(tabsheadwidth);
  1924. var tabsmenuliwidth = parseInt(getlen1 * 90);
  1925. //alert(tabsmenuliwidth);
  1926. if (tabsmenuliwidth < settabsheadwidth) {
  1927. return false;
  1928. } else {
  1929. $(".sp-wrapper-tabs-menu").animate({
  1930. marginLeft: "40px"
  1931. }, "fast");
  1932. }
  1933. };
  1934. ////页签太多时点击左移按钮向右移动部分20180807
  1935. sp.pagetabShiftRight = function () {
  1936. var tabsheadwidth = $(".sp-wrapper-tabs-head").outerWidth();
  1937. var getlen1 = $(".sp-wrapper-tabs-menu").children("li").length;
  1938. var settabsheadwidth = parseInt(tabsheadwidth - 190);
  1939. //alert(tabsheadwidth);
  1940. var tabsmenuliwidth = parseInt(getlen1 * 90);
  1941. //alert(tabsmenuliwidth);
  1942. if (tabsmenuliwidth < settabsheadwidth) {
  1943. return false;
  1944. } else {
  1945. var getmorenum = Math.ceil(parseInt(tabsmenuliwidth - settabsheadwidth) / 90);
  1946. //alert(getmorenum);
  1947. var shiftleftwidth = getmorenum * 90 + 50;
  1948. $(".sp-wrapper-tabs-menu").animate({
  1949. marginLeft: 0 - shiftleftwidth + "px"
  1950. }, "fast");
  1951. }
  1952. };
  1953. ////获取字符串的长度2018-7-27
  1954. sp.getlength = function (str) {
  1955. ///<summary>获得字符串实际长度,中文2,英文1</summary>
  1956. ///<param name="str">要获得长度的字符串</param>
  1957. var realLength = 0, len = str.length, charCode = -1;
  1958. for (var i = 0; i < len; i++) {
  1959. charCode = str.charCodeAt(i);
  1960. if (charCode >= 0 && charCode <= 128) realLength += 1;
  1961. else realLength += 2;
  1962. }
  1963. return realLength;
  1964. };
  1965. /**
  1966. * js截取字符串,中英文都能用
  1967. * @param str:需要截取的字符串
  1968. * @param len: 需要截取的长度
  1969. */
  1970. sp.cutstr = function (str, len) {
  1971. var str_length = 0;
  1972. var str_len = 0;
  1973. var str_cut = new String();
  1974. str_len = str.length;
  1975. for (var i = 0; i < str_len; i++) {
  1976. a = str.charAt(i);
  1977. str_length++;
  1978. if (escape(a).length > 4) {
  1979. //中文字符的长度经编码之后大于4
  1980. str_length++;
  1981. }
  1982. str_cut = str_cut.concat(a);
  1983. if (str_length >= len) {
  1984. str_cut = str_cut.concat("..");
  1985. return str_cut;
  1986. }
  1987. }
  1988. //如果给定字符串小于指定长度,则返回源字符串;
  1989. if (str_length < len) {
  1990. return str;
  1991. }
  1992. }
  1993. ////清空cookie: $.cookie('cookie_myskin',null,{expires: -1,path: '/'});
  1994. ////加上cookie: $.cookie("cookie_myskin", "123456", { path: '/', expires: 2 });
  1995. ////接收cookie: var getCookie=$.cookie("cookie_myskin");
  1996. jQuery.cookie = function (name, value, options) {
  1997. /// <summary>设置cookie</summary>
  1998. if (typeof value != 'undefined') { // name and value given, set cookie
  1999. options = options || {};
  2000. if (value === null) {
  2001. value = '';
  2002. options.expires = -1;
  2003. }
  2004. var expires = '';
  2005. if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
  2006. var date;
  2007. if (typeof options.expires == 'number') {
  2008. date = new Date();
  2009. date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
  2010. } else {
  2011. date = options.expires;
  2012. }
  2013. expires = '; expires=' + date.toUTCString();
  2014. }
  2015. var path = options.path ? '; path=' + (options.path) : '';
  2016. var domain = options.domain ? '; domain=' + (options.domain) : '';
  2017. var secure = options.secure ? '; secure' : '';
  2018. document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
  2019. } else {
  2020. var cookieValue = null;
  2021. if (document.cookie && document.cookie != '') {
  2022. var cookies = document.cookie.split(';');
  2023. for (var i = 0; i < cookies.length; i++) {
  2024. var cookie = jQuery.trim(cookies[i]);
  2025. if (cookie.substring(0, name.length + 1) == (name + '=')) {
  2026. cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
  2027. break;
  2028. }
  2029. }
  2030. }
  2031. return cookieValue;
  2032. }
  2033. }
  2034. ////Tabs方法 切换tab选项卡
  2035. /// <summary>选项卡</summary>
  2036. ; (function ($) {
  2037. $.fn.extend({
  2038. settabs: function (options) {
  2039. // 处理参数
  2040. options = $.extend({
  2041. event: 'mouseover',
  2042. timeout: 0,
  2043. auto: 0,
  2044. callback: null
  2045. }, options);
  2046. var self = $(this),
  2047. tabBox = self.children('div.sp-tab-box').children('div'),
  2048. menu = self.children('ul.sp-tab-menu'),
  2049. items = menu.find('li'),
  2050. timer;
  2051. var tabHandle = function (elem) {
  2052. elem.siblings('li').removeClass('sp-tab-current').end().addClass('sp-tab-current');
  2053. tabBox.siblings('div').addClass('sp-tab-hide').end().eq(elem.index()).removeClass('sp-tab-hide');
  2054. },
  2055. delay = function (elem, time) {
  2056. time ? setTimeout(function () { tabHandle(elem); }, time) : tabHandle(elem);
  2057. },
  2058. start = function () {
  2059. if (!options.auto) return;
  2060. timer = setInterval(autoRun, options.auto);
  2061. },
  2062. autoRun = function () {
  2063. var current = menu.find('li.sp-tab-current'),
  2064. firstItem = items.eq(0),
  2065. len = items.length,
  2066. index = current.index() + 1,
  2067. item = index === len ? firstItem : current.next('li'),
  2068. i = index === len ? 0 : index;
  2069. current.removeClass('sp-tab-current');
  2070. item.addClass('sp-tab-current');
  2071. tabBox.siblings('div').addClass('sp-tab-hide').end().eq(i).removeClass('sp-tab-hide');
  2072. };
  2073. items.bind(options.event, function () {
  2074. delay($(this), options.timeout);
  2075. if (options.callback) {
  2076. options.callback(self);
  2077. }
  2078. });
  2079. if (options.auto) {
  2080. start();
  2081. self.hover(function () {
  2082. clearInterval(timer);
  2083. timer = undefined;
  2084. }, function () {
  2085. start();
  2086. });
  2087. }
  2088. sp.settableft();
  2089. sp.settabright();
  2090. return this;
  2091. }
  2092. });
  2093. })(jQuery);
  2094. //////进度条横向20180606
  2095. ;(function ($) {
  2096. if (typeof ($.fn.myProgress) != 'undefined') {
  2097. return false;
  2098. }
  2099. $.fn.myProgress = function (options) {
  2100. initOptions(options);
  2101. $(this).each(function () {
  2102. var this_ = $(this);
  2103. var $percent = $(this).find("div.percent-show>span");
  2104. var progress_in = $(this).find("div.progress-in");
  2105. initCss(options, $(this));
  2106. var t = setInterval(function () {
  2107. $percent.html(parseInt(progress_in.width() / this_.width() * 100))
  2108. }, options.speed / 100);
  2109. progress_in.animate({
  2110. width: options.percent + "%"
  2111. }, options.speed, function () {
  2112. clearInterval(t);
  2113. t = null;
  2114. $percent.html(options.percent);
  2115. options.percent == 100 && progress_in.css("border-sp-radius", 0);
  2116. });
  2117. });
  2118. return $(this);
  2119. }
  2120. function initOptions(options) {
  2121. (!options.hasOwnProperty("speed") || isNaN(options.speed)) && (options.speed = 1000);
  2122. (!options.hasOwnProperty("percent") || isNaN(options.percent)) && (options.percent = 100);
  2123. !options.hasOwnProperty("width") && (options.width = '180px');
  2124. !options.hasOwnProperty("height") && (options.height = '15px');
  2125. !options.hasOwnProperty("direction") && (options.direction = 'left');
  2126. options.fontSize = Math.floor(parseInt(options.height) * 6 / 10) + "px";
  2127. options.lineHeight = options.height;
  2128. }
  2129. function initCss(options, obj) {
  2130. //////设置百分比的数字显示位置
  2131. var setleft = 0;
  2132. if (options.percent == 0) {
  2133. setleft = 0;
  2134. }
  2135. if (options.percent > 0 && options.percent <= 90) {
  2136. setleft = options.percent + "%";
  2137. }
  2138. if (options.percent > 90) {
  2139. setleft = options.percent - 8 + "%";
  2140. }
  2141. obj.css({
  2142. "width": options.width,
  2143. "height": options.height
  2144. }).find("div.percent-show").css({
  2145. "lineHeight": options.lineHeight,
  2146. "fontSize": options.fontSize,
  2147. "left": setleft
  2148. });
  2149. if (options.direction == "right") {
  2150. obj.find("div.progress-in").addClass("direction-right");
  2151. } else {
  2152. obj.find("div.progress-in").addClass("direction-left");
  2153. }
  2154. }
  2155. })(jQuery);
  2156. //
  2157. /*
  2158. *点击非当前显示元素时, 当前显示元素自动隐藏 chenhao 2018/3/15
  2159. * 使用方法
  2160. $('#btn').on("click",function(){
  2161. $('.menu').toggle().autoHide();
  2162. return false;
  2163. });
  2164. * autoHide(speed,callback)
  2165. * speed
  2166. 可选。规定元素从可见到隐藏的速度。默认为 "0"。
  2167. 可能的值:
  2168. 毫秒 (比如 1500)
  2169. "slow"
  2170. "normal"
  2171. "fast"
  2172. 在设置速度的情况下,元素从可见到隐藏的过程中,会逐渐地改变其高度、宽度、外边距、内边距和透明度。
  2173. * callback
  2174. 可选。autoHide 函数执行完之后,要执行的函数。
  2175. **** !! 除非设置了 speed 参数,否则不能设置该参数。
  2176. */
  2177. (function ($) {
  2178. $.fn.autoHide = function (speed, callback) {
  2179. var ele = $(this);
  2180. $(document).on('click', function (e) {
  2181. var e = e || window.event; //浏览器兼容性
  2182. e.target = e.target || e.srcElement;
  2183. if (ele.is(':visible') && (!$(e.target)[0].isEqualNode(ele[0]) && ele.has(e.target).length === 0)) {
  2184. ele.hide(speed, callback);
  2185. }
  2186. // e.stopPropagation();
  2187. // return false;
  2188. });
  2189. return this;
  2190. }
  2191. })(jQuery);
  2192. //iframe自适应内容长度 2016.08.07 setiframe(id);是定义的方法 window.setInterval("setiframe('id')", 10);功能:按照指定的周期(以毫秒计)来调用函数或计算表达式。
  2193. sp.setiframe = function (id) {
  2194. /// <summary>设置iframe自适应嵌套页高度</summary>
  2195. window.setInterval("sp.setiframe_getPageHight('" + id + "')", 10);
  2196. }
  2197. sp.setiframe_getPageHight = function (id) {
  2198. /// <summary>得到iframe嵌套的内容页高度</summary>
  2199. var Iframe = document.getElementById(id);
  2200. try {
  2201. // 声明变量取值
  2202. var bHeight = Iframe.contentWindow.document.body.scrollHeight;
  2203. var dHeight = Iframe.contentWindow.document.documentElement.scrollHeight;
  2204. var height = Math.max(bHeight, dHeight); // 取最大值
  2205. Iframe.height = height;
  2206. } catch (ex) { }
  2207. }
  2208. //javascript 解决IE8兼容 placeholder属性 含password 时间:20160811
  2209. sp.set_placeholder = function () {
  2210. if (!('placeholder' in document.createElement('input'))) {
  2211. function GetStringNumValue(pxstr) {
  2212. return pxstr.substring(0, pxstr.length - 2);
  2213. }
  2214. $('input[placeholder],textarea[placeholder]').each(function () {
  2215. var $element = $(this),
  2216. placeholder = $element.attr('placeholder');
  2217. if ($element.attr('type') != 'password') {//非密码
  2218. $element.css('color', '#cccccc');//placeholder定义文字颜色
  2219. if ($element.val() === "") {
  2220. $element.val(placeholder).addClass('placeholder');
  2221. }
  2222. $element.focus(function () {
  2223. if ($element.val() === placeholder) {
  2224. $element.val("").removeClass('placeholder');
  2225. $element.css('color', '#000'); //获取焦点输入文字颜色
  2226. }
  2227. }).blur(function () { //失去焦点进行判断
  2228. if ($element.val() === "") {
  2229. $element.val(placeholder).addClass('placeholder');
  2230. $element.css('color', '#ccc');
  2231. } else if ($element.val() == placeholder) {
  2232. $element.css('color', '#000');
  2233. } else {
  2234. $element.css('color', '#000');
  2235. }
  2236. }).closest('form').submit(function () {
  2237. if ($element.val() === placeholder) {
  2238. $element.val('');
  2239. }
  2240. });
  2241. }
  2242. //密码框的样式
  2243. else {
  2244. if (placeholder) {
  2245. var elementId = $element.attr('id');
  2246. if (!elementId) {
  2247. var now = new Date();
  2248. elementId = 'lbl_placeholder' + now.getSeconds() + now.getMilliseconds();
  2249. $element.attr('id', elementId);
  2250. }
  2251. }
  2252. // 添加label标签,用于显示placeholder的值
  2253. var $label = $('<label>', {
  2254. html: $element.val() ? '' : placeholder,
  2255. 'for': elementId,
  2256. css: {
  2257. position: 'absolute',
  2258. color: '#cccccc',
  2259. fontSize: $element.css('fontSize'),
  2260. fontFamily: $element.css('fontFamily')
  2261. }
  2262. }, '</label>').insertAfter($element);
  2263. // 绑定事件
  2264. var width = $element.width();
  2265. var width2 = width - 3 + "px";
  2266. var width3 = "-" + width2;
  2267. //alert(width3);
  2268. var _setPosition = function () {
  2269. $label.css({
  2270. position: 'relative',
  2271. top: '',
  2272. left: width3
  2273. });
  2274. };
  2275. var _resetPlaceholder = function () {
  2276. if ($element.val()) { $label.html(null); }
  2277. else {
  2278. _setPosition();
  2279. $label.html(placeholder);
  2280. }
  2281. };
  2282. _setPosition();
  2283. $element.on('focus blur input keyup propertychange resetplaceholder', _resetPlaceholder);
  2284. }
  2285. });
  2286. }
  2287. }
  2288. /**sp.CutTableTd(name);//给Table的Td加3个点和鼠标指向文字去除的文字都显示出来**/
  2289. sp.cutgrid = function (TableID, Len) {
  2290. /// <summary>截取table的文字长度</summary>
  2291. /// <param name="TableID">表格的ID</param>
  2292. /// <param name="Len">需要截取的长度</param>
  2293. /// <returns></returns>
  2294. $(TableID + " tr td").each(function (index, value) {
  2295. var GetText = "";
  2296. if ($(this).children().length > 0) {
  2297. GetText = $(this).contents().text();//获取td中的内容
  2298. GetText = GetText.cutstr(Len); //截取字符串
  2299. $(this).contents().text(GetText);//赋值td中的内容
  2300. }
  2301. else {
  2302. GetText = $(this).text();//获取td中的内容
  2303. GetText = GetText.cutstr(Len); //截取字符串
  2304. $(this).text(GetText);//赋值td中的内容
  2305. }
  2306. });
  2307. };
  2308. //通过正则表达式获取地址栏的参数 var get_name = sp.getUrlName("name");
  2309. sp.getUrlName = function (name) {
  2310. /// <summary>
  2311. /// 获取url中特定的参数
  2312. /// </summary>
  2313. /// <param name="name">具体参数变量名</param>
  2314. /// <returns>返回变量值</returns>
  2315. var result = location.search.match(new RegExp("[\?\&]" + name + "=([^\&]+)", "i"));
  2316. if (result == null || result.length < 1) {
  2317. return "";
  2318. }
  2319. return result[1];
  2320. }
  2321. sp.geturl = function () {
  2322. /// <summary>
  2323. /// 获取url中全部参数
  2324. /// </summary>
  2325. /// <returns>返回数组格式</returns>
  2326. var str = location.href; //取得整个地址栏
  2327. var num = str.indexOf("?")
  2328. str = str.substr(num + 1); //取得所有参数
  2329. var loastr = "";
  2330. var loc = "";
  2331. $.each(str.split('&'), function (index, item) {
  2332. item = item.split('=');
  2333. var name = item[0];
  2334. var val = item[1];
  2335. loastr = "\"" + name + "\":\"" + val + "\",";
  2336. loc += loastr;
  2337. });
  2338. loc = loc.substring(0, loc.length - 1);
  2339. loc = "{" + loc + "}";
  2340. var obj = JSON.parse(loc); //将字符型数组转换为对象
  2341. return obj;
  2342. }
  2343. //设置折叠面板
  2344. sp.setPanel = function () {
  2345. /// <summary>折叠面板</summary>
  2346. if ($("body").find(".sp-panel-folder").length > 0) {
  2347. $('.sp-panel-folder').each(function () {
  2348. $('.sp-panel-head', this).on('click', function () {
  2349. if ($(this).hasClass('click')) {
  2350. $(this).parent().children('.sp-panel-body').slideUp(230);
  2351. $(this).removeClass('click');
  2352. } else {
  2353. $(this).parent().children('.sp-panel-body').slideDown(230);
  2354. $(this).parent().siblings('.sp-panel-folder').children('.sp-panel-body').slideUp(230);
  2355. $(this).parent().siblings('.sp-panel-folder').children('.sp-panel-head').removeClass('click');
  2356. $(this).addClass('click');
  2357. }
  2358. });
  2359. });
  2360. }
  2361. }
  2362. //获取json串的长度 var jsonLen=sp.getJsonLen(jsonData);
  2363. sp.getJsonLen = function (json) {
  2364. /// <summary>获取json串长度</summary>
  2365. var Length = 0;
  2366. for (var item in json) {
  2367. Length++;
  2368. }
  2369. return Length;
  2370. }
  2371. //删除含有特定文字的table某列 table:id或class名,str:特定文字
  2372. sp.delCol = function (table, str) {
  2373. /// <summary>removeTD("#tableTD", "编号");</summary>
  2374. var getindex;
  2375. $("" + table + " thead tr th").each(function () {
  2376. var gettext = $(this).text();
  2377. if (gettext == str) {
  2378. getindex = $(this).index();
  2379. $(this).remove();
  2380. }
  2381. });
  2382. $("" + table + " tbody tr").each(function () {
  2383. $("td:eq(" + getindex + ")", this).remove();
  2384. });
  2385. }
  2386. ////组织事件
  2387. sp.stopPropagation = function (e) {
  2388. /// <summary>阻止浏览器的冒泡</summary>
  2389. var ev = e || window.event;
  2390. if (ev.stopPropagation) {
  2391. ev.stopPropagation();
  2392. }
  2393. else if (window.event) {
  2394. window.event.cancelBubble = true;//兼容IE
  2395. }
  2396. }
  2397. //点击一个按钮显示div,点击div之外的地方div隐藏,点击div之内的地方div不隐藏
  2398. sp.clickDomCloseDiv = function (btn, div) {
  2399. /// <summary>点击按钮显示div,点击页面其他地方div隐藏,点击div阻止冒泡</summary>
  2400. $(btn).on("click", function (e) {
  2401. if ($(btn).hasClass("clickDom")) {
  2402. $(btn).removeClass("clickDom");
  2403. $(div).hide();
  2404. sp.stopPropagation(e);
  2405. } else {
  2406. $(btn).addClass("clickDom");
  2407. $(div).show();
  2408. sp.stopPropagation(e);
  2409. }
  2410. });
  2411. $(document).bind('click', function () {
  2412. $(btn).removeClass("clickDom");
  2413. $(div).hide();
  2414. });
  2415. $(div).click(function (e) {
  2416. sp.stopPropagation(e);
  2417. });
  2418. }
  2419. //类似:[{name:"张三", val:"111"},{name:"张三", val:"111"}]
  2420. sp.serializeJSON = function (str) {
  2421. /// <summary>将序列化的值转成json格式</summary>
  2422. var testJson = decodeURIComponent(str, true);//将数据解码,调用decodeURIComponent(XXX,true);中文会乱码,需要将乱码解码
  2423. var loastr = "";
  2424. var loc = "";
  2425. $.each(testJson.split('&'), function (index, item) {
  2426. item = item.split('=');
  2427. var name = item[0], val = item[1];
  2428. loastr = "{\"dname\":\"" + name + "\", \"dval\":\"" + val + "\"},";
  2429. loc += loastr;
  2430. });
  2431. loc = loc.substring(0, loc.length - 1);
  2432. loc = "[" + loc + "]";
  2433. var obj = JSON.parse(loc);//将字符型数组转换为对象
  2434. return obj;
  2435. }
  2436. //遍历某行下的所有的td,然后将其内容以数组形式返回
  2437. sp.eachTDtoArray = function (rowid) {
  2438. /// <summary>遍历该行td的内容,返回数组</summary>
  2439. var alltdText = "";
  2440. $("#" + rowid + " td").each(function () {
  2441. var getText = $.trim($(this).text());
  2442. alltdText += getText + ",";
  2443. });
  2444. var alltdText2 = alltdText.substring(0, alltdText.length - 2);
  2445. var obj = alltdText2.split(",");
  2446. return obj;
  2447. }
  2448. //设置select框的年月, 程序自动跟据当前年显示20170310
  2449. //赋值年份
  2450. sp.selectYear = function (name) {
  2451. /// <summary>设置select框的年份</summary>
  2452. var getyear = new Date().getFullYear(); //今年
  2453. for (var i = (getyear - 20); i < (getyear + 20); i++) //以今年为准,前30年,后30年
  2454. {
  2455. $(name).append("<option value='" + i + "'>" + i + "</option>");
  2456. }
  2457. $(name).find("option[value='" + getyear + "']").attr("selected", true);
  2458. $(name).val(getyear);
  2459. }
  2460. //赋值月份
  2461. sp.selectMonth = function (name) {
  2462. /// <summary>设置select框的月份</summary>
  2463. var getMonth = new Date().getMonth() + 1; //当前月
  2464. for (var i = 1; i < 13; i++) {
  2465. $(name).append("<option value='" + i + "'>" + i + "</option>");
  2466. }
  2467. $(name).find("option[value='" + getMonth + "']").attr("selected", true);
  2468. $(name).val(getMonth);
  2469. }
  2470. sp.showLocalTime = function (divname) {
  2471. /// <summary>动态显示当地时间</summary>
  2472. var objDate = new Date();
  2473. var str, colorhead, colorfoot;
  2474. var yy = objDate.getYear();
  2475. if (yy < 1900) yy = yy + 1900;
  2476. var MM = objDate.getMonth() + 1;
  2477. if (MM < 10) MM = '0' + MM;
  2478. var dd = objDate.getDate();
  2479. if (dd < 10) dd = '0' + dd;
  2480. var hh = objDate.getHours();
  2481. if (hh < 10) hh = '0' + hh;
  2482. var mm = objDate.getMinutes();
  2483. if (mm < 10) mm = '0' + mm;
  2484. var ss = objDate.getSeconds();
  2485. if (ss < 10) ss = '0' + ss;
  2486. var ww = objDate.getDay();
  2487. if (ww == 0) ww = "星期日";
  2488. if (ww == 1) ww = "星期一";
  2489. if (ww == 2) ww = "星期二";
  2490. if (ww == 3) ww = "星期三";
  2491. if (ww == 4) ww = "星期四";
  2492. if (ww == 5) ww = "星期五";
  2493. if (ww == 6) ww = "星期六";
  2494. str = yy + "年" + MM + "月" + dd + "日&nbsp;" + hh + ":" + mm + ":" + ss + "&nbsp;" + ww;
  2495. var get_time = str;
  2496. $(divname).html(get_time);
  2497. window.setTimeout("sp.showLocalTime('" + divname + "')", 1000); ///延时1秒执行
  2498. };
  2499. //获取当前时间,格式:2018-1-27 10:47:15
  2500. sp.getLocalDate = function () {
  2501. var objDate = new Date();
  2502. var str, colorhead, colorfoot;
  2503. var yy = objDate.getFullYear();
  2504. var MM = objDate.getMonth() + 1;
  2505. if (MM < 10) MM = '0' + MM;
  2506. var dd = objDate.getDate();
  2507. if (dd < 10) dd = '0' + dd;
  2508. var hh = objDate.getHours();
  2509. if (hh < 10) hh = '0' + hh;
  2510. var mm = objDate.getMinutes();
  2511. if (mm < 10) mm = '0' + mm;
  2512. var ss = objDate.getSeconds();
  2513. if (ss < 10) ss = '0' + ss;
  2514. str = yy + "-" + MM + "-" + dd + " " + hh + ":" + mm + ":" + ss;
  2515. return str;
  2516. };
  2517. //利用当前时间生成yyyymmddhhmmss这样的字符串
  2518. sp.setNumRandom = function () {
  2519. var date = new Date();
  2520. var yyyy = date.getFullYear().toString();
  2521. var MM = date.getMonth() + 1;
  2522. if (MM < 10) MM = '0' + MM;
  2523. var dd = date.getDate();
  2524. if (dd < 10) dd = '0' + dd;
  2525. var hh = date.getHours();
  2526. if (hh < 10) hh = '0' + hh;
  2527. var mm = date.getMinutes();
  2528. if (mm < 10) mm = '0' + mm;
  2529. var ss = date.getSeconds();
  2530. if (ss < 10) ss = '0' + ss;
  2531. var millisecond = date.getMilliseconds(); //获取当前毫秒数(0-999)
  2532. var setTimeStr = yyyy + MM + dd + hh + mm + ss + millisecond;
  2533. return setTimeStr;
  2534. };
  2535. //格式化日期 如:2017-10-10 22:33:32
  2536. sp.format = function (str) {
  2537. if (str == "1900-01-01T00:00:00") {
  2538. str = "";
  2539. return str;
  2540. } else if (str == "0001-01-01T00:00:00") {
  2541. ///这种情况是在做滨旅建管系统时用sqlserver数据库时遇到的
  2542. str = "";
  2543. return str;
  2544. } else if (str == "-") {
  2545. ///在做滨旅建管时存的是—,然后就让其显示—
  2546. str = "-";
  2547. return str;
  2548. } else if (str != undefined && str != "" && str != null) {
  2549. /////如果找到"-",不等于负1
  2550. if (str.toString().indexOf('-') != -1) {
  2551. str = str.replace(/-/g, "/"); //将-替换为/,因为ios与ie浏览器中不支持-和T
  2552. }
  2553. /////如果找到T,不等于负1
  2554. if (str.toString().indexOf('T') != -1) {
  2555. str = str.replace(/T/g, ' '); ///去掉日期中的T,因为ios与ie浏览器中不支持-和T
  2556. }
  2557. /////如果找到".",不等于负1
  2558. if (str.toString().indexOf('.') != -1) {
  2559. str = str.slice(0, str.indexOf(".")); ///如果含有毫秒,就将毫秒去掉
  2560. }
  2561. var formatDate = new Date(Date.parse(str));
  2562. var yy = formatDate.getFullYear();
  2563. var MM = formatDate.getMonth() + 1;
  2564. if (MM < 10) { MM = '0' + MM; }
  2565. var dd = formatDate.getDate();
  2566. if (dd < 10) { dd = '0' + dd; }
  2567. var setDate = yy + "-" + MM + "-" + dd;
  2568. return setDate;
  2569. } else {
  2570. str = "";
  2571. return str;
  2572. }
  2573. };
  2574. ///格式化时间,为年月日时分秒
  2575. sp.formatMinute = function (str) {
  2576. if (str == "1900-01-01T00:00:00") {
  2577. str = "";
  2578. return str;
  2579. } else if (str == "0001-01-01T00:00:00") {
  2580. ///这种情况是在做滨旅建管系统时用sqlserver数据库时遇到的
  2581. str = "";
  2582. return str;
  2583. }
  2584. else if (str != undefined && str != "" && str != null) {
  2585. /////如果找到"-",不等于负1
  2586. if (str.toString().indexOf('-') != -1) {
  2587. str = str.replace(/-/g, "/"); //将-替换为/,因为ios与ie浏览器中不支持-和T
  2588. }
  2589. /////如果找到T,不等于负1
  2590. if (str.toString().indexOf('T') != -1) {
  2591. str = str.replace(/T/g, ' '); ///去掉日期中的T,因为ios与ie浏览器中不支持-和T
  2592. }
  2593. /////如果找到".",不等于负1
  2594. if (str.toString().indexOf('.') != -1) {
  2595. str = str.slice(0, str.indexOf(".")); ///如果含有毫秒,就将毫秒去掉
  2596. }
  2597. var formatDate = new Date(Date.parse(str));
  2598. var yy = formatDate.getFullYear();
  2599. var MM = formatDate.getMonth() + 1;
  2600. if (MM < 10) { MM = '0' + MM; } //去掉前面加0,是为了便于后续的格式化得到年月
  2601. var dd = formatDate.getDate();
  2602. if (dd < 10) { dd = '0' + dd; } //去掉前面加0,是为了便于后续的格式化得到年月
  2603. var hh = formatDate.getHours();
  2604. if (hh < 10) { hh = '0' + hh; }
  2605. var mm = formatDate.getMinutes();
  2606. if (mm < 10) { mm = '0' + mm; }
  2607. var ss = formatDate.getSeconds();
  2608. if (ss < 10) { ss = '0' + ss; }
  2609. var setDate = yy + "-" + MM + "-" + dd + " " + hh + ":" + mm + ":" + ss;
  2610. return setDate;
  2611. } else {
  2612. str = "";
  2613. return str;
  2614. }
  2615. };
  2616. ///格式化时间,显示当前月第一天
  2617. sp.monthfirst = function (str) {
  2618. if (str == "1900-01-01T00:00:00") {
  2619. str = "";
  2620. return str;
  2621. } else if (str == "0001-01-01T00:00:00") {
  2622. ///这种情况是在做滨旅建管系统时用sqlserver数据库时遇到的
  2623. str = "";
  2624. return str;
  2625. }
  2626. else if (str != undefined && str != "" && str != null) {
  2627. /////如果找到"-",不等于负1
  2628. if (str.toString().indexOf('-') != -1) {
  2629. str = str.replace(/-/g, "/"); //将-替换为/,因为ios与ie浏览器中不支持-和T
  2630. }
  2631. /////如果找到T,不等于负1
  2632. if (str.toString().indexOf('T') != -1) {
  2633. str = str.replace(/T/g, ' '); ///去掉日期中的T,因为ios与ie浏览器中不支持-和T
  2634. }
  2635. /////如果找到".",不等于负1
  2636. if (str.toString().indexOf('.') != -1) {
  2637. str = str.slice(0, str.indexOf(".")); ///如果含有毫秒,就将毫秒去掉
  2638. }
  2639. var formatDate = new Date(Date.parse(str));
  2640. var yy = formatDate.getFullYear();
  2641. var MM = formatDate.getMonth() + 1;
  2642. if (MM < 10) { MM = '0' + MM; }
  2643. var returnData = yy + "-" + MM + "-01";
  2644. return returnData;
  2645. } else {
  2646. str = "";
  2647. return str;
  2648. }
  2649. };
  2650. ///格式化时间,显示当前月最后一天
  2651. sp.formatMonthLast = function (str) {
  2652. if (str == "1900-01-01T00:00:00") {
  2653. str = "";
  2654. return str;
  2655. } else if (str == "0001-01-01T00:00:00") {
  2656. ///这种情况是在做滨旅建管系统时用sqlserver数据库时遇到的
  2657. str = "";
  2658. return str;
  2659. }
  2660. else if (str != undefined && str != "" && str != null) {
  2661. /////如果找到"-",不等于负1
  2662. if (str.toString().indexOf('-') != -1) {
  2663. str = str.replace(/-/g, "/"); //将-替换为/,因为ios与ie浏览器中不支持-和T
  2664. }
  2665. /////如果找到T,不等于负1
  2666. if (str.toString().indexOf('T') != -1) {
  2667. str = str.replace(/T/g, ' '); ///去掉日期中的T,因为ios与ie浏览器中不支持-和T
  2668. }
  2669. /////如果找到".",不等于负1
  2670. if (str.toString().indexOf('.') != -1) {
  2671. str = str.slice(0, str.indexOf(".")); ///如果含有毫秒,就将毫秒去掉
  2672. }
  2673. var formatDate = new Date(Date.parse(str));
  2674. var yy = formatDate.getFullYear();
  2675. var MM = formatDate.getMonth() + 1;
  2676. var returnData = sp.getLastDayOfMonth(yy, MM);
  2677. return returnData;
  2678. } else {
  2679. str = "";
  2680. return str;
  2681. }
  2682. };
  2683. /**
  2684. * 获取某年某月的最后一天
  2685. */
  2686. sp.getLastDayOfMonth = function (year, month) {
  2687. //获取本年本月的第一天日期
  2688. var date = new Date(year, month - 1, '01');
  2689. //设置日期
  2690. date.setDate(1);
  2691. //设置月份
  2692. date.setMonth(date.getMonth() + 1);
  2693. //获取本月的最后一天
  2694. cdate = new Date(date.getTime() - 1000 * 60 * 60 * 24);
  2695. //打印某年某月的最后一天
  2696. //alert(cdate.getFullYear() + "年" + (Number(cdate.getMonth()) + 1) + "月最后一天的日期:" + cdate.getDate() + "日");
  2697. var yy = cdate.getFullYear();
  2698. var MM = cdate.getMonth() + 1;
  2699. if (MM < 10) { MM = '0' + MM; }
  2700. var setData = yy + "-" + MM + "-" + cdate.getDate();
  2701. //返回结果
  2702. return setData;
  2703. }
  2704. ////格式化日期获取其年份
  2705. sp.formatGetYear = function (str) {
  2706. var formatDate = new Date(sp.format(str));
  2707. var yy = formatDate.getFullYear();
  2708. return yy;
  2709. }
  2710. ////格式化日期获取其月份
  2711. sp.formatGetMonth = function (str) {
  2712. var formatDate = new Date(sp.format(str));
  2713. var MM = formatDate.getMonth() + 1;
  2714. return MM;
  2715. }
  2716. ////获取当前年份
  2717. sp.currentYear = function () {
  2718. var date = new Date();
  2719. var yyyy = date.getFullYear().toString();
  2720. return yyyy;
  2721. }
  2722. ////获取当前月份
  2723. sp.currentMonth = function () {
  2724. var date = new Date();
  2725. var MM = date.getMonth() + 1;
  2726. return MM;
  2727. }
  2728. /**************************************时间格式化处理************************************/
  2729. ///format格式化缩写为fmt,两个参数,前者是日期格式,后者是日期
  2730. sp.datefmt = function (fmt, date) {
  2731. ///console.log(date);
  2732. if (date == "1900-01-01T00:00:00") {
  2733. date = "";
  2734. return date;
  2735. } else if (date == "0001-01-01T00:00:00") {
  2736. ///这种情况是在做滨旅建管系统时用sqlserver数据库时遇到的
  2737. date = "";
  2738. return date;
  2739. } else if (date == "-") {
  2740. ///在做滨旅建管时存的是—,然后就让其显示—
  2741. date = "-";
  2742. return date;
  2743. } else if (date != undefined && date != "" && date != null) {
  2744. /////如果找到"-",不等于负1
  2745. if (date.toString().indexOf('-') != -1) {
  2746. date = date.replace(/-/g, "/"); //将-替换为/,因为ios与ie浏览器中不支持-和T
  2747. }
  2748. /////如果找到T,不等于负1
  2749. if (date.toString().indexOf('T') != -1) {
  2750. date = date.replace(/T/g, ' '); ///去掉日期中的T,因为ios与ie浏览器中不支持-和T
  2751. }
  2752. /////如果找到".",不等于负1
  2753. if (date.toString().indexOf('.') != -1) {
  2754. date = date.slice(0, date.indexOf(".")); ///如果含有毫秒,就将毫秒去掉
  2755. }
  2756. var formatDate = new Date(Date.parse(date));
  2757. var o = {
  2758. "M+": formatDate.getMonth() + 1, //月份
  2759. "d+": formatDate.getDate(), //日
  2760. "H+": formatDate.getHours(), //小时
  2761. "m+": formatDate.getMinutes(), //分
  2762. "s+": formatDate.getSeconds(), //秒
  2763. "q+": Math.floor((formatDate.getMonth() + 3) / 3), //季度
  2764. "S": formatDate.getMilliseconds() //毫秒
  2765. };
  2766. if (/(y+)/.test(fmt))
  2767. fmt = fmt.replace(RegExp.$1, (formatDate.getFullYear() + "").substr(4 - RegExp.$1.length));
  2768. for (var k in o)
  2769. if (new RegExp("(" + k + ")").test(fmt))
  2770. fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
  2771. return fmt;
  2772. } else {
  2773. date = "";
  2774. return date;
  2775. }
  2776. };
  2777. ////得到后几天的日期2019-10-26
  2778. ///sp.dateCount(7);//得到7天后的日子
  2779. sp.dateCount = function (AddDayCount) {
  2780. var dd = new Date();
  2781. dd.setDate(dd.getDate() + AddDayCount);//获取AddDayCount天后的日期
  2782. var y = dd.getFullYear();
  2783. var m = (dd.getMonth() + 1) < 10 ? "0" + (dd.getMonth() + 1) : (dd.getMonth() + 1);//获取当前月份的日期,不足10补0
  2784. var d = dd.getDate() < 10 ? "0" + dd.getDate() : dd.getDate();//获取当前几号,不足10补0
  2785. return y + "-" + m + "-" + d;
  2786. }
  2787. /// 2019-12-20
  2788. // 往前数monthNum月份:sp.getPreMonthDay("2019-12-20",-10),往后数monthNum :sp.getPreMonthDay("2019-12-20",20);
  2789. sp.getPreMonthDay = function (date, monthNum) {
  2790. var dd = new Date(new Date(date).setMonth((new Date(date).getMonth() + monthNum)));
  2791. var y = dd.getFullYear();
  2792. var m = (dd.getMonth() + 1) < 10 ? "0" + (dd.getMonth() + 1) : (dd.getMonth() + 1);//获取当前月份的日期,不足10补0
  2793. var d = dd.getDate() < 10 ? "0" + dd.getDate() : dd.getDate();//获取当前几号,不足10补0
  2794. return y + "-" + m + "-" + d;
  2795. },
  2796. ///2019-12-21得到几天前和几天后的日期 getday(7);//7天后的日期 getday(17);//7天前的日期
  2797. sp.getday = function (aa) {
  2798. var date1 = new Date(),
  2799. time1 = date1.getFullYear() + "-" + (date1.getMonth() + 1) + "-" + date1.getDate();//time1表示当前时间
  2800. var date2 = new Date(date1);
  2801. date2.setDate(date1.getDate() + aa);
  2802. var y = date2.getFullYear();
  2803. var m = (date2.getMonth() + 1) < 10 ? "0" + (date2.getMonth() + 1) : (date2.getMonth() + 1);//获取当前月份的日期,不足10补0
  2804. var d = date2.getDate() < 10 ? "0" + date2.getDate() : date2.getDate();//获取当前几号,不足10补0
  2805. var time2 = y + "-" + m + "-" + d;
  2806. return time2;
  2807. }
  2808. ////实时保存,实时保存表单数据 【2018-3-25】
  2809. ///用法:sp.localStorage("#formPlan",85);
  2810. //从localStorage中加载数据记得删除:
  2811. //var setId = "localStorage_formPlan_" + dataID;
  2812. //localStorage.removeItem(setId);
  2813. sp.localStorage = function (formId, dataID) {
  2814. /// <summary>formId:为form定义的id</summary>
  2815. /// <summary>dataID:表单数据的ID,目的防止重复</summary>
  2816. var get_formid = $(formId).attr("id");
  2817. ////声明本地存储localStorage的名称
  2818. var set_localStorage = 'localStorage_' + get_formid + "_" + dataID;
  2819. ///声明变量,得到form下面的带有name的所有控件
  2820. var formControls = $(formId).find("input:text[name],textarea[name],select[name]");
  2821. //从本地取localStorage
  2822. var storage = localStorage.getItem(set_localStorage);
  2823. ////如果,本地从本地取localStorage不为null,
  2824. ///遍历localStorage中的值,
  2825. if (storage != null) {
  2826. var myData = JSON.parse(storage);
  2827. formControls.each(function (i, e) {
  2828. var name = $(e).attr("name");
  2829. if (myData[name] != null) {
  2830. $(e).val(myData[name]);
  2831. $(e).change();
  2832. }
  2833. });
  2834. }
  2835. //绑定change事件,监听onchage事件
  2836. formControls.each(function (i, el) {
  2837. var name = $(el).attr('name');
  2838. if (name) {
  2839. $(el).on('change', function () {
  2840. onchange(this);
  2841. });
  2842. }
  2843. });
  2844. //触发onchange事件时,保存到本地存储,或者更新本地存储中的值
  2845. function onchange(el) {
  2846. var storage = localStorage.getItem(set_localStorage);
  2847. if (storage == null) {
  2848. var formDataDb = new Object();
  2849. var key = $(el).attr("name");
  2850. var value = $(el).val();
  2851. formDataDb[key] = value;
  2852. localStorage.setItem(set_localStorage, JSON.stringify(formDataDb));
  2853. } else {
  2854. var myData = JSON.parse(storage);
  2855. var key = $(el).attr("name");
  2856. var value = $(el).val();
  2857. myData[key] = value;
  2858. localStorage.setItem(set_localStorage, JSON.stringify(myData));
  2859. }
  2860. }
  2861. }
  2862. //只冻结表格头部首行 调用方式 fixTableHead('#TableId', 0),只能调用table的ID table表的宽度应该限制为固定宽度,width:100%;
  2863. sp.fixTableHead = function (table, rows) {
  2864. /// <summary>只冻结表格头部首行</summary>
  2865. if ($("#" + table + "_tableLayout").length != 0) {
  2866. $("#" + table + "_tableLayout").before($("#" + table));
  2867. $("#" + table + "_tableLayout").html('<div id="' + table + '_fixedHead" style="overflow:hidden"></div><div id="' + table + '_tableBody" style="overflow:auto"></div>');
  2868. } else {
  2869. $("#" + 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>');
  2870. }
  2871. var $tableLayout = $("#" + table + "_tableLayout");
  2872. var $fixedHead = $("#" + table + "_fixedHead");
  2873. var $tableBody = $("#" + table + "_tableBody");
  2874. var rows = rows || 1; //默认固定1行
  2875. var $table = $("#" + table);
  2876. var $tableClone = $table.clone(true).removeAttr("id");
  2877. $table.appendTo($tableBody);
  2878. $tableClone.appendTo($fixedHead);
  2879. $tableLayout.find('table').css("margin", "0");
  2880. var theadHeight = 0;
  2881. if ($table.find('thead').length != 0) {
  2882. theadHeight = $table.find('thead').height();
  2883. } else {
  2884. for (var i = 0; i < rows; i++) {
  2885. theadHeight += $table.find('tr').eq(i).height
  2886. }
  2887. }
  2888. $fixedHead.height(theadHeight);
  2889. $tableBody.height($tableLayout.height() - theadHeight);
  2890. var tableWidth = $table.outerWidth();
  2891. $table.css("marginTop", -theadHeight)
  2892. if ($table.height() - theadHeight > $tableBody.height()) {
  2893. $fixedHead.width($tableLayout.width() - 18)
  2894. $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>')
  2895. }
  2896. $tableBody.scroll(function () {
  2897. $fixedHead.scrollLeft($tableBody.scrollLeft());
  2898. });
  2899. var resizeTimer = null;
  2900. $(window).resize(function () {
  2901. if (resizeTimer) clearTimeout(resizeTimer);
  2902. resizeTimer = setTimeout(function () {
  2903. $fixedHead.height(theadHeight);
  2904. $tableBody.height($tableLayout.height() - theadHeight);
  2905. if ($table.height() - theadHeight > $tableBody.height()) {
  2906. $fixedHead.width($tableLayout.width() - 18);
  2907. if ($tableLayout.find('#' + table + '_gutter').length == 0) {
  2908. $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>')
  2909. }
  2910. } else {
  2911. $fixedHead.width($tableLayout.width() - 1);
  2912. $tableLayout.find('#' + table + '_gutter').remove();
  2913. }
  2914. }, 100);
  2915. });
  2916. }
  2917. //冻结头和列 调用: fixTable("MyTable", 1, 600, 300); 锁定表头和列: Table的ID、列的个数、显示的宽度、显示的高度,宽度不固定
  2918. /// 锁定表头和列. table表的宽度是不能限制为固定,min-width:100%;
  2919. sp.fixTable = function (TableID, FixColumnNumber, width, height) {
  2920. /// <summary>冻结表头和列</summary>
  2921. $(document).ready(function () {
  2922. if ($("#" + TableID + "_tableLayout").length != 0) {
  2923. $("#" + TableID + "_tableLayout").before($("#" + TableID)); $("#" + TableID + "_tableLayout").empty();
  2924. }
  2925. else {
  2926. $("#" + TableID).after("<div id=\"" + TableID + "_tableLayout\" style=\"overflow:hidden;height:" + height + "px; width:" + width + "px;\"></div>");
  2927. }
  2928. $("<div id=\"" + TableID + "_tableFix\"></div>" + "<div id=\"" + TableID + "_tableHead\"></div>" + "<div id=\"" + TableID + "_tableColumn\"></div>" + "<div id=\"" + TableID + "_tableData\"></div>").appendTo("#" + TableID + "_tableLayout");
  2929. var oldtable = $("#" + TableID);
  2930. var tableFixClone = oldtable.clone(true);
  2931. tableFixClone.attr("id", TableID + "_tableFixClone");
  2932. $("#" + TableID + "_tableFix").append(tableFixClone);
  2933. var tableHeadClone = oldtable.clone(true);
  2934. tableHeadClone.attr("id", TableID + "_tableHeadClone");
  2935. $("#" + TableID + "_tableHead").append(tableHeadClone);
  2936. var tableColumnClone = oldtable.clone(true);
  2937. tableColumnClone.attr("id", TableID + "_tableColumnClone");
  2938. $("#" + TableID + "_tableColumn").append(tableColumnClone);
  2939. $("#" + TableID + "_tableData").append(oldtable);
  2940. $("#" + TableID + "_tableLayout table").each(function () {
  2941. $(this).css("margin", "0");
  2942. });
  2943. var HeadHeight = $("#" + TableID + "_tableHead thead").height();
  2944. HeadHeight += 2;
  2945. $("#" + TableID + "_tableHead").css("height", HeadHeight);
  2946. $("#" + TableID + "_tableFix").css("height", HeadHeight);
  2947. var ColumnsWidth = 0;
  2948. var ColumnsNumber = 0;
  2949. $("#" + TableID + "_tableColumn tr:last td:lt(" + FixColumnNumber + ")").each(function () {
  2950. ColumnsWidth += $(this).outerWidth(true);
  2951. ColumnsNumber++;
  2952. });
  2953. ColumnsWidth += 2;
  2954. if ($.browser.msie) {
  2955. switch ($.browser.version) {
  2956. case "7.0":
  2957. if (ColumnsNumber >= 3) ColumnsWidth--;
  2958. break;
  2959. case "8.0":
  2960. if (ColumnsNumber >= 2) ColumnsWidth--;
  2961. break;
  2962. }
  2963. }
  2964. $("#" + TableID + "_tableColumn").css("width", ColumnsWidth);
  2965. $("#" + TableID + "_tableFix").css("width", ColumnsWidth);
  2966. $("#" + TableID + "_tableData").scroll(function () {
  2967. $("#" + TableID + "_tableHead").scrollLeft($("#" + TableID + "_tableData").scrollLeft());
  2968. $("#" + TableID + "_tableColumn").scrollTop($("#" + TableID + "_tableData").scrollTop());
  2969. });
  2970. $("#" + TableID + "_tableFix").css({ "overflow": "hidden", "position": "relative", "z-index": "50", "background-color": "Silver" });
  2971. $("#" + TableID + "_tableHead").css({ "overflow": "hidden", "width": width - 17, "position": "relative", "z-index": "45", "background-color": "#fff" });
  2972. $("#" + TableID + "_tableColumn").css({ "overflow": "hidden", "height": height - 17, "position": "relative", "z-index": "40", "background-color": "Silver" });
  2973. $("#" + TableID + "_tableData").css({ "overflow": "scroll", "width": width, "height": height, "position": "relative", "z-index": "35" });
  2974. if ($("#" + TableID + "_tableHead").width() > $("#" + TableID + "_tableFix table").width()) {
  2975. $("#" + TableID + "_tableHead").css("width", $("#" + TableID + "_tableFix table").width());
  2976. $("#" + TableID + "_tableData").css("width", $("#" + TableID + "_tableFix table").width() + 17);
  2977. }
  2978. if ($("#" + TableID + "_tableColumn").height() > $("#" + TableID + "_tableColumn table").height()) {
  2979. $("#" + TableID + "_tableColumn").css("height", $("#" + TableID + "_tableColumn table").height());
  2980. $("#" + TableID + "_tableData").css("height", $("#" + TableID + "_tableColumn table").height() + 17);
  2981. }
  2982. $("#" + TableID + "_tableFix").offset($("#" + TableID + "_tableLayout").offset());
  2983. $("#" + TableID + "_tableHead").offset($("#" + TableID + "_tableLayout").offset());
  2984. $("#" + TableID + "_tableColumn").offset($("#" + TableID + "_tableLayout").offset());
  2985. $("#" + TableID + "_tableData").offset($("#" + TableID + "_tableLayout").offset());
  2986. });
  2987. }
  2988. //获取滚动条宽度
  2989. sp.getScrollbarWidth = function () {
  2990. var oP = document.createElement('p'), styles = {
  2991. width: '100px',
  2992. height: '100px',
  2993. overflowY: 'scroll',
  2994. }, i, scrollbarWidth;
  2995. for (i in styles) {
  2996. oP.style[i] = styles[i];
  2997. }
  2998. document.body.appendChild(oP);
  2999. scrollbarWidth = oP.offsetWidth - oP.clientWidth;
  3000. oP.remove();
  3001. return scrollbarWidth;
  3002. }
  3003. // ************** 使用列很多的表格
  3004. sp.fixTab2 = function (TableID, FixColumnNumber) {
  3005. var scrollWidth = 17
  3006. var table = "#" + TableID;
  3007. var $table = $(table);
  3008. if ($(table + "_tableLayout").length != 0) {
  3009. $(table + "_tableLayout").before($(table));
  3010. $(table + "_tableLayout").empty();
  3011. } else {
  3012. $table.after('<div id="' + TableID + '_tableLayout" style="overflow:hidden;width:100%;max-height:100%;position:relative"></div>');
  3013. }
  3014. var $tableLayout = $(table + "_tableLayout");
  3015. //添加外壳
  3016. $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>')
  3017. //获取外壳
  3018. var $tableFix = $(table + "_tableFix");
  3019. var $tableHead = $(table + "_tableHead");
  3020. var $columnBox = $("#columnBox");
  3021. var $tableColumn = $(table + "_tableColumn");
  3022. var $tableData = $(table + "_tableData");
  3023. // console.log($table.width());
  3024. // console.log($table.outerWidth());
  3025. // $table.width(tableWidth);
  3026. //获取表头高度
  3027. var HeadHeight = $(table + " thead").outerHeight() + 1;
  3028. var ColumnsWidth = 0;
  3029. var ColumnsNumber = 0;
  3030. $("#" + TableID + " tr:last td:lt(" + FixColumnNumber + ")").each(function () {
  3031. ColumnsWidth += $(this).outerWidth(true);
  3032. ColumnsNumber++;
  3033. });
  3034. ColumnsWidth += 1;
  3035. //获取原表宽度
  3036. $tableData.append($table);
  3037. $tableData.css({ "overflow": "scroll", "height": par_height - HeadHeight, "position": "relative", "z-index": "35", "margin-top": HeadHeight });
  3038. var tableWidth = $(table).width();
  3039. var par_height = $tableLayout.outerHeight();
  3040. var par_width = $tableLayout.width();
  3041. $tableData.height(par_height - HeadHeight);
  3042. //左上角
  3043. setTimeout(function () {
  3044. var $tableFixClone = $table.clone(true);
  3045. $tableFixClone.attr("id", TableID + "_tableFixClone").css("margin", "0").width(tableWidth);
  3046. $tableFix.css({ "height": HeadHeight, "width": ColumnsWidth, "overflow": "hidden", "position": "absolute", "top": 0, "left": 0, "z-index": "50", "background-color": "#fff" }).append($tableFixClone);
  3047. })
  3048. //表头
  3049. setTimeout(function () {
  3050. var $tableHeadClone = $table.clone(true);
  3051. $tableHeadClone.attr("id", TableID + "_tableHeadClone").css("margin", "0");
  3052. $tableHead.append($tableHeadClone);
  3053. $tableHeadClone.width(tableWidth);
  3054. $tableHead.css({ "height": HeadHeight, "overflow": "hidden", "width": par_width - 17, "position": "absolute", "top": 0, "left": 0, "z-index": "45", "background-color": "#fff" });
  3055. })
  3056. //列
  3057. setTimeout(function () {
  3058. var $tableColumnClone = $table.clone(true);
  3059. $tableColumnClone.attr("id", TableID + "_tableColumnClone").css("margin", "0");
  3060. $tableColumn.append($tableColumnClone);
  3061. $tableColumnClone.width(tableWidth);
  3062. $columnBox.css({ "width": ColumnsWidth, "overflow": "hidden", "height": par_height - 17, "position": "absolute", "top": 0, "left": 0, "z-index": "40", "background-color": "#fff" });
  3063. $tableColumn.css({ "width": ColumnsWidth + scrollWidth, "overflow-x": "hidden", "overflow-y": "scroll", "height": par_height - 17, "position": "absolute", "top": 0, "left": 0, "z-index": "40" });
  3064. var scrollFlag = false;
  3065. $tableData.on('scroll', function () {
  3066. if (scrollFlag) {
  3067. return;
  3068. }
  3069. $tableHead.scrollLeft($tableData.scrollLeft());
  3070. $tableColumn.scrollTop($tableData.scrollTop());
  3071. }).on('mouseover', function () {
  3072. scrollFlag = false;
  3073. })
  3074. $tableColumn.on('scroll', function () {
  3075. if (!scrollFlag) {
  3076. return;
  3077. }
  3078. $tableData.scrollTop($tableColumn.scrollTop());
  3079. }).on('mouseover', function () {
  3080. scrollFlag = true;
  3081. })
  3082. });
  3083. $("#scrollMask").css({ 'position': "absolute", "top": 0, "right": 0, "width": scrollWidth, "height": HeadHeight, "background": "#E1E6EB", border: "solid #E1E6EB", "border-width": "1px 1px 1px 0" })
  3084. $table.css("margin-top", -HeadHeight);
  3085. var flag = false;
  3086. $(window).resize(function () {
  3087. if (flag) {
  3088. return;
  3089. }
  3090. setTimeout(function () {
  3091. par_height = $tableLayout.height();
  3092. par_width = $tableLayout.width();
  3093. // $columnBox.css({"width":ColumnsWidth,"height": par_height - 17});
  3094. // $tableColumn.css({"width": ColumnsWidth+scrollWidth,"height": par_height - 17});
  3095. // $tableData.css({"width":par_width-17,"height": par_height-HeadHeight});
  3096. $tableHead.width(par_width - 17);
  3097. $columnBox.height(par_height - 17);
  3098. $tableColumn.height(par_height - 17);
  3099. $tableData.height(par_height - HeadHeight);
  3100. flag = false;
  3101. }, 100);
  3102. flag = true;
  3103. });
  3104. // return $("#" + TableID + "_tableLayout").html();
  3105. }
  3106. ///*************************************************************
  3107. /* 为保证angularjs的显示效果,判断ie浏览器版本是否过低*/
  3108. sp.getMyBrowser = function () {
  3109. var userAgent = window.navigator.userAgent; //取得浏览器的userAgent字符串
  3110. var isOpera = userAgent.indexOf("Opera") > -1; //判断是否Opera浏览器
  3111. var isIE = userAgent.indexOf("compatible") > -1 && userAgent.indexOf("MSIE") > -1 && !isOpera; //判断是否IE浏览器
  3112. if (!isIE) {
  3113. isIE = userAgent.indexOf("Windows NT") > -1 && userAgent.indexOf("BOIE") > -1 && !isOpera; //判断是否IE浏览器
  3114. }
  3115. var is360 = isIE && ((window.navigator.userProfile + '') == 'null');//判断是否360浏览器
  3116. var isFF = userAgent.indexOf("Firefox") > -1; //判断是否Firefox浏览器
  3117. var isChrome = userAgent.indexOf("Chrome") > -1; //判断是否Safari浏览器
  3118. var isSafari = userAgent.indexOf("Safari") > -1 && !isChrome; //判断是否Safari浏览器
  3119. if (isIE && !is360) {
  3120. var IE5 = IE55 = IE6 = IE7 = IE8 = false;
  3121. var reIE = new RegExp("MSIE (\\d+\\.\\d+);");
  3122. reIE.test(userAgent);
  3123. var fIEVersion = parseFloat(RegExp["$1"]);
  3124. IE55 = fIEVersion == 5.5;
  3125. IE6 = fIEVersion == 6.0;
  3126. IE7 = fIEVersion == 7.0;
  3127. IE8 = fIEVersion == 8.0;
  3128. if (IE55) {
  3129. return "IE55|false";
  3130. } else if (IE6) {
  3131. return "IE6|false";
  3132. } else if (IE7) {
  3133. return "IE7|false";
  3134. } else if (IE8) {
  3135. return "IE8|false";
  3136. } else {
  3137. return "IE9|true";
  3138. }
  3139. } //isIE end
  3140. if (is360) {
  3141. return "360|alert";
  3142. }
  3143. if (isFF) {
  3144. return "FF|true";
  3145. }
  3146. if (isChrome) {
  3147. return "Chrome|true";
  3148. }
  3149. if (isOpera) {
  3150. return "Opera|true";
  3151. }
  3152. if (isSafari) {
  3153. return "Safari|true";
  3154. }
  3155. }
  3156. /**调用监测浏览器版本方法,并进行判断与提示**/
  3157. sp.checkIEVersion = function () {
  3158. var mb = sp.getMyBrowser(); ///获取浏览器判断返回的值
  3159. if (mb == undefined || mb == null || mb == "") {
  3160. sp.dialog("您正在使用兼容模式,网站的样式可能会发生变化,请您更换Google Chrome浏览器或IE9以上版本浏览器进行浏览。");
  3161. } else {
  3162. var mbArray = mb.split("|");
  3163. if (mbArray[1] == "alert") {
  3164. sp.dialog("您正在使用360浏览器浏览,网站的样式可能会发生变化,请您更换Google Chrome浏览器或IE9以上版本浏览器进行浏览。");
  3165. } else if (mbArray[1] == "false") {
  3166. sp.dialog("您正在使用低版本IE浏览器浏览,网站的样式可能会发生变化,请您更换Google Chrome浏览器或IE9以上版本浏览器进行浏览。");
  3167. } else {
  3168. }
  3169. }
  3170. }
  3171. sp.getExplorerInfo = function () {
  3172. var explorer = window.navigator.userAgent.toLowerCase();
  3173. //ie
  3174. if (explorer.indexOf("msie") >= 0) {
  3175. var ver = explorer.match(/msie ([\d.]+)/)[1];
  3176. return { type: "IE", version: ver };
  3177. }
  3178. ////ie11有点特殊,ie11执行这句话
  3179. if (explorer.indexOf("rv:11") > -1) {
  3180. var ver = explorer.match(/rv:([\d.]+)/)[1];
  3181. return { type: "IE", version: ver };
  3182. }
  3183. //firefox
  3184. else if (explorer.indexOf("firefox") >= 0) {
  3185. var ver = explorer.match(/firefox\/([\d.]+)/)[1];
  3186. return { type: "Firefox", version: ver };
  3187. }
  3188. //Chrome
  3189. else if (explorer.indexOf("chrome") >= 0) {
  3190. var ver = explorer.match(/chrome\/([\d.]+)/)[1];
  3191. return { type: "Chrome", version: ver };
  3192. }
  3193. //Opera
  3194. else if (explorer.indexOf("opera") >= 0) {
  3195. var ver = explorer.match(/opera.([\d.]+)/)[1];
  3196. return { type: "Opera", version: ver };
  3197. }
  3198. //Safari
  3199. else if (explorer.indexOf("Safari") >= 0) {
  3200. var ver = explorer.match(/version\/([\d.]+)/)[1];
  3201. return { type: "Safari", version: ver };
  3202. }
  3203. }
  3204. /////2018.7.12禁用ctrl+s快捷键
  3205. sp.disablesaving = function () {
  3206. document.onkeydown = function (e) {
  3207. e = window.event || e;
  3208. var key = e.keyCode;
  3209. if (key == 83 && e.ctrlKey == true) {
  3210. return false;
  3211. }
  3212. };
  3213. };
  3214. /////2018.9.27
  3215. ///***给字符串添加属性************************************************************
  3216. //2016-11-14 截取字符串两侧的空格 JavaScript
  3217. sp.trim = function (str) {
  3218. ///<summary>去掉字符串所有空格</summary>
  3219. return str.replace(/\s+/g, "");
  3220. };
  3221. sp.trimleft = function (str) {
  3222. ///<summary>去掉左边的空格</summary>
  3223. return str.replace(/^\s*/, "");
  3224. };
  3225. sp.trimright = function (str) {
  3226. ///<summary>去除右边的空格</summary>
  3227. return str.replace(/\s*$/, "");
  3228. };
  3229. sp.trimin = function (str) {
  3230. ///<summary>去除内的空格</summary>
  3231. return str.replace(/\s/g, "");
  3232. };
  3233. ///截取字符串
  3234. sp.cutfirst = function (str, num) {
  3235. /// <summary>去掉第一个字符 </summary>
  3236. if (sp.isval(num)) {
  3237. return str.substr(num);
  3238. } else { return str.substr(1); }
  3239. }
  3240. sp.cutlast = function (str, num) {
  3241. /// <summary>去掉最后一个字符 </summary>
  3242. if (sp.isval(num)) {
  3243. if (num < 1) {
  3244. sp.dialog("截取尾部字符的数量须大于0");
  3245. } else {
  3246. return str.substr(0, str.length - num);
  3247. }
  3248. } else {
  3249. return str.substr(0, str.length - 1);
  3250. }
  3251. };
  3252. ///给数组添加属性
  3253. //strMin();获取数组中最小值
  3254. sp.arraymin = function (strArr) {
  3255. /// <summary> 获取数组中最小值 </summary>
  3256. var strMin = strArr[0];
  3257. var len = strArr.length;
  3258. for (var i = 1; i < len; i++) {
  3259. if (strArr[i] < strMin) {
  3260. strMin = strArr[i];
  3261. }
  3262. }
  3263. return strMin;
  3264. }
  3265. //strMax();获取数组中最大值
  3266. sp.arraymax = function (strArr) {
  3267. /// <summary> 获取数组中最大值 </summary>
  3268. var strMax = strArr[0];
  3269. var len = strArr.length;
  3270. for (var i = 1; i < len; i++) {
  3271. if (strArr[i] > strMax) {
  3272. strMax = strArr[i];
  3273. }
  3274. }
  3275. return strMax;
  3276. }
  3277. //arrayAscend将数字升序排序();
  3278. sp.arrayAscend = function (strArr) {
  3279. /// <summary>冒泡排序:将数字从小到大排序升序</summary>
  3280. //var arr = new Array;
  3281. var arr = new Array;
  3282. arr = strArr;
  3283. var length = arr.length;
  3284. for (var i = 0; i < length; i++) {
  3285. for (var j = i; j < length; j++) {
  3286. if (arr[i] > arr[j]) {
  3287. Temp = arr[i];
  3288. arr[i] = arr[j];
  3289. arr[j] = Temp;
  3290. }
  3291. }
  3292. }
  3293. return arr;
  3294. };
  3295. //arrayDescend将数字降序排序();
  3296. sp.arrayDescend = function (strArr) {
  3297. /// <summary>冒泡排序:降序排序</summary>
  3298. var arr = new Array;
  3299. arr = strArr;
  3300. var Temp = 0;
  3301. var length = arr.length;
  3302. for (var i = 0; i < length; i++) {
  3303. for (var j = i + 1; j < length; j++) {
  3304. if (arr[i] < arr[j]) {
  3305. Temp = arr[i];
  3306. arr[i] = arr[j];
  3307. arr[j] = Temp;
  3308. }
  3309. }
  3310. }
  3311. return arr;
  3312. };
  3313. ///设置左右布局的tab选项卡,左右两边高度一致201809
  3314. sp.settableft = function () {
  3315. if ($("body").find(".sp-tab-left").length > 0) {
  3316. $(".sp-tab-left").each(function () {
  3317. if ($(".sp-tab-menu", this).height() > $(".sp-tab-box", this).height()) {
  3318. $(".sp-tab-box", this).css("height", $(".sp-tab-menu", this).outerHeight());
  3319. } else {
  3320. $(".sp-tab-menu", this).css("height", $(".sp-tab-box", this).outerHeight());
  3321. }
  3322. });
  3323. };
  3324. };
  3325. sp.settableft();
  3326. sp.settabright = function () {
  3327. if ($("body").find(".sp-tab-right").length > 0) {
  3328. $(".sp-tab-right").each(function () {
  3329. if ($(".sp-tab-menu", this).height() > $(".sp-tab-box", this).height()) {
  3330. $(".sp-tab-box", this).css("height", $(".sp-tab-menu", this).outerHeight());
  3331. } else {
  3332. $(".sp-tab-menu", this).css("height", $(".sp-tab-box", this).outerHeight());
  3333. }
  3334. });
  3335. };
  3336. };
  3337. sp.settabright();
  3338. //201810
  3339. /////判断这个变量不为空、null、undefined,即判断这个变量是有值存在
  3340. sp.isval = function (vars) {
  3341. if (typeof (vars) != undefined && vars != null && vars != "") {
  3342. return true;
  3343. }
  3344. };
  3345. ///201810
  3346. ////利用checkbox的多选情况
  3347. sp.selectmore = function () {
  3348. if ($("body").find(".sp-selectmore").length > 0) {
  3349. $(".sp-selectmore").each(function () {
  3350. $(".sp-selectmore-bottom span", this).each(function () {
  3351. $(this).on("click", function () {
  3352. var getmoreup = $(this).parents(".sp-selectmore").children(".sp-selectmore-up");
  3353. if ($(this).hasClass("sp-selectmore-active")) {
  3354. $(this).removeClass("sp-selectmore-active");
  3355. getmoreup.find("span[data-value='" + $(this).attr("data-value") + "']").remove();
  3356. } else {
  3357. $(this).addClass("sp-selectmore-active");
  3358. getmoreup.append("<span data-value='" + $(this).attr("data-value") + "'><label onclick='sp.selectmoreclose(this)'>×</label>" + $(this).text() + "</span>");
  3359. }
  3360. });
  3361. });
  3362. //判断是否有赋值
  3363. if ($(".sp-selectmore-up", this).find("span").length > 0) {
  3364. $(this).children(".sp-selectmore-up").find("span").each(function () {
  3365. var getvalue = $(this).attr("data-value");
  3366. $(this).parents(".sp-selectmore").children(".sp-selectmore-bottom").find("span[data-value='" + getvalue + "']").addClass("sp-selectmore-active");
  3367. });
  3368. };
  3369. /////点击上下两个div层控制显示隐藏切换
  3370. $(this).find(".sp-selectmore-up").on("click", function (e) {
  3371. if ($(this).hasClass("sp-selectmore-up-hasclick")) {
  3372. $(this).removeClass("sp-selectmore-up-hasclick");
  3373. $(this).parents(".sp-selectmore").children(".sp-selectmore-bottom").hide();
  3374. sp.stopPropagation(e);
  3375. } else {
  3376. $(this).addClass("sp-selectmore-up-hasclick");
  3377. $(this).parents(".sp-selectmore").children(".sp-selectmore-bottom").show();
  3378. sp.stopPropagation(e);
  3379. }
  3380. });
  3381. $(document).bind('click', function () {
  3382. $(".sp-selectmore-up", this).removeClass("sp-selectmore-up-hasclick");
  3383. $(".sp-selectmore-bottom",this).hide()
  3384. });
  3385. $(this).children(".sp-selectmore-bottom").click(function (e) {
  3386. sp.stopPropagation(e);
  3387. });
  3388. });
  3389. };
  3390. };
  3391. ////更多插件的上部叉号关闭按钮
  3392. sp.selectmoreclose = function (obj,e) {
  3393. var getvalue = $(obj).parent().attr("data-value");
  3394. var bottom = $(obj).parents(".sp-selectmore").children(".sp-selectmore-bottom");
  3395. bottom.find("span[data-value='" + getvalue + "']").removeClass("sp-selectmore-active");
  3396. $(obj).parent().remove();
  3397. sp.stopPropagation(e);
  3398. };
  3399. ////2019-5-7
  3400. // 字符串转base64
  3401. sp.strToBase64 = function (str){
  3402. return btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, function(match, p1) {
  3403. return String.fromCharCode('0x' + p1);
  3404. }));
  3405. };
  3406. // base64转字符串
  3407. sp.base64ToStr = function (base64){
  3408. return decodeURIComponent(atob(base64).split('').map(function(c) {
  3409. return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
  3410. }).join(''));
  3411. };
  3412. //2020-1-2 格式化文件大小显示
  3413. sp.filesize = function (limit) {
  3414. var size = "";
  3415. if (limit < 0.1 * 1024) { //如果小于0.1KB转化成B
  3416. size = limit.toFixed(2) + "B";
  3417. } else if (limit < 0.1 * 1024 * 1024) {//如果小于0.1MB转化成KB
  3418. size = (limit / 1024).toFixed(2) + "KB";
  3419. } else if (limit < 0.1 * 1024 * 1024 * 1024) { //如果小于0.1GB转化成MB
  3420. size = (limit / (1024 * 1024)).toFixed(2) + "MB";
  3421. } else { //其他转化成GB
  3422. size = (limit / (1024 * 1024 * 1024)).toFixed(2) + "GB";
  3423. }
  3424. var sizestr = size + "";
  3425. var len = sizestr.indexOf("\.");
  3426. var dec = sizestr.substr(len + 1, 2);
  3427. if (dec == "00") {//当小数点后为00时 去掉小数部分
  3428. return sizestr.substring(0, len) + sizestr.substr(len + 3, 2);
  3429. }
  3430. return sizestr;
  3431. }
  3432. ///2020-1-7
  3433. //自定义变形函数
  3434. sp.dateFtt = function(fmt, date) {
  3435. var o = {
  3436. "M+": date.getMonth() + 1, //月份
  3437. "d+": date.getDate(), //日
  3438. "h+": date.getHours(), //小时
  3439. "m+": date.getMinutes(), //分
  3440. "s+": date.getSeconds(), //秒
  3441. "q+": Math.floor((date.getMonth() + 3) / 3), //季度
  3442. "S": date.getMilliseconds() //毫秒
  3443. };
  3444. if (/(y+)/.test(fmt))
  3445. fmt = fmt.replace(RegExp.$1, (date.getFullYear() + "").substr(4 - RegExp.$1.length));
  3446. for (var k in o)
  3447. if (new RegExp("(" + k + ")").test(fmt))
  3448. fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
  3449. return fmt;
  3450. }
  3451. //判断所选日期是第几周 传入时间对象 //调用方式getWeekNumber(new Date())
  3452. sp.getWeekNumber = function (obj) {
  3453. var year = obj.getFullYear(); //年
  3454. var month = obj.getMonth(); //月
  3455. var days = obj.getDate(); //日
  3456. var nowTime = obj.getTime(); //毫秒
  3457. var day = obj.getDay(); //星期几
  3458. //那一天是那一年中的第多少天
  3459. for (var i = 0; i < month; i++) {
  3460. days += sp.getMonthDays(year, i);
  3461. }
  3462. //那一年第一天是星期几
  3463. var yearFirstDay = new Date(year, 0, 1).getDay() || 7;
  3464. var week = null;
  3465. if (yearFirstDay == 1) {
  3466. week = Math.ceil(days / 7);
  3467. } else {
  3468. days -= (7 - yearFirstDay + 1);
  3469. week = Math.ceil(days / 7) + 1;
  3470. }
  3471. var oneDayLong = 24 * 60 * 60 * 1000;
  3472. if (day == 0) {
  3473. var MondayTime = nowTime - 6 * oneDayLong;
  3474. var SundayTime = nowTime;
  3475. } else {
  3476. var MondayTime = nowTime - (day - 1) * oneDayLong;
  3477. var SundayTime = nowTime + (7 - day) * oneDayLong;
  3478. }
  3479. var dateString = "";
  3480. for (var i = 0; i < 7; i++) {
  3481. var time = MondayTime + (oneDayLong) * i;
  3482. dateString += sp.dateFtt("MM.dd", new Date(time)) + ","
  3483. }
  3484. var monday = sp.dateFtt("yyyy-MM-dd", new Date(MondayTime));
  3485. var sunday = sp.dateFtt("yyyy-MM-dd", new Date(SundayTime));
  3486. return {
  3487. begin: monday,
  3488. end: sunday,
  3489. week: week,
  3490. dateString: dateString.substring(0, dateString.length - 1),
  3491. weekday: ["周日", "周一", "周二", "周三", "周四", "周五", "周六"][day]
  3492. }
  3493. }
  3494. ///判断是否为闰年
  3495. sp.isLeapYear = function (year) {
  3496. return (year % 400 == 0) || (year % 4 == 0 && year % 100 != 0);
  3497. }
  3498. //判断每个月的天数
  3499. sp.getMonthDays = function (year, month) {
  3500. return [31, null, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month] || (sp.isLeapYear(year) ? 29 : 28);
  3501. }
  3502. ///判断是否为json字符串
  3503. sp.isJSON = function (str) {
  3504. if (typeof str == 'string') {
  3505. try {
  3506. var obj = JSON.parse(str);
  3507. if (typeof obj == 'object' && obj) {
  3508. return true;
  3509. } else {
  3510. return false;
  3511. }
  3512. } catch (e) {
  3513. return false;
  3514. }
  3515. }
  3516. }
  3517. ///【2020-2-26】js获取指定日期的前一天/后一天
  3518. // date 代表指定的日期,格式:2018-09-27
  3519. // day 传-1表始前一天,传1表始后一天
  3520. // JS获取指定日期的前一天,后一天
  3521. sp.getNextDate = function (date, day) {
  3522. var dd = new Date(date);
  3523. dd.setDate(dd.getDate() + day);
  3524. var y = dd.getFullYear();
  3525. var m = dd.getMonth() + 1 < 10 ? "0" + (dd.getMonth() + 1) : dd.getMonth() + 1;
  3526. var d = dd.getDate() < 10 ? "0" + dd.getDate() : dd.getDate();
  3527. return y + "-" + m + "-" + d;
  3528. };
  3529. ////getNextDate("2018-09-27", -1);
  3530. //获取本机ip地址
  3531. sp.myIP = function () {
  3532. var ip = "";
  3533. $.ajax({
  3534. url: apiurljs.login + "g2app/dataabase/getClientIP",
  3535. type: 'post',
  3536. async: false,
  3537. contentType: "application/json",
  3538. beforeSend: function (request) {
  3539. request.setRequestHeader("Authorization", "Bearer " + localStorage.getItem("GlWorkPlatform-AccessToken"));
  3540. },
  3541. dataType: "json",
  3542. success: function (obj) {
  3543. var res = strToJson(s4.decryptData_CBC(obj.data));
  3544. ip = res.data;
  3545. }
  3546. })
  3547. return ip
  3548. }
  3549. //获取本机操作系统
  3550. sp.detectOS = function () {
  3551. var sUserAgent = navigator.userAgent;
  3552. var isWin = (navigator.platform == "Win32") || (navigator.platform == "Windows");
  3553. var isMac = (navigator.platform == "Mac68K") || (navigator.platform == "MacPPC") || (navigator.platform == "Macintosh") || (navigator.platform == "MacIntel");
  3554. if (isMac) return "Mac";
  3555. var isUnix = (navigator.platform == "X11") && !isWin && !isMac;
  3556. if (isUnix) return "Unix";
  3557. var isLinux = (String(navigator.platform).indexOf("Linux") > -1);
  3558. var bIsAndroid = sUserAgent.toLowerCase().match(/android/i) == "android";
  3559. if (isLinux) {
  3560. if(bIsAndroid) return "Android";
  3561. else return "Linux";
  3562. }
  3563. if (isWin) {
  3564. if (sUserAgent.indexOf("Windows NT 5") != -1) {
  3565. return "Windows XP";
  3566. } else if (sUserAgent.indexOf("Windows NT 7") != -1) {
  3567. return "Windows 7";
  3568. } else if (sUserAgent.indexOf("Windows NT 10") != -1) {
  3569. return "Windows 10";
  3570. }
  3571. }
  3572. return "other";
  3573. }
  3574. //获取本机浏览器类型
  3575. sp.browser = function () {
  3576. var userAgent = navigator.userAgent;
  3577. if (navigator.userAgent.indexOf('Firefox') > -1)
  3578. return "火狐浏览器"
  3579. if (navigator.userAgent.indexOf('Chrome') > -1 )
  3580. return "谷歌浏览器"
  3581. if (navigator.userAgent.indexOf('Opera') > -1)
  3582. return "Opera"
  3583. if (userAgent.indexOf("compatible") > -1 && userAgent.indexOf("MSIE") > -1 && !isOpera)
  3584. return "IE浏览器"
  3585. }
  3586. //获取当前时间(带毫秒),格式:2021-11-23 10:47:15.165
  3587. sp.getLocalDate1 = function () {
  3588. var objDate = new Date();
  3589. var str, date, colorhead, colorfoot;
  3590. var yy = objDate.getFullYear();
  3591. var MM = objDate.getMonth() + 1;
  3592. if (MM < 10) MM = '0' + MM;
  3593. var dd = objDate.getDate();
  3594. if (dd < 10) dd = '0' + dd;
  3595. var hh = objDate.getHours();
  3596. if (hh < 10) hh = '0' + hh;
  3597. var mm = objDate.getMinutes();
  3598. if (mm < 10) mm = '0' + mm;
  3599. var ss = objDate.getSeconds();
  3600. if (ss < 10) ss = '0' + ss;
  3601. date = yy + "-" + MM + "-" + dd + " " + hh + ":" + mm + ":" + ss;
  3602. var mins = objDate.getTime() - new Date(date).getTime();
  3603. mins < 10 ? '00' + mins : mins < 100 ? '0' + mins : mins;
  3604. str = yy + "-" + MM + "-" + dd + " " + hh + ":" + mm + ":" + ss + "." + mins;
  3605. return str;
  3606. };
  3607. //提醒登录超时
  3608. sp.addDLTX = function () {
  3609. if ($('body').find(".DLTX").length < 1) {
  3610. $('body').prepend("<div class=\"DLTX\"></div>");
  3611. }
  3612. }
  3613. sp.openDLTX = function (Name) {
  3614. $('.DLTX').fadeIn(200);
  3615. sp.setCenter(Name);
  3616. }
  3617. //毫秒转日期格式
  3618. sp.minsToDate = function (fmt, str) {
  3619. var date = new Date(str);
  3620. var o = {
  3621. "M+": date.getMonth() + 1, //月份
  3622. "d+": date.getDate(), //日
  3623. "h+": date.getHours(), //小时
  3624. "m+": date.getMinutes(), //分
  3625. "s+": date.getSeconds(), //秒
  3626. "q+": Math.floor((date.getMonth() + 3) / 3), //季度
  3627. "S": date.getMilliseconds() //毫秒
  3628. };
  3629. if (/(y+)/.test(fmt))
  3630. fmt = fmt.replace(RegExp.$1, (date.getFullYear() + "").substr(4 - RegExp.$1.length));
  3631. for (var k in o)
  3632. if (new RegExp("(" + k + ")").test(fmt))
  3633. fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
  3634. return fmt;
  3635. }
  3636. //拖动
  3637. sp.drag = function (id) {
  3638. var box = document.querySelector(id);
  3639. var title = document.querySelector(id).children[0];
  3640. title.addEventListener("mousedown", function (event) {
  3641. var x = event.pageX - box.offsetLeft;
  3642. var y = event.pageY - box.offsetTop;
  3643. document.addEventListener("mousemove", boxMove)
  3644. function boxMove(event) {
  3645. box.style.left = (event.pageX - x) + "px"
  3646. box.style.top = (event.pageY - y) + "px"
  3647. }
  3648. document.addEventListener("mouseup", function () {
  3649. document.removeEventListener("mousemove", boxMove)
  3650. })
  3651. })
  3652. }