perf:前端部分事件增加try, finally,用于取消 loading 状态, 因为使用await 方式,报错 status=5xx,不会执行后面的语句
This commit is contained in:
parent
f5d5de8785
commit
ff0990331c
@ -97,16 +97,23 @@ const save = async () => {
|
||||
loading.value = true
|
||||
const data = await write?.getFormData()
|
||||
const res = ref({})
|
||||
if (actionType.value === 'add') {
|
||||
res.value = await addMenuListApi(data)
|
||||
} else if (actionType.value === 'edit') {
|
||||
res.value = await putMenuListApi(data)
|
||||
try {
|
||||
if (actionType.value === 'add') {
|
||||
res.value = await addMenuListApi(data)
|
||||
if (res.value) {
|
||||
dialogVisible.value = false
|
||||
getList()
|
||||
}
|
||||
} else if (actionType.value === 'edit') {
|
||||
res.value = await putMenuListApi(data)
|
||||
if (res.value) {
|
||||
dialogVisible.value = false
|
||||
getList()
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
if (res.value) {
|
||||
dialogVisible.value = false
|
||||
getList()
|
||||
}
|
||||
loading.value = false
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -83,16 +83,23 @@ const save = async () => {
|
||||
}
|
||||
data.menu_ids = write?.getTreeCheckedKeys()
|
||||
const res = ref({})
|
||||
if (actionType.value === 'add') {
|
||||
res.value = await addRoleListApi(data)
|
||||
} else if (actionType.value === 'edit') {
|
||||
res.value = await putRoleListApi(data)
|
||||
try {
|
||||
if (actionType.value === 'add') {
|
||||
res.value = await addRoleListApi(data)
|
||||
if (res.value) {
|
||||
dialogVisible.value = false
|
||||
getList()
|
||||
}
|
||||
} else if (actionType.value === 'edit') {
|
||||
res.value = await putRoleListApi(data)
|
||||
if (res.value) {
|
||||
dialogVisible.value = false
|
||||
getList()
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
if (res.value) {
|
||||
dialogVisible.value = false
|
||||
getList()
|
||||
}
|
||||
loading.value = false
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -58,19 +58,22 @@ const handleImport = async () => {
|
||||
importLoading.value = true
|
||||
const formData = new FormData()
|
||||
formData.append('file', importFile.value)
|
||||
const res = await postImportUserApi(formData)
|
||||
if (res) {
|
||||
resultTableData.value.push({
|
||||
filename: importFile.value.name,
|
||||
success_number: res.data.success_number,
|
||||
error_number: res.data.error_number,
|
||||
error_url: res.data.error_url
|
||||
})
|
||||
successTotalNumber.value += res.data.success_number
|
||||
handleDelete()
|
||||
emit('getList')
|
||||
try {
|
||||
const res = await postImportUserApi(formData)
|
||||
if (res) {
|
||||
resultTableData.value.push({
|
||||
filename: importFile.value.name,
|
||||
success_number: res.data.success_number,
|
||||
error_number: res.data.error_number,
|
||||
error_url: res.data.error_url
|
||||
})
|
||||
successTotalNumber.value += res.data.success_number
|
||||
handleDelete()
|
||||
emit('getList')
|
||||
}
|
||||
} finally {
|
||||
importLoading.value = false
|
||||
}
|
||||
importLoading.value = false
|
||||
}
|
||||
|
||||
const downloadTemplate = async () => {
|
||||
|
@ -24,12 +24,14 @@ const initPassword = async () => {
|
||||
if (ids.length <= 0) {
|
||||
return ElMessage.warning('已全部重置完成,无需重复操作')
|
||||
}
|
||||
const res = await postUsersInitPasswordSendEmailApi(ids).finally(() => {
|
||||
try {
|
||||
const res = await postUsersInitPasswordSendEmailApi(ids)
|
||||
if (res) {
|
||||
tableData.value = res.data
|
||||
ElMessage.success('重置成功')
|
||||
}
|
||||
} finally {
|
||||
loading.value = false
|
||||
})
|
||||
if (res) {
|
||||
tableData.value = res.data
|
||||
ElMessage.success('重置成功')
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
@ -24,12 +24,14 @@ const initPassword = async () => {
|
||||
if (ids.length <= 0) {
|
||||
return ElMessage.warning('已全部重置完成,无需重复操作')
|
||||
}
|
||||
const res = await postUsersInitPasswordSendSMSApi(ids).finally(() => {
|
||||
try {
|
||||
const res = await postUsersInitPasswordSendSMSApi(ids)
|
||||
if (res) {
|
||||
tableData.value = res.data
|
||||
ElMessage.success('重置成功')
|
||||
}
|
||||
} finally {
|
||||
loading.value = false
|
||||
})
|
||||
if (res) {
|
||||
tableData.value = res.data
|
||||
ElMessage.success('重置成功')
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
@ -127,23 +127,33 @@ const save = async () => {
|
||||
loading.value = false
|
||||
return ElMessage.error('未获取到数据')
|
||||
}
|
||||
const res = ref({})
|
||||
if (actionType.value === 'add') {
|
||||
res.value = await addUserListApi(data)
|
||||
} else if (actionType.value === 'edit') {
|
||||
const user = authStore.getUser
|
||||
res.value = await putUserListApi(data)
|
||||
if (user.id === data.id && user.telephone !== data.telephone) {
|
||||
dialogVisible.value = false
|
||||
authStore.logout()
|
||||
return ElMessage.warning('认证已过期,请您重新登陆!')
|
||||
try {
|
||||
const res = ref({})
|
||||
if (actionType.value === 'add') {
|
||||
res.value = await addUserListApi(data)
|
||||
if (res.value) {
|
||||
dialogVisible.value = false
|
||||
getList()
|
||||
}
|
||||
} else if (actionType.value === 'edit') {
|
||||
const user = authStore.getUser
|
||||
const userId = data.id
|
||||
const userTelephone = data.telephone
|
||||
res.value = await putUserListApi(data)
|
||||
if (res.value) {
|
||||
dialogVisible.value = false
|
||||
if (user.id === userId && user.telephone !== userTelephone) {
|
||||
dialogVisible.value = false
|
||||
authStore.logout()
|
||||
return ElMessage.warning('认证已过期,请您重新登陆!')
|
||||
} else {
|
||||
getList()
|
||||
}
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
if (res.value) {
|
||||
dialogVisible.value = false
|
||||
getList()
|
||||
}
|
||||
loading.value = false
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -111,18 +111,26 @@ const save = async () => {
|
||||
loading.value = false
|
||||
return ElMessage.error('未获取到数据')
|
||||
}
|
||||
const tagsViewStore = useTagsViewStore()
|
||||
const res = ref({})
|
||||
if (actionType.value === 'add') {
|
||||
res.value = await addIssueApi(data)
|
||||
} else if (actionType.value === 'edit') {
|
||||
res.value = await putIssueApi(data)
|
||||
}
|
||||
loading.value = false
|
||||
if (res.value) {
|
||||
const tagsViewStore = useTagsViewStore()
|
||||
// 删除当前标签页,并跳转到列表页
|
||||
tagsViewStore.delView(unref(currentRoute))
|
||||
push('/help/issue')
|
||||
try {
|
||||
if (actionType.value === 'add') {
|
||||
res.value = await addIssueApi(data)
|
||||
if (res.value) {
|
||||
// 删除当前标签页,并跳转到列表页
|
||||
tagsViewStore.delView(unref(currentRoute))
|
||||
push('/help/issue')
|
||||
}
|
||||
} else if (actionType.value === 'edit') {
|
||||
res.value = await putIssueApi(data)
|
||||
if (res.value) {
|
||||
// 删除当前标签页,并跳转到列表页
|
||||
tagsViewStore.delView(unref(currentRoute))
|
||||
push('/help/issue')
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
})
|
||||
|
@ -117,16 +117,23 @@ const save = async () => {
|
||||
loading.value = true
|
||||
let data = await write?.getFormData()
|
||||
const res = ref({})
|
||||
if (actionType.value === 'add') {
|
||||
res.value = await addIssueCategoryApi(data)
|
||||
} else if (actionType.value === 'edit') {
|
||||
res.value = await putIssueCategoryApi(data)
|
||||
try {
|
||||
if (actionType.value === 'add') {
|
||||
res.value = await addIssueCategoryApi(data)
|
||||
if (res.value) {
|
||||
dialogVisible.value = false
|
||||
getList()
|
||||
}
|
||||
} else if (actionType.value === 'edit') {
|
||||
res.value = await putIssueCategoryApi(data)
|
||||
if (res.value) {
|
||||
dialogVisible.value = false
|
||||
getList()
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
if (res.value) {
|
||||
dialogVisible.value = false
|
||||
getList()
|
||||
}
|
||||
loading.value = false
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -109,14 +109,17 @@ const save = async () => {
|
||||
const res = ref({})
|
||||
if (actionType.value === 'add') {
|
||||
res.value = await addDictDetailsListApi(data)
|
||||
if (res.value) {
|
||||
dialogVisible.value = false
|
||||
getList()
|
||||
}
|
||||
} else if (actionType.value === 'edit') {
|
||||
res.value = await putDictDetailsListApi(data)
|
||||
if (res.value) {
|
||||
dialogVisible.value = false
|
||||
getList()
|
||||
}
|
||||
}
|
||||
if (res.value) {
|
||||
dialogVisible.value = false
|
||||
getList()
|
||||
}
|
||||
loading.value = false
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -93,16 +93,23 @@ const save = async () => {
|
||||
return ElMessage.error('未获取到数据')
|
||||
}
|
||||
const res = ref({})
|
||||
if (actionType.value === 'add') {
|
||||
res.value = await addDictTypeListApi(data)
|
||||
} else if (actionType.value === 'edit') {
|
||||
res.value = await putDictTypeListApi(data)
|
||||
try {
|
||||
if (actionType.value === 'add') {
|
||||
res.value = await addDictTypeListApi(data)
|
||||
if (res.value) {
|
||||
dialogVisible.value = false
|
||||
getList()
|
||||
}
|
||||
} else if (actionType.value === 'edit') {
|
||||
res.value = await putDictTypeListApi(data)
|
||||
if (res.value) {
|
||||
dialogVisible.value = false
|
||||
getList()
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
if (res.value) {
|
||||
dialogVisible.value = false
|
||||
getList()
|
||||
}
|
||||
loading.value = false
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -25,12 +25,16 @@ const loading = ref(false)
|
||||
|
||||
const save = async () => {
|
||||
loading.value = true
|
||||
const res = await putSystemSettingsApi({ web_agreement: defaultHtml.value })
|
||||
if (res) {
|
||||
getData()
|
||||
return ElMessage.success('更新成功')
|
||||
try {
|
||||
const res = ref({})
|
||||
res.value = await putSystemSettingsApi({ web_agreement: defaultHtml.value })
|
||||
if (res.value) {
|
||||
getData()
|
||||
return ElMessage.success('更新成功')
|
||||
}
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
loading.value = false
|
||||
}
|
||||
|
||||
const editorConfig = {
|
||||
|
@ -40,12 +40,15 @@ const save = async () => {
|
||||
loading.value = false
|
||||
return ElMessage.error('未获取到数据')
|
||||
}
|
||||
const res = await putSystemSettingsApi(data)
|
||||
if (res) {
|
||||
getData()
|
||||
return ElMessage.success('更新成功')
|
||||
try {
|
||||
const res = await putSystemSettingsApi(data)
|
||||
if (res) {
|
||||
getData()
|
||||
return ElMessage.success('更新成功')
|
||||
}
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
loading.value = false
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -92,15 +92,18 @@ const save = async () => {
|
||||
loading.value = false
|
||||
return ElMessage.error('未获取到数据')
|
||||
}
|
||||
const res = await putSystemSettingsApi(data)
|
||||
if (res) {
|
||||
appStore.setTitle(data.web_title || import.meta.env.VITE_APP_TITLE)
|
||||
appStore.setLogoImage(data.web_logo || '/static/system/logo.png')
|
||||
appStore.setFooterContent(data.web_copyright || 'Copyright ©2022-present K')
|
||||
appStore.setIcpNumber(data.web_icp_number || '')
|
||||
return ElMessage.success('更新成功')
|
||||
try {
|
||||
const res = await putSystemSettingsApi(data)
|
||||
if (res) {
|
||||
appStore.setTitle(data.web_title || import.meta.env.VITE_APP_TITLE)
|
||||
appStore.setLogoImage(data.web_logo || '/static/system/logo.png')
|
||||
appStore.setFooterContent(data.web_copyright || 'Copyright ©2022-present K')
|
||||
appStore.setIcpNumber(data.web_icp_number || '')
|
||||
return ElMessage.success('更新成功')
|
||||
}
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
loading.value = false
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -25,12 +25,15 @@ const loading = ref(false)
|
||||
|
||||
const save = async () => {
|
||||
loading.value = true
|
||||
const res = await putSystemSettingsApi({ web_privacy: defaultHtml.value })
|
||||
if (res) {
|
||||
getData()
|
||||
return ElMessage.success('更新成功')
|
||||
try {
|
||||
const res = await putSystemSettingsApi({ web_privacy: defaultHtml.value })
|
||||
if (res) {
|
||||
getData()
|
||||
return ElMessage.success('更新成功')
|
||||
}
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
loading.value = false
|
||||
}
|
||||
|
||||
const editorConfig = {
|
||||
|
@ -40,12 +40,15 @@ const save = async () => {
|
||||
loading.value = false
|
||||
return ElMessage.error('未获取到数据')
|
||||
}
|
||||
const res = await putSystemSettingsApi(data)
|
||||
if (res) {
|
||||
getData()
|
||||
return ElMessage.success('更新成功')
|
||||
try {
|
||||
const res = await putSystemSettingsApi(data)
|
||||
if (res) {
|
||||
getData()
|
||||
return ElMessage.success('更新成功')
|
||||
}
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
loading.value = false
|
||||
}
|
||||
})
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user