更新初始化文件

pull/1/head
759675757@qq.com 2019-12-26 13:20:54 +08:00
parent 30ec1b8024
commit 029769b044
15 changed files with 154 additions and 176 deletions

View File

@ -1,5 +1,6 @@
package com.songpeng.sparchetype.common;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.Data;
import lombok.experimental.Accessors;
@ -11,7 +12,7 @@ import lombok.experimental.Accessors;
*/
@Data
@Accessors(chain = true)
public class BasePageReq {
public class BasePageReq extends Page {
private String orderBy = "last_upd";

View File

@ -3,7 +3,6 @@ package com.songpeng.sparchetype.system.controller.admin;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.songpeng.sparchetype.common.BaseController;
import com.songpeng.sparchetype.common.Result;
import com.songpeng.sparchetype.system.entity.SysUser;
@ -43,11 +42,11 @@ public class SysUserController extends BaseController {
@PostMapping("/page")
@ResponseBody
public Result page(Page page, SysUserPageReq req) {
public Result page(SysUserPageReq req) {
Object principal = SecurityUtils.getSubject().getPrincipal();
QueryWrapper qw = new QueryWrapper();
qw.orderByDesc(req.getOrderBy());
IPage result = sysUserService.page(page, qw);
IPage result = sysUserService.page(req, qw);
return Result.success(result);
}

View File

@ -1,7 +1,7 @@
/**
* date:2019/12/24
* author:SongPeng
* description:扩展layui弹出框 框架扩展
* date: 2019/12/24
* author: SongPeng
* description: 扩展layui弹出框 框架扩展
*/
layui.define(['layer'], function (exports) {
var $ = layui.jquery;
@ -10,11 +10,33 @@ layui.define(['layer'], function (exports) {
var splayer = {
// 渲染弹出框
open: function (param) {
var config = {};
$.extend(config, param, {
// 这里写默认配置,会覆盖自定义配置 param
// 默认配置
var defaultConfig = {
type: 2,
fixed: false,
maxmin: true,
btn: ['确定', '取消'],
yes: function (index, layero) {
//点击确认触发 iframe 内容中的按钮提交
var submit = layero.find('iframe').contents().find("#js-submit");
submit.click();
},
btn2: function (index, layero) {
//按钮【按钮二】的回调
//return false 开启该代码可禁止点击该按钮关闭
},
cancel: function (index, layero) {
//右上角关闭回调
//return false 开启该代码可禁止点击该按钮关闭
}
};
var config = $.extend({}, defaultConfig, param, {
content: param.content + '?' + spUtil.parseParam(param.spWhere)
});
layer.open(config);
}
};

View File

@ -1,7 +1,7 @@
/**
* date:2019/12/24
* author:SongPeng
* description:扩展layui数据表格 框架扩展
* date: 2019/12/24
* author: SongPeng
* description: 扩展layui数据表格 框架扩展
*/
layui.define(['table'], function (exports) {
var $ = layui.jquery;
@ -10,25 +10,27 @@ layui.define(['table'], function (exports) {
var sptable = {
// 渲染表格
render: function (param) {
var config = {};
$.extend(config, param, {
var defaultConfig = {
elem: '#record-table',
toolbar: '#toolbar-top',
method: 'POST',
limits: [10, 20, 50, 100],
limit: 10,
request: {
pageName: 'current' //页码的参数名称默认page
, limitName: 'size' //每页数据量的参数名默认limit
pageName: 'current'
, limitName: 'size'
},
parseData: function (res) { //res 即为原始返回的数据
parseData: function (res) {
return {
"code": res.code || 1, //解析接口状态
"msg": res.msg || '系统错误,请联系管理员', //解析提示文本
"count": res.data ? res.data.total : 0, //解析数据长度
"data": res.data ? res.data.records : [] //解析数据列表
"code": res.code,
"msg": res.msg,
"count": res.data ? res.data.total : 0,
"data": res.data ? res.data.records : []
};
}
};
var config = $.extend({}, defaultConfig, param, {
});
return table.render(config);

View File

@ -1,6 +1,39 @@
// 工具类
var spUtil = {};
spUtil.submitForm = function(param) {
// 默认配置
var defaultConfig = {
type: "POST",
async: true,
success: function (result) {
if (result.code === 0) {
// 获得frame索引
var index = parent.layer.getFrameIndex(window.name);
//刷新父页面注意一定要在关闭当前iframe层之前执行刷新
parent.location.reload();
//关闭当前frame
parent.layer.close(index);
} else {
layer.alert(result.msg, {
icon: 2
})
}
},
error: function (e) {
layer.alert(e, {
icon: 2
});
}
};
var config = $.extend({}, defaultConfig, param, {
// 此处写覆盖默认和传参配置
});
$.ajax(config);
};
/**
* 将对象转为url路径字符串参数编码之后的字符串
* @param param

View File

@ -21,7 +21,7 @@
<i class="layui-icon" style="line-height:30px">&#xe669;</i>
</a>
</div>
<div class="weadmin-body">
<div class="">
<div class="layui-row">
<form class="layui-form layui-col-md12 we-search" lay-filter="search-form-filter">
<div class="layui-input-inline">

View File

@ -9,7 +9,7 @@
<#include "${request.contextPath}/common/common.ftl">
</head>
<body>
<div class="weadmin-body">
<div class="">
<div class="weadmin-trailer">
403
</div>

View File

@ -2,15 +2,15 @@
<html>
<head>
<meta charset="UTF-8">
<title>欢迎页面-WeAdmin Frame型后台管理系统-WeAdmin 1.0</title>
<title>欢迎页面-后台管理系统-1.0</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
<#include "${request.contextPath}/common/common.ftl">
</head>
<body>
<div class="weadmin-body">
<div class="weadmin-trailer">
<div class="">
<div class="">
500
</div>
</div>

View File

@ -15,7 +15,7 @@
</head>
<body>
<div class="weadmin-body">
<div class="">
<form class="layui-form">
<div class="layui-form-item">
<label for="js-name" class="layui-form-label sp-required">标签名

View File

@ -10,7 +10,7 @@
<#include "${request.contextPath}/common/common.ftl">
</head>
<body>
<div class="weadmin-body">
<div class="">
<div class="layui-row">
<form class="layui-form layui-col-md12 we-search" lay-filter="search-form-filter">
<div class="layui-input-inline">

View File

@ -15,7 +15,7 @@
</head>
<body>
<div class="weadmin-body">
<div class="">
<form class="layui-form">
<div class="layui-form-item">
<label for="js-name" class="layui-form-label sp-required">菜单名称

View File

@ -15,7 +15,7 @@
</head>
<body>
<div class="weadmin-body">
<div class="">
<form class="layui-form">
<div class="layui-form-item">
<label for="js-name" class="layui-form-label sp-required">角色名称

View File

@ -10,7 +10,7 @@
<#include "${request.contextPath}/common/common.ftl">
</head>
<body>
<div class="weadmin-body">
<div class="">
<div class="layui-row">
<form class="layui-form layui-col-md12 we-search" lay-filter="search-form-filter">
<div class="layui-input-inline">

View File

@ -10,7 +10,7 @@
</head>
<body>
<div class="weadmin-body">
<div class="">
<form class="layui-form layuimini-form">
<div class="layui-container">
<div class="layui-row">
@ -211,30 +211,9 @@
//监听提交
form.on('submit(js-submit-filter)', function (data) {
$.ajax({
type: "POST",
async: true,
spUtil.submitForm({
url: "${request.contextPath}/admin/sys/user/add-or-upd",
data: data.field,
success: function (result) {
if (result.code === 0) {
// 获得frame索引
var index = parent.layer.getFrameIndex(window.name);
//刷新父页面注意一定要在关闭当前iframe层之前执行刷新
parent.location.reload();
//关闭当前frame
parent.layer.close(index);
} else {
layer.alert(result.msg, {
icon: 2
})
}
},
error: function (e) {
layer.alert(e, {
icon: 2
})
}
data: data.field
});
return false;

View File

@ -12,51 +12,37 @@
<div class="layuimini-container">
<div class="layuimini-main">
<!--查询参数-->
<form id="js-q-form" class="layui-form" action="">
<form id="js-search-form" class="layui-form" lay-filter="js-q-form-filter">
<div class="layui-form-item">
<div class="layui-inline">
<label class="layui-form-label">用户姓名</label>
<label class="layui-form-label">姓名</label>
<div class="layui-input-inline">
<input type="text" name="username" autocomplete="off" class="layui-input">
<input type="text" name="nameLike" autocomplete="off" class="layui-input">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">用户性别</label>
<label class="layui-form-label">用户</label>
<div class="layui-input-inline">
<input type="text" name="sex" autocomplete="off" class="layui-input">
<input type="text" name="usernameLike" autocomplete="off" class="layui-input">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">用户城市</label>
<div class="layui-input-inline">
<input type="text" name="city" autocomplete="off" class="layui-input">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">用户职业</label>
<div class="layui-input-inline">
<input type="text" name="classify" autocomplete="off" class="layui-input">
</div>
</div>
<div class="layui-inline">
<a class="layui-btn" lay-submit lay-filter="data-search-btn"><i class="layui-icon layui-icon-search layuiadmin-button-btn"></i></a>
<a class="layui-btn" lay-submit lay-filter="js-search-filter"><i class="layui-icon layui-icon-search layuiadmin-button-btn"></i></a>
</div>
</div>
</form>
<!--表格-->
<table class="layui-hide" id="record-table" lay-filter="table-filter"></table>
<table class="layui-hide" id="record-table" lay-filter="js-table-filter"></table>
</div>
</div>
<!--表格头操作模板-->
<script type="text/html" id="toolbar-top">
<div class="layui-btn-container">
<button class="layui-btn layui-btn-danger layui-btn-sm" lay-event="getCheckData"><i class="layui-icon">&#xe640;</i>批量删除</button>
<button class="layui-btn layui-btn-danger layui-btn-sm" lay-event="deleteBatch"><i class="layui-icon">&#xe640;</i>批量删除</button>
<@shiro.hasPermission name="user:add">
<button class="layui-btn layui-btn-sm" onclick="WeAdminShow('添加用户','${request.contextPath}/admin/sys/user/add-or-upd-ui',600,400)">
<i class="layui-icon">&#xe61f;</i>添加
</button>
<button class="layui-btn layui-btn-sm" lay-event="add"><i class="layui-icon">&#xe61f;</i>添加</button>
</@shiro.hasPermission>
</div>
</script>
@ -64,7 +50,7 @@
<!--行操作模板-->
<script type="text/html" id="toolbar-right">
<a class="layui-btn layui-btn-xs" lay-event="edit"><i class="layui-icon layui-icon-edit"></i>编辑</a>
<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del"><i class="layui-icon layui-icon-delete"></i>删除</a>
<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="delete"><i class="layui-icon layui-icon-delete"></i>删除</a>
</script>
<!--js逻辑-->
@ -76,8 +62,9 @@
splayer = layui.splayer,
sptable = layui.sptable;
// 表格及数据初始化
var tableIns = sptable.render({
height: 'full-' + ($('#js-q-form').height() + 40),
height: 'full-' + ($('#js-search-form').height() + 40),
page: true,
url: '${request.contextPath}/admin/sys/user/page',
cols: [
@ -126,8 +113,6 @@
}]
],
done: function (res, curr, count) {
//如果是异步请求数据方式res即为你接口返回的信息。
//如果是直接赋值的方式res即为{data: [], count: 99} data为当前页数据、count为数据总长度
}
});
@ -139,120 +124,77 @@
form.render();
});
form.on('submit(search-form-btn-filter)', function (data) {
/**
* 搜索按钮事件
*/
form.on('submit(js-search-filter)', function (data) {
tableIns.reload({
// 设定异步数据接口的额外参数,任意设
where: data.field,
page: {
curr: 1 //重新从第 1 页开始
// 重新从第 1 页开始
curr: 1
}
});
// 阻止表单跳转。如果需要表单跳转,去掉这段即可。
return false;
});
//头工具栏事件
table.on('toolbar(table-filter)', function (obj) {
/**
* 头工具栏事件
*/
table.on('toolbar(js-table-filter)', function (obj) {
var checkStatus = table.checkStatus(obj.config.id);
switch (obj.event) {
case 'getCheckData':
var checkStatus = table.checkStatus('record-table'),
data = checkStatus.data;
if (data.length > 0) {
layer.confirm('确认要删除吗?' + JSON.stringify(data), function (index) {
layer.msg('删除成功', {
icon: 1
});
//找到所有被选中的,发异步进行删除
$(".layui-table-body .layui-form-checked").parents('tr').remove();
});
} else {
layer.msg("请先选择需要删除的文章!");
}
break;
case 'recommend':
var checkStatus = table.checkStatus('record-table'),
data = checkStatus.data;
if (data.length > 0) {
layer.msg("您点击了推荐操作");
for (var i = 0; i < data.length; i++) {
data[i].recommend = "checked";
form.render();
}
} else {
layer.msg("请先选择");
}
break;
case 'top':
layer.msg("您点击了置顶操作");
break;
case 'review':
layer.msg("您点击了审核操作");
break;
// 批量删除
if (obj.event === 'deleteBatch') {
var checkStatus = table.checkStatus('record-table'),
data = checkStatus.data;
if (data.length > 0) {
layer.confirm('确认要删除吗?', function (index) {
});
} else {
layer.msg("请先选择需要删除的数据!");
}
}
// 添加
if (obj.event === 'add') {
splayer.open({
title: '添加',
area: ['100%', '100%'],
content: '${request.contextPath}/admin/sys/user/add-or-upd-ui'
});
}
});
//监听行工具事件
table.on('tool(table-filter)', function (obj) {
/**
* 监听行工具事件
*/
table.on('tool(js-table-filter)', function (obj) {
var data = obj.data;
if (obj.event === 'del') {
layer.confirm('真的删除行么', function (index) {
// 编辑
if (obj.event === 'edit') {
splayer.open({
title: '编辑',
area: ['100%', '100%'],
// 请求url参数
spWhere: {id: data.id},
content: '${request.contextPath}/admin/sys/user/add-or-upd-ui'
});
}
// 删除
if (obj.event === 'delete') {
layer.confirm('确认要删除吗?', function (index) {
obj.del();
layer.close(index);
});
} else if (obj.event === 'edit') {
splayer.open({
title: '编辑',
type: 2,
area: ['100%', '100%'],
fixed: false,
maxmin: true,
// 请求url参数
spWhere: {id: data.id},
content: '${request.contextPath}/admin/sys/user/add-or-upd-ui',
btn: ['确定', '取消'],
yes: function(index, layero){
//点击确认触发 iframe 内容中的按钮提交
var submit = layero.find('iframe').contents().find("#js-submit");
submit.click();
},
btn2: function(index, layero){
//按钮【按钮二】的回调
//return false 开启该代码可禁止点击该按钮关闭
},
cancel: function(index, layero){
//右上角关闭回调
//return false 开启该代码可禁止点击该按钮关闭
}
});
}
});
/*用户-删除*/
window.member_del = function (obj, id) {
layer.confirm('确认要删除吗?', function (index) {
//发异步删除数据
$(obj).parents("tr").remove();
layer.msg('已删除!', {
icon: 1,
time: 1000
});
});
};
function delAll(argument) {
var data = tableCheck.getData();
layer.confirm('确认要删除吗?' + data, function (index) {
//捉到所有被选中的,发异步进行删除
layer.msg('删除成功', {
icon: 1
});
$(".layui-form-checked").not('.header').parents('tr').remove();
});
}
});
</script>
</body>