fix: improve error message when uploading Excel file with incorrect column count

This commit is contained in:
ulleo
2025-11-27 14:56:51 +08:00
committed by ulleo
parent d916e2911f
commit 8023ce2907
9 changed files with 62 additions and 6 deletions
@@ -11,7 +11,7 @@ import IconOpeDelete from '@/assets/svg/icon_delete.svg'
import icon_searchOutline_outlined from '@/assets/svg/icon_search-outline_outlined.svg'
import EmptyBackground from '@/views/dashboard/common/EmptyBackground.vue'
import { useI18n } from 'vue-i18n'
import { cloneDeep } from 'lodash-es'
import { cloneDeep, endsWith, startsWith } from 'lodash-es'
import { genFileId, type UploadInstance, type UploadProps, type UploadRawFile } from 'element-plus'
import { useCache } from '@/utils/useCache.ts'
import { settingsApi } from '@/api/setting.ts'
@@ -164,9 +164,18 @@ const onSuccess = (response: any) => {
}
}
const onError = () => {
const onError = (err: Error) => {
uploadLoading.value = false
uploadRef.value!.clearFiles()
let msg = err.message
if (startsWith(msg, '"') && endsWith(msg, '"')) {
msg = msg.slice(1, msg.length - 1)
}
ElMessage({
message: msg,
type: 'error',
showClose: true,
})
}
const exportExcel = () => {
+11 -2
View File
@@ -13,7 +13,7 @@ import icon_searchOutline_outlined from '@/assets/svg/icon_search-outline_outlin
import EmptyBackground from '@/views/dashboard/common/EmptyBackground.vue'
import { useClipboard } from '@vueuse/core'
import { useI18n } from 'vue-i18n'
import { cloneDeep } from 'lodash-es'
import { cloneDeep, endsWith, startsWith } from 'lodash-es'
import { genFileId, type UploadInstance, type UploadProps, type UploadRawFile } from 'element-plus'
import { settingsApi } from '@/api/setting.ts'
import { useCache } from '@/utils/useCache.ts'
@@ -167,9 +167,18 @@ const onSuccess = (response: any) => {
}
}
const onError = () => {
const onError = (err: Error) => {
uploadLoading.value = false
uploadRef.value!.clearFiles()
let msg = err.message
if (startsWith(msg, '"') && endsWith(msg, '"')) {
msg = msg.slice(1, msg.length - 1)
}
ElMessage({
message: msg,
type: 'error',
showClose: true,
})
}
const exportExcel = () => {
+11 -2
View File
@@ -15,7 +15,7 @@ import EmptyBackground from '@/views/dashboard/common/EmptyBackground.vue'
import { useClipboard } from '@vueuse/core'
import { useUserStore } from '@/stores/user'
import { useI18n } from 'vue-i18n'
import { cloneDeep } from 'lodash-es'
import { cloneDeep, endsWith, startsWith } from 'lodash-es'
import { getAdvancedApplicationList } from '@/api/embedded.ts'
import { genFileId } from 'element-plus'
@@ -172,9 +172,18 @@ const onSuccess = (response: any) => {
}
}
const onError = () => {
const onError = (err: Error) => {
uploadLoading.value = false
uploadRef.value!.clearFiles()
let msg = err.message
if (startsWith(msg, '"') && endsWith(msg, '"')) {
msg = msg.slice(1, msg.length - 1)
}
ElMessage({
message: msg,
type: 'error',
showClose: true,
})
}
const exportExcel = () => {