service.java


public List<Menu> listAllMenuPage(PageData pd) throws Exception{
List<Menu> NewList = new ArrayList<Menu>();
Integer page = Integer.parseInt((String) pd.get("page"));
Integer rows = Integer.parseInt((String) pd.get("limit"));
if(StringUtils.isBlank(pd.getString("page"))){
page = 1;
}
if(StringUtils.isBlank(pd.getString("limit"))){
rows = 10;
}

Integer nowpage = (page - 1) * rows;

PageData pdResult = new PageData();
pdResult.put("erows", rows);
pdResult.put("ebeginIndex",nowpage);
List<Menu> Plist= (List<Menu>) dao.findForList("com.ctvit.mapper.MenuMapper.findMenuPagelist", pdResult);
for(int i=0;i<Plist.size();i++){
Menu childmenu=Plist.get(i);
int childnenuid=childmenu.getMenuId();
PageData pad=new PageData();
pad.put("parentId", childnenuid);
List<Menu> Sublist= (List<Menu>) dao.findForList("com.ctvit.mapper.MenuMapper.findMenuchildByParentid", pad);
childmenu.setSubMenu(Sublist);
NewList.add(childmenu);
}
return NewList;
}

Html
<script>
layui.use(['form'], function(){
form = layui.form;

});

layui.use(['laypage'], function () {
var laypage = layui.laypage
, layer = layui.layer;
var epage = 1;
var epagesize=3;
$.ajax({
url: '[[${springMacroRequestContext.contextPath}]]/MenuManage/listmenu.do',
type: 'post',
dataType: 'json',
async: false,
data: {page: epage, limit: epagesize},
success: function (rs) {
setHtml(rs);
pages(rs.total);
}
})

function setHtml(rs){
console.log(rs);
var row = rs.rows;
var total = rs.total;
console.log(rs);
var html = "";
for (var i = 0; i < row.length; i++) {
html += ' <tr cate-id=' + row[i].menuId + ' fid=0 >' +
'<td><input type="checkbox" name="" lay-skin="primary"> </td><td>' + row[i].menuId + '</td><td><i class="layui-icon x-show" status="true"></i>' + row[i].menuName +
'</td> <td>' + row[i].menuUrl +
'</td><td>' + row[i].sort + '</td>'
+ ' <td class="td-manage"><button class="layui-btn layui-btn layui-btn-xs" onclick="xadmin.open(\'编辑\',\'menu-edit.html?menuId=' + row[i].menuId + '\')" ><i class="layui-icon"></i>编辑</button>'
+ ' <button class="layui-btn layui-btn-warm layui-btn-xs" onclick="xadmin.open(\'添加子菜单\',\'/api/MenuManage/menu-edit.html\')" ><i class="layui-icon"></i>添加子栏目</button>'
+ '<button class="layui-btn-danger layui-btn layui-btn-xs" onclick="delmenu(this,' + row[i].menuId + ')" href="javascript:;" ><i class="layui-icon"></i>删除</button></td></tr>'
var submenu = row[i].subMenu;
if (submenu.length > 0) {
for (var j = 0; j < submenu.length; j++) {
html += '<tr cate-id=' + submenu[j].menuId + ' fid=' + submenu[j].parentId +
' ><td><input type="checkbox" name="" lay-skin="primary"></td><td>' + submenu[j].menuId +
'</td> <td> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;├' + submenu[j].menuName +
'</td> <td>' + submenu[j].menuUrl +
'</td><td>' + submenu[j].sort + '</td><td class="td-manage">'
+ ' <button class="layui-btn layui-btn layui-btn-xs" onclick="xadmin.open(\'编辑\',\'menu-edit.html?menuId=' + submenu[j].menuId + '\')" ><i class="layui-icon"></i>编辑</button>'
+ ' <button class="layui-btn-danger layui-btn layui-btn-xs" onclick="delmenu(this,' + submenu[j].menuId + ')" href="javascript:;" ><i class="layui-icon"></i>删除</button>'
+ ' </td> </tr>'
}
}
}
$(".x-cate").html(html);
shou()

}
//--------------------------------分页组件渲染
function pages(count) {
laypage.render({
elem: 'demo7'
, count: count
, theme: '#009688'
//, layout: ['prev', 'page', 'next']
,layout: ['count', 'prev', 'page', 'next', 'limit', 'refresh', 'skip']
, limit:epagesize
, limits:[5,10,15]
, jump: function (obj, first) {
if (!first) {
$.post('[[${springMacroRequestContext.contextPath}]]/MenuManage/listmenu.do'
, { page: obj.curr, limit: obj.limit}
, function (result) {
//res = result.data;
setHtml(result);
});
}
}
})
}
} //yuanlaiend
)
//列表结束处理



// 分类展开收起的分类的逻辑
function shou() {
$("tbody.x-cate tr[fid!='0']").hide();
// 栏目多级显示效果
$('.x-show').click(function () {
if ($(this).attr('status') == 'true') {

$(this).html('');
$(this).attr('status', 'false');
cateId = $(this).parents('tr').attr('cate-id');
$("tbody tr[fid=" + cateId + "]").show();
} else {
cateIds = [];
$(this).html('');
$(this).attr('status', 'true');
cateId = $(this).parents('tr').attr('cate-id');
getCateId(cateId);
for (var i in cateIds) {
$("tbody tr[cate-id=" + cateIds[i] + "]").hide().find('.x-show').html('').attr('status', 'true');
}
}
})
}

