fix(数据源): 修复 Excel 文件上传时超过 1 分钟被取消但是系统无提示信息给用户

This commit is contained in:
taojinlong 2024-05-22 18:18:09 +08:00
parent eebc94a739
commit 4b6da963b4
4 changed files with 31 additions and 7 deletions

View File

@ -152,6 +152,7 @@ export const uploadFile = async (data): Promise<IResponse> => {
.post({
url: '/datasource/uploadFile',
data,
loading: true,
headersType: 'multipart/form-data;'
})
.then(res => {

View File

@ -210,7 +210,7 @@ service.interceptors.response.use(
) {
ElMessage({
type: 'error',
message: error.message,
message: error.response?.data?.msg ? error.response?.data?.msg : error.message,
showClose: true
})
} else if (error?.config?.url.startsWith('/xpackComponent/content')) {

View File

@ -354,11 +354,24 @@ const uploadExcel = () => {
formData.append('type', '')
formData.append('editType', param.value.editType)
formData.append('id', param.value.id || 0)
return uploadFile(formData).then(res => {
upload.value?.clearFiles()
uploadAgain.value?.clearFiles()
uploadSuccess(res)
})
loading.value = true
return uploadFile(formData)
.then(res => {
upload.value?.clearFiles()
uploadAgain.value?.clearFiles()
uploadSuccess(res)
loading.value = false
})
.catch(error => {
if (error.code === 'ECONNABORTED') {
ElMessage({
type: 'error',
message: error.message,
showClose: true
})
}
loading.value = false
})
}
const excelForm = ref()
const submitForm = () => {
@ -394,6 +407,7 @@ defineExpose({
require-asterisk-position="right"
:model="param"
label-position="top"
v-loading="loading"
>
<el-form-item
v-if="sheetFile.name"

View File

@ -1,5 +1,7 @@
package io.dataease.filter;
import io.dataease.result.ResultMessage;
import io.dataease.utils.JsonUtil;
import jakarta.servlet.*;
import jakarta.servlet.FilterConfig;
import jakarta.servlet.http.HttpServletResponse;
@ -36,7 +38,14 @@ public class HtmlResourceFilter implements Filter, Ordered {
httpResponse.setHeader(HttpHeaders.EXPIRES, "0");
}
// 继续执行过滤器链
filterChain.doFilter(servletRequest, httpResponse);
try {
filterChain.doFilter(servletRequest, httpResponse);
}catch (Exception e){
httpResponse.setContentType("application/json");
httpResponse.setCharacterEncoding("UTF-8");
httpResponse.setStatus(HttpServletResponse.SC_BAD_REQUEST);
httpResponse.getWriter().write(JsonUtil.toJSONString(new ResultMessage(HttpServletResponse.SC_BAD_REQUEST,e.getMessage())).toString());
}
}
@Override