修改页面,完成单页模式新增首页返回上一页按钮

This commit is contained in:
2026-08-31 14:48:32 +08:00
parent aaed0584b1
commit 15b301b358
363 changed files with 10895 additions and 213 deletions
+1
View File
@@ -0,0 +1 @@
layui.define("layer",function(x){var n=layui.$,y=layui.layer,T=function(e){this.c={elem:"",data:"",url:"",placeholder:"请选择:",disabledTips:"",success:function(){}},this.c=n.extend(this.c,e),this.init()};T.prototype={init:function(){this.data=this.c.url?this.getData(this.c.url):this.c.data,this.render()},getData:function(e){var t;return n.ajax({url:e,type:"get",dataType:"json",async:!1,success:function(a){t=a.data||y.msg("数据接口错误,请正确配置")},error:function(){y.msg("数据接口错误,请正确配置"),t=""}}),t},getChild:function(e,t){for(var a=[],i=0;i<e.length;i++)e[i].pid==t&&a.push(e[i]);return a},createChild:function(e){for(var t=this,a="<ul>",i=0;i<e.length;i++){var r=t.getChild(t.data,e[i].id);r=r.length!=0?"child-row":"";var l=e[i].off?"layui-disabled":"";a+='<li class="'+r+" "+l+'" data-id="'+e[i].id+'">'+e[i].name+"</li>"}return a+="</ul>",a},setValue:function(e){var t=this,a=t.data,i=n(t.c.elem),r=i.parent();r.find(".pop").empty(),r.find(".show").html(t.c.placeholder),i.val("");for(var l=[],s=t.getChild(a,0),d=0;d<e.length;d++){for(var c=!1,o=0;o<s.length;o++)if(s[o].name===e[d]){l.push(s[o]),s=t.getChild(a,s[o].id),c=!0;break}if(!c)break}if(l.length>0){r.find(".pop").empty();for(var h=0;h<l.length;h++){var v=t.getChild(a,h===0?0:l[h-1].id),C=t.createChild(v);r.find(".pop").append(C);var g=r.find(".pop ul").eq(h);g.find('li[data-id="'+l[h].id+'"]').addClass("active")}var f=l[l.length-1],m=t.getChild(a,f.id);if(m.length>0){var u=t.createChild(m);r.find(".pop").append(u)}var w=l.map(function(p){return p.name}).join("<i>/</i>"),q=l.map(function(p){return p.name}).join("/");if(r.find(".show").html(w),i.val(q),typeof t.c.success=="function"){var b=l.map(function(p){return p.id}),Y=l.map(function(p){return p.name});t.c.success({data:Y,ids:b})}return l.map(function(p){return p.id})}return[]},showPopup:function(e,t){var a=this,i=a.getChild(e,t);if(i.length!=0){var r=a.createChild(i);n(a.c.elem).parent().find(".pop").append(r)}},scroll:function(){for(var e=this,t=e.c,a=t.elem,i=n(a).parent().find(".pop ul"),r=0;r<i.length;r++){var l=i.eq(r).children("li.active");if(l[0]){var s=l.position().top,d=i.eq(r).height(),c=l.height();s>d&&i.eq(r).scrollTop(s+i.eq(r).scrollTop()-d+c+3),s<0&&i.eq(r).scrollTop(s+i.eq(r).scrollTop()-5)}}},render:function(){var e=this,t=e.c,a=t.elem,i='<div class="selectY-box"></div>',r='<span class="show"><span class="cl-exp">'+t.placeholder+"</span></span>",l='<div class="pop"></div>';if(n(a).wrap(i),n(a).after(r+l),e.showPopup(e.data,0),n(a).val()!=""){var s=n(a).val().split("/"),d=s.join("<i>/</i>");n(a).parent().find(".show").html(d);for(var c=e.setValue(s),o=0;o<c.length;o++){e.showPopup(e.data,c[o]);var h=n(a).parent().find(".pop ul");h.eq(o).find("li[data-id="+c[o]+"]").addClass("active")}}n(a).parent().find(".pop").on("click","ul li",function(v){if(n(this).hasClass("layui-disabled"))return y.msg(t.disabledTips),!1;n(this).addClass("active").siblings().removeClass("active"),n(this).parent().nextAll("ul").remove();var C=n(this).data("id");if(e.showPopup(e.data,C),!n(this).hasClass("child-row")){n(a).parent().find(".pop").hide();for(var g=n(a).parent().find(".pop li.active"),f=[],m=[],u=0;u<g.length;u++)f.push(g.eq(u).html()),m.push(g.eq(u).data("id"));var w=f.join("/"),q=f.join("<i>/</i>");if(n(a).val(w),n(a).parent().find(".show").html(q),typeof t.success=="function"){var b={data:f,ids:m};t.success(b)}}layui.stope(v)}),n(a).parent().find(".show").on("click",function(v){n(a).parent().find(".pop").show(),e.scroll(),layui.stope(v)}),n(document).on("click",function(){n(a).parent().find(".pop").hide()})}},x("selectY2",function(e){return new T(e)})}).link(layui.cache.base+"selectY/selectY.css?v="+new Date().getTime());