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
|
loading.value = true
|
||||||
const data = await write?.getFormData()
|
const data = await write?.getFormData()
|
||||||
const res = ref({})
|
const res = ref({})
|
||||||
if (actionType.value === 'add') {
|
try {
|
||||||
res.value = await addMenuListApi(data)
|
if (actionType.value === 'add') {
|
||||||
} else if (actionType.value === 'edit') {
|
res.value = await addMenuListApi(data)
|
||||||
res.value = await putMenuListApi(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()
|
data.menu_ids = write?.getTreeCheckedKeys()
|
||||||
const res = ref({})
|
const res = ref({})
|
||||||
if (actionType.value === 'add') {
|
try {
|
||||||
res.value = await addRoleListApi(data)
|
if (actionType.value === 'add') {
|
||||||
} else if (actionType.value === 'edit') {
|
res.value = await addRoleListApi(data)
|
||||||
res.value = await putRoleListApi(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
|
importLoading.value = true
|
||||||
const formData = new FormData()
|
const formData = new FormData()
|
||||||
formData.append('file', importFile.value)
|
formData.append('file', importFile.value)
|
||||||
const res = await postImportUserApi(formData)
|
try {
|
||||||
if (res) {
|
const res = await postImportUserApi(formData)
|
||||||
resultTableData.value.push({
|
if (res) {
|
||||||
filename: importFile.value.name,
|
resultTableData.value.push({
|
||||||
success_number: res.data.success_number,
|
filename: importFile.value.name,
|
||||||
error_number: res.data.error_number,
|
success_number: res.data.success_number,
|
||||||
error_url: res.data.error_url
|
error_number: res.data.error_number,
|
||||||
})
|
error_url: res.data.error_url
|
||||||
successTotalNumber.value += res.data.success_number
|
})
|
||||||
handleDelete()
|
successTotalNumber.value += res.data.success_number
|
||||||
emit('getList')
|
handleDelete()
|
||||||
|
emit('getList')
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
importLoading.value = false
|
||||||
}
|
}
|
||||||
importLoading.value = false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const downloadTemplate = async () => {
|
const downloadTemplate = async () => {
|
||||||
|
@ -24,12 +24,14 @@ const initPassword = async () => {
|
|||||||
if (ids.length <= 0) {
|
if (ids.length <= 0) {
|
||||||
return ElMessage.warning('已全部重置完成,无需重复操作')
|
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
|
loading.value = false
|
||||||
})
|
|
||||||
if (res) {
|
|
||||||
tableData.value = res.data
|
|
||||||
ElMessage.success('重置成功')
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -24,12 +24,14 @@ const initPassword = async () => {
|
|||||||
if (ids.length <= 0) {
|
if (ids.length <= 0) {
|
||||||
return ElMessage.warning('已全部重置完成,无需重复操作')
|
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
|
loading.value = false
|
||||||
})
|
|
||||||
if (res) {
|
|
||||||
tableData.value = res.data
|
|
||||||
ElMessage.success('重置成功')
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -127,23 +127,33 @@ const save = async () => {
|
|||||||
loading.value = false
|
loading.value = false
|
||||||
return ElMessage.error('未获取到数据')
|
return ElMessage.error('未获取到数据')
|
||||||
}
|
}
|
||||||
const res = ref({})
|
try {
|
||||||
if (actionType.value === 'add') {
|
const res = ref({})
|
||||||
res.value = await addUserListApi(data)
|
if (actionType.value === 'add') {
|
||||||
} else if (actionType.value === 'edit') {
|
res.value = await addUserListApi(data)
|
||||||
const user = authStore.getUser
|
if (res.value) {
|
||||||
res.value = await putUserListApi(data)
|
dialogVisible.value = false
|
||||||
if (user.id === data.id && user.telephone !== data.telephone) {
|
getList()
|
||||||
dialogVisible.value = false
|
}
|
||||||
authStore.logout()
|
} else if (actionType.value === 'edit') {
|
||||||
return ElMessage.warning('认证已过期,请您重新登陆!')
|
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
|
loading.value = false
|
||||||
return ElMessage.error('未获取到数据')
|
return ElMessage.error('未获取到数据')
|
||||||
}
|
}
|
||||||
|
const tagsViewStore = useTagsViewStore()
|
||||||
const res = ref({})
|
const res = ref({})
|
||||||
if (actionType.value === 'add') {
|
try {
|
||||||
res.value = await addIssueApi(data)
|
if (actionType.value === 'add') {
|
||||||
} else if (actionType.value === 'edit') {
|
res.value = await addIssueApi(data)
|
||||||
res.value = await putIssueApi(data)
|
if (res.value) {
|
||||||
}
|
// 删除当前标签页,并跳转到列表页
|
||||||
loading.value = false
|
tagsViewStore.delView(unref(currentRoute))
|
||||||
if (res.value) {
|
push('/help/issue')
|
||||||
const tagsViewStore = useTagsViewStore()
|
}
|
||||||
// 删除当前标签页,并跳转到列表页
|
} else if (actionType.value === 'edit') {
|
||||||
tagsViewStore.delView(unref(currentRoute))
|
res.value = await putIssueApi(data)
|
||||||
push('/help/issue')
|
if (res.value) {
|
||||||
|
// 删除当前标签页,并跳转到列表页
|
||||||
|
tagsViewStore.delView(unref(currentRoute))
|
||||||
|
push('/help/issue')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
loading.value = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -117,16 +117,23 @@ const save = async () => {
|
|||||||
loading.value = true
|
loading.value = true
|
||||||
let data = await write?.getFormData()
|
let data = await write?.getFormData()
|
||||||
const res = ref({})
|
const res = ref({})
|
||||||
if (actionType.value === 'add') {
|
try {
|
||||||
res.value = await addIssueCategoryApi(data)
|
if (actionType.value === 'add') {
|
||||||
} else if (actionType.value === 'edit') {
|
res.value = await addIssueCategoryApi(data)
|
||||||
res.value = await putIssueCategoryApi(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({})
|
const res = ref({})
|
||||||
if (actionType.value === 'add') {
|
if (actionType.value === 'add') {
|
||||||
res.value = await addDictDetailsListApi(data)
|
res.value = await addDictDetailsListApi(data)
|
||||||
|
if (res.value) {
|
||||||
|
dialogVisible.value = false
|
||||||
|
getList()
|
||||||
|
}
|
||||||
} else if (actionType.value === 'edit') {
|
} else if (actionType.value === 'edit') {
|
||||||
res.value = await putDictDetailsListApi(data)
|
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('未获取到数据')
|
return ElMessage.error('未获取到数据')
|
||||||
}
|
}
|
||||||
const res = ref({})
|
const res = ref({})
|
||||||
if (actionType.value === 'add') {
|
try {
|
||||||
res.value = await addDictTypeListApi(data)
|
if (actionType.value === 'add') {
|
||||||
} else if (actionType.value === 'edit') {
|
res.value = await addDictTypeListApi(data)
|
||||||
res.value = await putDictTypeListApi(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 () => {
|
const save = async () => {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
const res = await putSystemSettingsApi({ web_agreement: defaultHtml.value })
|
try {
|
||||||
if (res) {
|
const res = ref({})
|
||||||
getData()
|
res.value = await putSystemSettingsApi({ web_agreement: defaultHtml.value })
|
||||||
return ElMessage.success('更新成功')
|
if (res.value) {
|
||||||
|
getData()
|
||||||
|
return ElMessage.success('更新成功')
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
loading.value = false
|
||||||
}
|
}
|
||||||
loading.value = false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const editorConfig = {
|
const editorConfig = {
|
||||||
|
@ -40,12 +40,15 @@ const save = async () => {
|
|||||||
loading.value = false
|
loading.value = false
|
||||||
return ElMessage.error('未获取到数据')
|
return ElMessage.error('未获取到数据')
|
||||||
}
|
}
|
||||||
const res = await putSystemSettingsApi(data)
|
try {
|
||||||
if (res) {
|
const res = await putSystemSettingsApi(data)
|
||||||
getData()
|
if (res) {
|
||||||
return ElMessage.success('更新成功')
|
getData()
|
||||||
|
return ElMessage.success('更新成功')
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
loading.value = false
|
||||||
}
|
}
|
||||||
loading.value = false
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -92,15 +92,18 @@ const save = async () => {
|
|||||||
loading.value = false
|
loading.value = false
|
||||||
return ElMessage.error('未获取到数据')
|
return ElMessage.error('未获取到数据')
|
||||||
}
|
}
|
||||||
const res = await putSystemSettingsApi(data)
|
try {
|
||||||
if (res) {
|
const res = await putSystemSettingsApi(data)
|
||||||
appStore.setTitle(data.web_title || import.meta.env.VITE_APP_TITLE)
|
if (res) {
|
||||||
appStore.setLogoImage(data.web_logo || '/static/system/logo.png')
|
appStore.setTitle(data.web_title || import.meta.env.VITE_APP_TITLE)
|
||||||
appStore.setFooterContent(data.web_copyright || 'Copyright ©2022-present K')
|
appStore.setLogoImage(data.web_logo || '/static/system/logo.png')
|
||||||
appStore.setIcpNumber(data.web_icp_number || '')
|
appStore.setFooterContent(data.web_copyright || 'Copyright ©2022-present K')
|
||||||
return ElMessage.success('更新成功')
|
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 () => {
|
const save = async () => {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
const res = await putSystemSettingsApi({ web_privacy: defaultHtml.value })
|
try {
|
||||||
if (res) {
|
const res = await putSystemSettingsApi({ web_privacy: defaultHtml.value })
|
||||||
getData()
|
if (res) {
|
||||||
return ElMessage.success('更新成功')
|
getData()
|
||||||
|
return ElMessage.success('更新成功')
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
loading.value = false
|
||||||
}
|
}
|
||||||
loading.value = false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const editorConfig = {
|
const editorConfig = {
|
||||||
|
@ -40,12 +40,15 @@ const save = async () => {
|
|||||||
loading.value = false
|
loading.value = false
|
||||||
return ElMessage.error('未获取到数据')
|
return ElMessage.error('未获取到数据')
|
||||||
}
|
}
|
||||||
const res = await putSystemSettingsApi(data)
|
try {
|
||||||
if (res) {
|
const res = await putSystemSettingsApi(data)
|
||||||
getData()
|
if (res) {
|
||||||
return ElMessage.success('更新成功')
|
getData()
|
||||||
|
return ElMessage.success('更新成功')
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
loading.value = false
|
||||||
}
|
}
|
||||||
loading.value = false
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user