支持用户数据导入

This commit is contained in:
RuoYi
2019-01-10 19:06:15 +08:00
parent 619e1d241a
commit ec8c7f1d79
20 changed files with 1057 additions and 223 deletions

View File

@ -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;

View File

@ -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, {