var cateIds = [];
function getCateId(cateId) {
$("tbody tr[fid="+cateId+"]").each(function(index, el) {
id = $(el).attr('cate-id');
cateIds.push(id);
getCateId(id);
});
}

</script>
 

Layui分页与springboots的更多相关文章

  1. LayUI分页,LayUI动态分页,LayUI laypage分页,LayUI laypage刷新当前页

    LayUI分页,LayUI动态分页,LayUI laypage分页,LayUI laypage刷新当前页 >>>>>>>>>>>> ...

  2. 最易懂的layui分页

    该篇文章是在layui前端框架之分页基础上简洁化和详细化. 首先该示例采用的是Spring+MyBatis Plus+SpringMVC(常规的SSM框架),持久层换成MyBatis也行. 至于lay ...

  3. springBoot mybatis mysql pagehelper layui 分页

    <!-- 加入 pagehelper 分页插件 jar包--><dependency> <groupId>com.github.pagehelper</gro ...

  4. 二十九、layui分页插件的使用

    <div id="page1"></div> <script> //开启分页 var page = 1; function findstoreL ...

  5. tp5 设置layui分页

    \thinkphp\library\think\paginator\driver 添加 Layui.php <?php namespace think\paginator\driver; use ...

  6. SSM项目layui分页实例

    最近学了layui,发现其中的分页挺有意思的,所以整理了一下,一遍自己随时查看.(官方文档上已经很详细了,当中有不足的地方欢迎大家指出) 关于前台的js文件,css样式,js样式,大家可以到官网下 本 ...

  7. 基于MVC框架layui分页控件实现前端分页信息写法

    详细链接:https://shop499704308.taobao.com/?spm=a1z38n.10677092.card.11.594c1debsAGeak@{ ViewBag.Title = ...

  8. layui分页

    毕业已经两年,期间经历了很多.一个人欢笑与哭泣,在墙角.在路边.在床上.每天搭乘首班车来到公司,每天无数次反省自己,每天每天再问自己为什么活着. 一.下载并引用css和js 地址:点我 <lin ...

  9. js layui 分页脚本

    //分页 layui.use(['laypage'], function(){ var laypage = layui.laypage; laypage.render({ elem: 'page' , ...

  10. LayUI分页基于ASP.NET MVC

    ---恢复内容开始--- 今天写了挺久的分页,百度了很多都没有很好的.Net实例,今天我来更新一期关于layuiTable分页 首先你得理解layui的官方文档的Table分页部分,我在这里附上地址 ...

随机推荐

  1. sass和less以及stylus的区别

    一.区别: 需要配置不同:Sass需要Ruby环境:Less需要引入less.js:Stylus需要安装node 使用语法不用:Sass变量使用$ ;Less变量使用@:stylus变量使用 属性名 ...

  2. 【记录】Linux Mint Cinnamon Desktop Enviroment使用记录

    之前使用的系统是Kali Linux,并不是看上了一堆工具,工具的话上虚拟机不好吗,会折腾的docker更好阿,主要是 1. 用习惯了gnome的桌面环境 2. 开箱即用 很多配置他都已经做好了 我都 ...

  3. Nginx基础篇

    目录 一.nginx基础篇 1.Nginx开源版本安装 2.Nginx的基础配置 3.虚拟主机与域名解析 4.ServerName匹配规则 5.反向代理 6.动静分离 7.location后符号的匹配 ...

  4. Doris使用记录

    创建分区表: CREATE TABLE `test_partitioned` ( `gmt_create` datetime NULL COMMENT "创建时间", `colum ...

  5. Beginning IOS 7 Development Exploring the IOS SDK - Handling Basic Interface Fun

    Beginning IOS 7 Development Exploring the IOS SDK 目前使用的是Objective-C,用这本书,简单记录一下 第一章,图书简介 第二章,简要介绍使用x ...

  6. Physics Informed Deep Learning for Flow and Transport in Porous Media

    Paper presented at the SPE Reservoir Simulation Conference, On-Demand, October 2021. 这篇论文关注石油储藏模拟问题, ...

  7. Eclipse创建maven-web项目时找不到archetype解决方法

    转:https://blog.csdn.net/sunjinjuan/article/details/82943488

  8. CSS兄弟范围选择器

    我们想要选择一部分兄弟元素,根据需要试着写了一个  td:nth-child(4)~td:not(:nth-child(7)~td) {        display: none;  } 从第5个元素 ...

  9. 大二下学期开学java测试

    我们在2月13日下午进行了java测试(是一个新闻类型的题),通过这一个测试我进行了以下总结: 我对于javaweb的框架构建和加密密码,还有一些不同人物功能的实现,使得我在这次得考试中成绩不太理想. ...

  10. Maxim遍历测试工具(monkey升级版)

    Maxim 对应GitHub地址:https://github.com/zhangzhao4444/Maxim,其是对Android monkey的改进工具.是基于遍历规则和高性能要求. 条件准备: ...