支持用户数据导入
This commit is contained in:
@ -59,7 +59,7 @@ public class SysJobController extends BaseController
|
||||
{
|
||||
List<SysJob> list = jobService.selectJobList(job);
|
||||
ExcelUtil<SysJob> util = new ExcelUtil<SysJob>(SysJob.class);
|
||||
return util.exportExcel(list, "job");
|
||||
return util.exportExcel(list, "定时任务");
|
||||
}
|
||||
|
||||
@Log(title = "定时任务", businessType = BusinessType.DELETE)
|
||||
|
@ -58,7 +58,7 @@ public class SysJobLogController extends BaseController
|
||||
{
|
||||
List<SysJobLog> list = jobLogService.selectJobLogList(jobLog);
|
||||
ExcelUtil<SysJobLog> util = new ExcelUtil<SysJobLog>(SysJobLog.class);
|
||||
return util.exportExcel(list, "jobLog");
|
||||
return util.exportExcel(list, "调度日志");
|
||||
}
|
||||
|
||||
@Log(title = "调度日志", businessType = BusinessType.DELETE)
|
||||
|
@ -56,7 +56,7 @@ public class SysLogininforController extends BaseController
|
||||
{
|
||||
List<SysLogininfor> list = logininforService.selectLogininforList(logininfor);
|
||||
ExcelUtil<SysLogininfor> util = new ExcelUtil<SysLogininfor>(SysLogininfor.class);
|
||||
return util.exportExcel(list, "logininfor");
|
||||
return util.exportExcel(list, "登陆日志");
|
||||
}
|
||||
|
||||
@RequiresPermissions("monitor:logininfor:remove")
|
||||
|
@ -58,7 +58,7 @@ public class SysOperlogController extends BaseController
|
||||
{
|
||||
List<SysOperLog> list = operLogService.selectOperLogList(operLog);
|
||||
ExcelUtil<SysOperLog> util = new ExcelUtil<SysOperLog>(SysOperLog.class);
|
||||
return util.exportExcel(list, "operLog");
|
||||
return util.exportExcel(list, "操作日志");
|
||||
}
|
||||
|
||||
@RequiresPermissions("monitor:operlog:remove")
|
||||
|
@ -62,7 +62,7 @@ public class SysConfigController extends BaseController
|
||||
{
|
||||
List<SysConfig> list = configService.selectConfigList(config);
|
||||
ExcelUtil<SysConfig> util = new ExcelUtil<SysConfig>(SysConfig.class);
|
||||
return util.exportExcel(list, "config");
|
||||
return util.exportExcel(list, "参数数据");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -59,7 +59,7 @@ public class SysDictDataController extends BaseController
|
||||
{
|
||||
List<SysDictData> list = dictDataService.selectDictDataList(dictData);
|
||||
ExcelUtil<SysDictData> util = new ExcelUtil<SysDictData>(SysDictData.class);
|
||||
return util.exportExcel(list, "dictData");
|
||||
return util.exportExcel(list, "字典数据");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -60,7 +60,7 @@ public class SysDictTypeController extends BaseController
|
||||
|
||||
List<SysDictType> list = dictTypeService.selectDictTypeList(dictType);
|
||||
ExcelUtil<SysDictType> util = new ExcelUtil<SysDictType>(SysDictType.class);
|
||||
return util.exportExcel(list, "dictType");
|
||||
return util.exportExcel(list, "字典类型");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -59,7 +59,7 @@ public class SysPostController extends BaseController
|
||||
{
|
||||
List<SysPost> list = postService.selectPostList(post);
|
||||
ExcelUtil<SysPost> util = new ExcelUtil<SysPost>(SysPost.class);
|
||||
return util.exportExcel(list, "post");
|
||||
return util.exportExcel(list, "岗位数据");
|
||||
}
|
||||
|
||||
@RequiresPermissions("system:post:remove")
|
||||
|
@ -60,7 +60,7 @@ public class SysRoleController extends BaseController
|
||||
{
|
||||
List<SysRole> list = roleService.selectRoleList(role);
|
||||
ExcelUtil<SysRole> util = new ExcelUtil<SysRole>(SysRole.class);
|
||||
return util.exportExcel(list, "role");
|
||||
return util.exportExcel(list, "角色数据");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -11,6 +11,7 @@ import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.base.AjaxResult;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
@ -19,11 +20,11 @@ import com.ruoyi.common.utils.ExcelUtil;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.framework.shiro.service.SysPasswordService;
|
||||
import com.ruoyi.framework.util.ShiroUtils;
|
||||
import com.ruoyi.framework.web.base.BaseController;
|
||||
import com.ruoyi.system.domain.SysUser;
|
||||
import com.ruoyi.system.service.ISysPostService;
|
||||
import com.ruoyi.system.service.ISysRoleService;
|
||||
import com.ruoyi.system.service.ISysUserService;
|
||||
import com.ruoyi.framework.web.base.BaseController;
|
||||
|
||||
/**
|
||||
* 用户信息
|
||||
@ -73,7 +74,28 @@ public class SysUserController extends BaseController
|
||||
{
|
||||
List<SysUser> list = userService.selectUserList(user);
|
||||
ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
|
||||
return util.exportExcel(list, "user");
|
||||
return util.exportExcel(list, "用户数据");
|
||||
}
|
||||
|
||||
@Log(title = "用户管理", businessType = BusinessType.IMPORT)
|
||||
@RequiresPermissions("system:user:import")
|
||||
@PostMapping("/importData")
|
||||
@ResponseBody
|
||||
public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception
|
||||
{
|
||||
ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
|
||||
List<SysUser> userList = util.importExcel(file.getInputStream());
|
||||
String message = userService.importUser(userList, updateSupport);
|
||||
return AjaxResult.success(message);
|
||||
}
|
||||
|
||||
@RequiresPermissions("system:user:view")
|
||||
@GetMapping("/importTemplate")
|
||||
@ResponseBody
|
||||
public AjaxResult importTemplate()
|
||||
{
|
||||
ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
|
||||
return util.importTemplateExcel("用户数据");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -3,7 +3,42 @@
|
||||
* Copyright (c) 2018 ruoyi
|
||||
*/
|
||||
|
||||
/** 用户管理 样式布局 */
|
||||
/** 基础通用 **/
|
||||
.pt5 {
|
||||
padding-top: 5px;
|
||||
}
|
||||
.pr5 {
|
||||
padding-right: 5px;
|
||||
}
|
||||
.pb5 {
|
||||
padding-bottom: 5px;
|
||||
}
|
||||
.mt10 {
|
||||
margin-top: 10px;
|
||||
}
|
||||
.mr10 {
|
||||
margin-right: 10px;
|
||||
}
|
||||
.mb10 {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.ml0 {
|
||||
margin-left: 10px;
|
||||
}
|
||||
.mt20 {
|
||||
margin-top: 20px;
|
||||
}
|
||||
.mr20 {
|
||||
margin-right: 20px;
|
||||
}
|
||||
.mb20 {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
.ml20 {
|
||||
margin-left: 20px;
|
||||
}
|
||||
|
||||
/** 用户管理 样式布局 **/
|
||||
.box {
|
||||
position: relative;
|
||||
border-radius: 3px;
|
||||
@ -91,7 +126,7 @@
|
||||
margin: 5px 0 5px -25px
|
||||
}
|
||||
|
||||
/** select2 样式修改 */
|
||||
/** select2 样式修改 **/
|
||||
.select2-container--default .select2-selection--multiple .select2-selection__choice {
|
||||
background-color: #1AB394;
|
||||
border-color: #1AB394;
|
||||
@ -112,7 +147,7 @@
|
||||
padding-right: 10px
|
||||
}
|
||||
|
||||
/** 表单验证 样式布局 */
|
||||
/** 表单验证 样式布局 **/
|
||||
label.error {
|
||||
position: absolute;
|
||||
right: 18px;
|
||||
@ -143,7 +178,7 @@ label.error {
|
||||
max-width: none;
|
||||
}
|
||||
|
||||
/** 复选框&单选框 */
|
||||
/** 复选框&单选框 **/
|
||||
.check-box,.radio-box {
|
||||
display: inline-block;
|
||||
box-sizing: border-box;
|
||||
@ -160,7 +195,7 @@ label.error {
|
||||
left: 0
|
||||
}
|
||||
|
||||
/* iCheck */
|
||||
/** iCheck **/
|
||||
.icheckbox-blue,.iradio-blue {
|
||||
display: block;
|
||||
margin: 0;
|
||||
@ -214,7 +249,7 @@ label.error {
|
||||
background-position: -180px 0
|
||||
}
|
||||
|
||||
/** 遮罩层 */
|
||||
/** 遮罩层 **/
|
||||
.loaderbox {
|
||||
display: inline-block;
|
||||
min-width: 125px;
|
||||
@ -281,7 +316,7 @@ label.error {
|
||||
}
|
||||
}
|
||||
|
||||
/** 表单查询条件 */
|
||||
/** 表单查询条件 **/
|
||||
ul {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
@ -409,7 +444,7 @@ label {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
/** 表格查询数据 */
|
||||
/** 表格查询数据 **/
|
||||
.table-striped {
|
||||
min-height: 75%;
|
||||
}
|
||||
@ -437,7 +472,7 @@ label {
|
||||
border: 1px solid #ddd!important
|
||||
}
|
||||
|
||||
/** 首页样式 */
|
||||
/** 首页样式 **/
|
||||
.ax_close_max {
|
||||
position: fixed;
|
||||
top: 5px;
|
||||
|
@ -92,7 +92,7 @@
|
||||
}
|
||||
$("#bootstrap-table").bootstrapTable('refresh', params);
|
||||
},
|
||||
// 下载-默认第一个form
|
||||
// 导出数据
|
||||
exportExcel: function(formId) {
|
||||
var currentId = $.common.isEmpty(formId) ? $('form').attr('id') : formId;
|
||||
$.modal.loading("正在导出数据,请稍后...");
|
||||
@ -105,6 +105,64 @@
|
||||
$.modal.closeLoading();
|
||||
});
|
||||
},
|
||||
// 下载模板
|
||||
importTemplate: function() {
|
||||
$.get($.table._option.importTemplateUrl, function(result) {
|
||||
if (result.code == web_status.SUCCESS) {
|
||||
window.location.href = ctx + "common/download?fileName=" + result.msg + "&delete=" + true;
|
||||
} else {
|
||||
$.modal.alertError(result.msg);
|
||||
}
|
||||
});
|
||||
},
|
||||
// 导入数据
|
||||
importExcel: function(formId) {
|
||||
var currentId = $.common.isEmpty(formId) ? 'importForm' : formId;
|
||||
$.form.reset(currentId);
|
||||
layer.open({
|
||||
type: 1,
|
||||
area: ['400px'],
|
||||
fix: false,
|
||||
//不固定
|
||||
maxmin: true,
|
||||
shade: 0.3,
|
||||
title: '导入' + $.table._option.modalName + '数据',
|
||||
content: $('#' + currentId),
|
||||
btn: ['<i class="fa fa-check"></i> 导入', '<i class="fa fa-remove"></i> 取消'],
|
||||
// 弹层外区域关闭
|
||||
shadeClose: true,
|
||||
btn1: function(index, layero){
|
||||
var file = layero.find('#file').val();
|
||||
if (file == '' || (!$.common.endWith(file, '.xls') && !$.common.endWith(file, '.xlsx'))){
|
||||
$.modal.msgWarning("请选择后缀为 “xls”或“xlsx”的文件。");
|
||||
return false;
|
||||
}
|
||||
var index = layer.load(2, {shade: false});
|
||||
var url = prefix + "/importData";
|
||||
var formData = new FormData();
|
||||
formData.append("file", $('#file')[0].files[0]);
|
||||
formData.append("updateSupport", $("input[name='updateSupport']").is(':checked'));
|
||||
$.ajax({
|
||||
url: url,
|
||||
data: formData,
|
||||
cache: false,
|
||||
contentType: false,
|
||||
processData: false,
|
||||
type: 'POST',
|
||||
success: function (result) {
|
||||
if (result.code == web_status.SUCCESS) {
|
||||
$.modal.closeAll();
|
||||
$.modal.alertSuccess(result.msg);
|
||||
$.table.refresh();
|
||||
} else {
|
||||
layer.close(index);
|
||||
$.modal.alertError(result.msg);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
// 刷新表格
|
||||
refresh: function() {
|
||||
$("#bootstrap-table").bootstrapTable('refresh', {
|
||||
@ -288,6 +346,10 @@
|
||||
var index = parent.layer.getFrameIndex(window.name);
|
||||
parent.layer.close(index);
|
||||
},
|
||||
// 关闭全部窗体
|
||||
closeAll: function () {
|
||||
layer.closeAll();
|
||||
},
|
||||
// 确认窗体
|
||||
confirm: function (content, callBack) {
|
||||
layer.confirm(content, {
|
||||
|
@ -184,7 +184,7 @@
|
||||
|
||||
/*用户管理-修改-选择部门树*/
|
||||
function selectDeptTree() {
|
||||
var deptId = $("#treeId").val();
|
||||
var deptId = $.common.isEmpty($("#treeId").val()) ? "100" : $("#treeId").val();
|
||||
var url = ctx + "system/dept/selectDeptTree/" + deptId;
|
||||
var options = {
|
||||
title: '选择部门',
|
||||
|
@ -73,6 +73,9 @@
|
||||
<a class="btn btn-danger btn-del disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:user:remove">
|
||||
<i class="fa fa-remove"></i> 删除
|
||||
</a>
|
||||
<a class="btn btn-info" onclick="$.table.importExcel()" shiro:hasPermission="system:user:import">
|
||||
<i class="fa fa-download"></i> 导入
|
||||
</a>
|
||||
<a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:user:export">
|
||||
<i class="fa fa-download"></i> 导出
|
||||
</a>
|
||||
@ -83,6 +86,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div th:include="include :: footer"></div>
|
||||
<script th:src="@{/ajax/libs/jquery-layout/jquery.layout-latest.js}"></script>
|
||||
<script th:src="@{/ajax/libs/jquery-ztree/3.5/js/jquery.ztree.all-3.5.js}"></script>
|
||||
@ -106,6 +110,8 @@
|
||||
updateUrl: prefix + "/edit/{id}",
|
||||
removeUrl: prefix + "/remove",
|
||||
exportUrl: prefix + "/export",
|
||||
importUrl: prefix + "/importData",
|
||||
importTemplateUrl: prefix + "/importTemplate",
|
||||
sortName: "createTime",
|
||||
sortOrder: "desc",
|
||||
modalName: "用户",
|
||||
@ -214,4 +220,16 @@
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
<form id="importForm" enctype="multipart/form-data" class="mt20 mb10" style="display: none;">
|
||||
<div class="col-xs-offset-1">
|
||||
<input type="file" id="file" name="file"/>
|
||||
<div class="mt10 pt5">
|
||||
<input type="checkbox" id="updateSupport" name="updateSupport" title="如果登录账户已经存在,更新这条数据。"> 是否更新已经存在的用户数据
|
||||
<a onclick="$.table.importTemplate()" class="btn btn-default btn-xs"><i class="fa fa-file-excel-o"></i> 下载模板</a>
|
||||
</div>
|
||||
<font color="red" class="pull-left mt10">
|
||||
提示:仅允许导入“xls”或“xlsx”格式文件!
|
||||
</font>
|
||||
</div>
|
||||
</form>
|
||||
</html>
|
Reference in New Issue
Block a user