perf:前端部分事件增加try, finally,用于取消 loading 状态, 因为使用await 方式,报错 status=5xx,不会执行后面的语句
This commit is contained in:
parent
f5d5de8785
commit
ff0990331c
@ -97,17 +97,24 @@ 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({})
|
||||||
|
try {
|
||||||
if (actionType.value === 'add') {
|
if (actionType.value === 'add') {
|
||||||
res.value = await addMenuListApi(data)
|
res.value = await addMenuListApi(data)
|
||||||
} else if (actionType.value === 'edit') {
|
|
||||||
res.value = await putMenuListApi(data)
|
|
||||||
}
|
|
||||||
if (res.value) {
|
if (res.value) {
|
||||||
dialogVisible.value = false
|
dialogVisible.value = false
|
||||||
getList()
|
getList()
|
||||||
}
|
}
|
||||||
|
} else if (actionType.value === 'edit') {
|
||||||
|
res.value = await putMenuListApi(data)
|
||||||
|
if (res.value) {
|
||||||
|
dialogVisible.value = false
|
||||||
|
getList()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
loading.value = false
|
loading.value = false
|
||||||
}
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,17 +83,24 @@ const save = async () => {
|
|||||||
}
|
}
|
||||||
data.menu_ids = write?.getTreeCheckedKeys()
|
data.menu_ids = write?.getTreeCheckedKeys()
|
||||||
const res = ref({})
|
const res = ref({})
|
||||||
|
try {
|
||||||
if (actionType.value === 'add') {
|
if (actionType.value === 'add') {
|
||||||
res.value = await addRoleListApi(data)
|
res.value = await addRoleListApi(data)
|
||||||
} else if (actionType.value === 'edit') {
|
|
||||||
res.value = await putRoleListApi(data)
|
|
||||||
}
|
|
||||||
if (res.value) {
|
if (res.value) {
|
||||||
dialogVisible.value = false
|
dialogVisible.value = false
|
||||||
getList()
|
getList()
|
||||||
}
|
}
|
||||||
|
} else if (actionType.value === 'edit') {
|
||||||
|
res.value = await putRoleListApi(data)
|
||||||
|
if (res.value) {
|
||||||
|
dialogVisible.value = false
|
||||||
|
getList()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
loading.value = false
|
loading.value = false
|
||||||
}
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,6 +58,7 @@ 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)
|
||||||
|
try {
|
||||||
const res = await postImportUserApi(formData)
|
const res = await postImportUserApi(formData)
|
||||||
if (res) {
|
if (res) {
|
||||||
resultTableData.value.push({
|
resultTableData.value.push({
|
||||||
@ -70,8 +71,10 @@ const handleImport = async () => {
|
|||||||
handleDelete()
|
handleDelete()
|
||||||
emit('getList')
|
emit('getList')
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
importLoading.value = false
|
importLoading.value = false
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const downloadTemplate = async () => {
|
const downloadTemplate = async () => {
|
||||||
const res = await getImportTemplateApi()
|
const res = await getImportTemplateApi()
|
||||||
|
@ -24,13 +24,15 @@ const initPassword = async () => {
|
|||||||
if (ids.length <= 0) {
|
if (ids.length <= 0) {
|
||||||
return ElMessage.warning('已全部重置完成,无需重复操作')
|
return ElMessage.warning('已全部重置完成,无需重复操作')
|
||||||
}
|
}
|
||||||
const res = await postUsersInitPasswordSendEmailApi(ids).finally(() => {
|
try {
|
||||||
loading.value = false
|
const res = await postUsersInitPasswordSendEmailApi(ids)
|
||||||
})
|
|
||||||
if (res) {
|
if (res) {
|
||||||
tableData.value = res.data
|
tableData.value = res.data
|
||||||
ElMessage.success('重置成功')
|
ElMessage.success('重置成功')
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
|
loading.value = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -24,13 +24,15 @@ const initPassword = async () => {
|
|||||||
if (ids.length <= 0) {
|
if (ids.length <= 0) {
|
||||||
return ElMessage.warning('已全部重置完成,无需重复操作')
|
return ElMessage.warning('已全部重置完成,无需重复操作')
|
||||||
}
|
}
|
||||||
const res = await postUsersInitPasswordSendSMSApi(ids).finally(() => {
|
try {
|
||||||
loading.value = false
|
const res = await postUsersInitPasswordSendSMSApi(ids)
|
||||||
})
|
|
||||||
if (res) {
|
if (res) {
|
||||||
tableData.value = res.data
|
tableData.value = res.data
|
||||||
ElMessage.success('重置成功')
|
ElMessage.success('重置成功')
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
|
loading.value = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -127,24 +127,34 @@ const save = async () => {
|
|||||||
loading.value = false
|
loading.value = false
|
||||||
return ElMessage.error('未获取到数据')
|
return ElMessage.error('未获取到数据')
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
const res = ref({})
|
const res = ref({})
|
||||||
if (actionType.value === 'add') {
|
if (actionType.value === 'add') {
|
||||||
res.value = await addUserListApi(data)
|
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('认证已过期,请您重新登陆!')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (res.value) {
|
if (res.value) {
|
||||||
dialogVisible.value = false
|
dialogVisible.value = false
|
||||||
getList()
|
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
|
loading.value = false
|
||||||
}
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,19 +111,27 @@ const save = async () => {
|
|||||||
loading.value = false
|
loading.value = false
|
||||||
return ElMessage.error('未获取到数据')
|
return ElMessage.error('未获取到数据')
|
||||||
}
|
}
|
||||||
|
const tagsViewStore = useTagsViewStore()
|
||||||
const res = ref({})
|
const res = ref({})
|
||||||
|
try {
|
||||||
if (actionType.value === 'add') {
|
if (actionType.value === 'add') {
|
||||||
res.value = await addIssueApi(data)
|
res.value = await addIssueApi(data)
|
||||||
} else if (actionType.value === 'edit') {
|
|
||||||
res.value = await putIssueApi(data)
|
|
||||||
}
|
|
||||||
loading.value = false
|
|
||||||
if (res.value) {
|
if (res.value) {
|
||||||
const tagsViewStore = useTagsViewStore()
|
|
||||||
// 删除当前标签页,并跳转到列表页
|
// 删除当前标签页,并跳转到列表页
|
||||||
tagsViewStore.delView(unref(currentRoute))
|
tagsViewStore.delView(unref(currentRoute))
|
||||||
push('/help/issue')
|
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,17 +117,24 @@ 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({})
|
||||||
|
try {
|
||||||
if (actionType.value === 'add') {
|
if (actionType.value === 'add') {
|
||||||
res.value = await addIssueCategoryApi(data)
|
res.value = await addIssueCategoryApi(data)
|
||||||
} else if (actionType.value === 'edit') {
|
|
||||||
res.value = await putIssueCategoryApi(data)
|
|
||||||
}
|
|
||||||
if (res.value) {
|
if (res.value) {
|
||||||
dialogVisible.value = false
|
dialogVisible.value = false
|
||||||
getList()
|
getList()
|
||||||
}
|
}
|
||||||
|
} else if (actionType.value === 'edit') {
|
||||||
|
res.value = await putIssueCategoryApi(data)
|
||||||
|
if (res.value) {
|
||||||
|
dialogVisible.value = false
|
||||||
|
getList()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
loading.value = false
|
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)
|
||||||
} else if (actionType.value === 'edit') {
|
|
||||||
res.value = await putDictDetailsListApi(data)
|
|
||||||
}
|
|
||||||
if (res.value) {
|
if (res.value) {
|
||||||
dialogVisible.value = false
|
dialogVisible.value = false
|
||||||
getList()
|
getList()
|
||||||
}
|
}
|
||||||
loading.value = false
|
} else if (actionType.value === 'edit') {
|
||||||
|
res.value = await putDictDetailsListApi(data)
|
||||||
|
if (res.value) {
|
||||||
|
dialogVisible.value = false
|
||||||
|
getList()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -93,17 +93,24 @@ const save = async () => {
|
|||||||
return ElMessage.error('未获取到数据')
|
return ElMessage.error('未获取到数据')
|
||||||
}
|
}
|
||||||
const res = ref({})
|
const res = ref({})
|
||||||
|
try {
|
||||||
if (actionType.value === 'add') {
|
if (actionType.value === 'add') {
|
||||||
res.value = await addDictTypeListApi(data)
|
res.value = await addDictTypeListApi(data)
|
||||||
} else if (actionType.value === 'edit') {
|
|
||||||
res.value = await putDictTypeListApi(data)
|
|
||||||
}
|
|
||||||
if (res.value) {
|
if (res.value) {
|
||||||
dialogVisible.value = false
|
dialogVisible.value = false
|
||||||
getList()
|
getList()
|
||||||
}
|
}
|
||||||
|
} else if (actionType.value === 'edit') {
|
||||||
|
res.value = await putDictTypeListApi(data)
|
||||||
|
if (res.value) {
|
||||||
|
dialogVisible.value = false
|
||||||
|
getList()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
loading.value = false
|
loading.value = false
|
||||||
}
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,13 +25,17 @@ 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({})
|
||||||
|
res.value = await putSystemSettingsApi({ web_agreement: defaultHtml.value })
|
||||||
|
if (res.value) {
|
||||||
getData()
|
getData()
|
||||||
return ElMessage.success('更新成功')
|
return ElMessage.success('更新成功')
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
loading.value = false
|
loading.value = false
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const editorConfig = {
|
const editorConfig = {
|
||||||
customAlert: (s: string, t: string) => {
|
customAlert: (s: string, t: string) => {
|
||||||
|
@ -40,13 +40,16 @@ const save = async () => {
|
|||||||
loading.value = false
|
loading.value = false
|
||||||
return ElMessage.error('未获取到数据')
|
return ElMessage.error('未获取到数据')
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
const res = await putSystemSettingsApi(data)
|
const res = await putSystemSettingsApi(data)
|
||||||
if (res) {
|
if (res) {
|
||||||
getData()
|
getData()
|
||||||
return ElMessage.success('更新成功')
|
return ElMessage.success('更新成功')
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
loading.value = false
|
loading.value = false
|
||||||
}
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,6 +92,7 @@ const save = async () => {
|
|||||||
loading.value = false
|
loading.value = false
|
||||||
return ElMessage.error('未获取到数据')
|
return ElMessage.error('未获取到数据')
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
const res = await putSystemSettingsApi(data)
|
const res = await putSystemSettingsApi(data)
|
||||||
if (res) {
|
if (res) {
|
||||||
appStore.setTitle(data.web_title || import.meta.env.VITE_APP_TITLE)
|
appStore.setTitle(data.web_title || import.meta.env.VITE_APP_TITLE)
|
||||||
@ -100,8 +101,10 @@ const save = async () => {
|
|||||||
appStore.setIcpNumber(data.web_icp_number || '')
|
appStore.setIcpNumber(data.web_icp_number || '')
|
||||||
return ElMessage.success('更新成功')
|
return ElMessage.success('更新成功')
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
loading.value = false
|
loading.value = false
|
||||||
}
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,13 +25,16 @@ const loading = ref(false)
|
|||||||
|
|
||||||
const save = async () => {
|
const save = async () => {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
|
try {
|
||||||
const res = await putSystemSettingsApi({ web_privacy: defaultHtml.value })
|
const res = await putSystemSettingsApi({ web_privacy: defaultHtml.value })
|
||||||
if (res) {
|
if (res) {
|
||||||
getData()
|
getData()
|
||||||
return ElMessage.success('更新成功')
|
return ElMessage.success('更新成功')
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
loading.value = false
|
loading.value = false
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const editorConfig = {
|
const editorConfig = {
|
||||||
customAlert: (s: string, t: string) => {
|
customAlert: (s: string, t: string) => {
|
||||||
|
@ -40,13 +40,16 @@ const save = async () => {
|
|||||||
loading.value = false
|
loading.value = false
|
||||||
return ElMessage.error('未获取到数据')
|
return ElMessage.error('未获取到数据')
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
const res = await putSystemSettingsApi(data)
|
const res = await putSystemSettingsApi(data)
|
||||||
if (res) {
|
if (res) {
|
||||||
getData()
|
getData()
|
||||||
return ElMessage.success('更新成功')
|
return ElMessage.success('更新成功')
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
loading.value = false
|
loading.value = false
|
||||||
}
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user