forked from github/dataease
Merge pull request #3019 from dataease/pr@dev@fix_import_user_error_tip
fix(系统管理-用户管理): 导入用户错误提示
This commit is contained in:
commit
e4d85fb8d3
@ -21,4 +21,8 @@ public class AuthConstants {
|
||||
public final static String DEPT_DATASET_NAME = "dept_dataset";
|
||||
public final static String DEPT_PANEL_NAME = "dept_panel";
|
||||
|
||||
|
||||
|
||||
public static final String DE_DOWN_ERROR_KEY = "de-down-error-msg";
|
||||
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package io.dataease.plugins.server;
|
||||
|
||||
import io.dataease.commons.exception.DEException;
|
||||
import io.dataease.i18n.Translator;
|
||||
import io.dataease.commons.constants.AuthConstants;
|
||||
import io.dataease.commons.utils.LogUtil;
|
||||
import io.dataease.plugins.config.SpringContextUtil;
|
||||
import io.dataease.plugins.xpack.user.service.UserXpackService;
|
||||
import io.swagger.annotations.Api;
|
||||
@ -31,23 +31,24 @@ public class XUserServer {
|
||||
|
||||
@ApiOperation("导入")
|
||||
@PostMapping("/upload")
|
||||
public void upload(@RequestPart(value = "file", required = true) MultipartFile file, HttpServletResponse response) throws Exception{
|
||||
public void upload(@RequestPart(value = "file", required = true) MultipartFile file, HttpServletResponse response) {
|
||||
if (file.getSize() > MAXSIZE) {
|
||||
String msgKey = "i18n_max_user_import_size";
|
||||
String msg = Translator.get(msgKey);
|
||||
DEException.throwException(msg);
|
||||
response.addHeader("Access-Control-Expose-Headers", AuthConstants.DE_DOWN_ERROR_KEY);
|
||||
response.setHeader(AuthConstants.DE_DOWN_ERROR_KEY, msgKey);
|
||||
return;
|
||||
}
|
||||
UserXpackService userXpackService = SpringContextUtil.getBean(UserXpackService.class);
|
||||
try{
|
||||
userXpackService.upload(file, response);
|
||||
}catch (Exception e) {
|
||||
response.addHeader("Access-Control-Expose-Headers", AuthConstants.DE_DOWN_ERROR_KEY);
|
||||
if (StringUtils.contains(e.getMessage(), "template file error")) {
|
||||
|
||||
DEException.throwException(Translator.get("I18N_USER_TEMPLATE_ERROR"));
|
||||
response.setHeader(AuthConstants.DE_DOWN_ERROR_KEY, "I18N_USER_TEMPLATE_ERROR");
|
||||
}else {
|
||||
DEException.throwException(e.getMessage());
|
||||
response.setHeader(AuthConstants.DE_DOWN_ERROR_KEY, e.getMessage());
|
||||
}
|
||||
|
||||
LogUtil.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2459,5 +2459,8 @@ export default {
|
||||
attr: 'Attribute',
|
||||
empty: 'Empty',
|
||||
please_select_map: 'Please select a range of map'
|
||||
}
|
||||
},
|
||||
'I18N_USER_TEMPLATE_ERROR': 'Template file error',
|
||||
'i18n_max_user_import_size': 'File size exceeds 10M'
|
||||
|
||||
}
|
||||
|
@ -2460,5 +2460,7 @@ export default {
|
||||
attr: '屬性',
|
||||
empty: '無數據',
|
||||
please_select_map: '請先選擇地圖範圍'
|
||||
}
|
||||
},
|
||||
'I18N_USER_TEMPLATE_ERROR': '模版錯誤',
|
||||
'i18n_max_user_import_size': '文件最大不能超過10M'
|
||||
}
|
||||
|
@ -2460,5 +2460,7 @@ export default {
|
||||
attr: '属性',
|
||||
empty: '无数据',
|
||||
please_select_map: '请先选择地图范围'
|
||||
}
|
||||
},
|
||||
'I18N_USER_TEMPLATE_ERROR': '模版错误',
|
||||
'i18n_max_user_import_size': '文件最大不能超过10M'
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ module.exports = {
|
||||
IdTokenKey: 'IdToken',
|
||||
AccessTokenKey: 'AccessToken',
|
||||
CASSESSION: 'JSESSIONID',
|
||||
DownErrorKey: 'de-down-error-msg',
|
||||
|
||||
/**
|
||||
* @type {boolean} true | false
|
||||
|
@ -1262,6 +1262,7 @@ div:focus {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.btn {
|
||||
border-radius: 4px;
|
||||
padding: 5px 26px 5px 26px;
|
||||
@ -1311,4 +1312,11 @@ div:focus {
|
||||
.user-popper.dept {
|
||||
height: 400px;
|
||||
overflow: auto;
|
||||
|
||||
}
|
||||
.upload-user{
|
||||
margin-bottom: 5px;
|
||||
.el-upload{
|
||||
width: 100%;
|
||||
}
|
||||
}
|
@ -11,6 +11,7 @@ import Vue from 'vue'
|
||||
const TokenKey = Config.TokenKey
|
||||
const RefreshTokenKey = Config.RefreshTokenKey
|
||||
const LinkTokenKey = Config.LinkTokenKey
|
||||
const DownErrorKey = Config.DownErrorKey
|
||||
import Cookies from 'js-cookie'
|
||||
|
||||
const getTimeOut = () => {
|
||||
@ -98,6 +99,9 @@ service.interceptors.response.use(response => {
|
||||
response.config.loading && tryHideLoading(store.getters.currentPath)
|
||||
checkAuth(response)
|
||||
Vue.prototype.$currentHttpRequestList.delete(response.config.url)
|
||||
if (checkDownError(response)) {
|
||||
return response
|
||||
}
|
||||
return response.data
|
||||
}, error => {
|
||||
const config = error.response && error.response.config || error.config
|
||||
@ -114,7 +118,14 @@ service.interceptors.response.use(response => {
|
||||
!config.hideMsg && (!headers['authentication-status']) && $error(msg)
|
||||
return Promise.reject(error)
|
||||
})
|
||||
|
||||
const checkDownError = response => {
|
||||
if (response.request && response.request.responseType && response.request.responseType === 'blob' && response.headers && response.headers['de-down-error-msg']) {
|
||||
const msg = i18n.t(response.headers[DownErrorKey])
|
||||
$error(msg)
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
const checkAuth = response => {
|
||||
if (response.headers['authentication-status'] === 'login_expire') {
|
||||
const message = i18n.t('login.expires')
|
||||
|
Loading…
Reference in New Issue
Block a user