[update 解读流程] 多行报错,br换行
This commit is contained in:
+34
-1
@@ -659,7 +659,12 @@ export default {
|
|||||||
this.$message.success(res.message)
|
this.$message.success(res.message)
|
||||||
this.goBack()
|
this.goBack()
|
||||||
} else {
|
} else {
|
||||||
this.$message.warn(res.message)
|
// 多行报错
|
||||||
|
if (res.code === 500) {
|
||||||
|
this.messageLineFeedByBr(this.$t('operationFailed'), res.message)
|
||||||
|
} else {
|
||||||
|
this.$message.warn(res.message)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}).catch((err) => {
|
}).catch((err) => {
|
||||||
if (err && err.message && tabList.includes(err.message)) {
|
if (err && err.message && tabList.includes(err.message)) {
|
||||||
@@ -770,6 +775,34 @@ export default {
|
|||||||
return Promise.all(promiseList).catch(() => {
|
return Promise.all(promiseList).catch(() => {
|
||||||
throw new Error('base')
|
throw new Error('base')
|
||||||
})
|
})
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 对包含<br/>的后端错误信息进行处理
|
||||||
|
* @param title
|
||||||
|
* @param content
|
||||||
|
*/
|
||||||
|
messageLineFeedByBr (title, content) {
|
||||||
|
// 可以用分号和<br> </br> <br/>换行
|
||||||
|
content = content.replace(/<br>|<\/br>|<br\/>/g, ';')
|
||||||
|
const messageArr = content.split(';')
|
||||||
|
const htmlDom = []
|
||||||
|
messageArr.map(tt => {
|
||||||
|
if (tt) {
|
||||||
|
htmlDom.push((<div>{tt}</div>))
|
||||||
|
}
|
||||||
|
})
|
||||||
|
this.$warning({
|
||||||
|
title: title,
|
||||||
|
closable: true,
|
||||||
|
width: 800,
|
||||||
|
content: () => <div>
|
||||||
|
{htmlDom}
|
||||||
|
</div>
|
||||||
|
})
|
||||||
|
this.$nextTick(() => {
|
||||||
|
document.getElementsByClassName('ant-modal-confirm-btns')[0].style = 'display: inline-block'
|
||||||
|
document.getElementsByClassName('ant-modal-confirm-content')[0].style = 'max-height: calc(100vh - 300px);overflow-y: auto;'
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user