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. 在CentOS 7.4下配置VNC Server服务

    安装步骤 1. 查询系统是否安装vnc-server [root@localhost ~]# rpm –qa | grep vnc 如果有返回值,类似于vnc-server-的值,说明已经安装了vnc ...

  2. 一加5T刷入魔趣

    0.准备工作 1.安装adb工具 2.下载twrp 3.5t系统包. 1.解锁bootloader 先进入原版系统,打开开发者选项,允许USB调试,勾选允许OEM解锁,高级重启选项 打开命令行输入: ...

  3. Linux系统时间的设定以及自带的timesync时间同步

    1.三个阶段的系统时间设定 1.1 内核启动阶段 这里是在menuconfig文件配置RTC设定系统时间选项.      CONFIG_RTC_HCTOSYS_DEVICE="rtc1&qu ...

  4. 【SHELL】记一个没啥用的脚本

    因为最近Terraria更新了嘛,然后又想开服了,但是捏,我原来的UbuntuServer系统因为没有界面,而且我新购置了一台3D打印机,需要软件界面去操作,所以原先的系统就格了,重装win10,然后 ...

  5. superset2.0.0 支持MaxCompute 时间颗粒

    编译的时候需要在superset/superset/db_engine_specs以下路径增加一个 odps.py的文件 # Licensed to the Apache Software Found ...

  6. A表某字段==B表某字段 更新A表的数据

    update mls_supplytask t1 -- 供应商认证任务 JOIN mls_sup_cert_report t2 -- 供应商认证报告 on t1.id = t2.certTaskId ...

  7. 微信小程序循环数组展示数据点击当前改变当前按钮状态

    Html: <view class="container" wx:for="{{arr}}" wx:key="*"> //这里循 ...

  8. Linux安装证书

    Linux安装 vCenter root CA: 1.访问vCenter管理页面,下载"下载受信任的根 CA 证书" 2.压缩文件内带有数字作为扩展名(.0..1 等)的文件是根证 ...

  9. SAP管理员SAP*和DDIC被锁定后如何解锁或重置密码

    SAP*初始化密码是06071992或passDDIC默认密码为19920706 环境信息:win server2003,SQL Server2008 R2 账号信息存在于数据库usr02表中,1.删 ...

  10. SPI接口(续一)

    SPI接口共涉及到11个寄存器,下面就来对它们进行具体分析. 先来看SPI配置寄存器CFG,下表是它的全部位结构,其地址分别为0x40058000(SPI0),0x4005C000(SPI1). (1 ...