fix: 上传excel异常情况,清理缓存

This commit is contained in:
taojinlong 2024-09-02 19:02:30 +08:00
parent 4c0f8893e5
commit 5693e06233
2 changed files with 15 additions and 0 deletions

View File

@ -145,6 +145,10 @@ const handleTabClick = tab => {
}
const uploadFail = response => {
state.excelData = []
activeTab.value = ''
tabList.value = []
Object.assign(sheetObj, cloneDeep(defaultSheetObj))
let myError = response.toString()
myError.replace('Error: ', '')
}
@ -160,6 +164,10 @@ const handleExcelDel = () => {
const uploadSuccess = response => {
if (response?.code !== 0) {
state.excelData = []
activeTab.value = ''
tabList.value = []
Object.assign(sheetObj, cloneDeep(defaultSheetObj))
ElMessage.warning(response.msg)
return
}
@ -365,6 +373,10 @@ const uploadExcel = () => {
loading.value = false
})
.catch(error => {
state.excelData = []
activeTab.value = ''
tabList.value = []
Object.assign(sheetObj, cloneDeep(defaultSheetObj))
if (error.code === 'ECONNABORTED') {
ElMessage({
type: 'error',

View File

@ -884,6 +884,9 @@ const uploadExcel = editType => {
addLoading.value = editType === 1
return uploadFile(formData)
.then(res => {
if (res?.code !== 0) {
return
}
nodeInfo.editType = editType
datasourceEditor.value.init(nodeInfo, nodeInfo.id, res)
})