Commit 680eaf2fdb8e885880cc6a1b53e4823a0dc9149f
1 parent
2dbb8146
fix: DEFECT-939 validate form faild loading button has been spinning
Showing
2 changed files
with
12 additions
and
25 deletions
| @@ -117,15 +117,16 @@ const transform: AxiosTransform = { | @@ -117,15 +117,16 @@ const transform: AxiosTransform = { | ||
| 117 | const errorLogStore = useErrorLogStoreWithOut(); | 117 | const errorLogStore = useErrorLogStoreWithOut(); |
| 118 | errorLogStore.addAjaxErrorInfo(error); | 118 | errorLogStore.addAjaxErrorInfo(error); |
| 119 | const { response, code, message, config } = error || {}; | 119 | const { response, code, message, config } = error || {}; |
| 120 | + | ||
| 120 | const errorMessageMode = config?.requestOptions?.errorMessageMode || 'none'; | 121 | const errorMessageMode = config?.requestOptions?.errorMessageMode || 'none'; |
| 121 | - const errorMsgIsObj = typeof response.data === 'object'; | 122 | + const errorMsgIsObj = typeof response?.data === 'object'; |
| 122 | const msg: string = errorMsgIsObj | 123 | const msg: string = errorMsgIsObj |
| 123 | ? response?.data?.message || response?.data?.msg | 124 | ? response?.data?.message || response?.data?.msg |
| 124 | - : response.data; | 125 | + : response?.data; |
| 125 | const err: string = error?.toString?.() ?? ''; | 126 | const err: string = error?.toString?.() ?? ''; |
| 126 | let errMessage = ''; | 127 | let errMessage = ''; |
| 127 | try { | 128 | try { |
| 128 | - if (response.data.status == '401' || response.data.message == '"Authentication failed"') { | 129 | + if (response?.data?.status == '401' || response?.data?.message == '"Authentication failed"') { |
| 129 | window.localStorage.clear(); | 130 | window.localStorage.clear(); |
| 130 | window.sessionStorage.clear(); | 131 | window.sessionStorage.clear(); |
| 131 | router.push(PageEnum.BASE_HOME); | 132 | router.push(PageEnum.BASE_HOME); |
| @@ -40,7 +40,6 @@ | @@ -40,7 +40,6 @@ | ||
| 40 | import { FileItem } from '/@/components/Upload/src/typing'; | 40 | import { FileItem } from '/@/components/Upload/src/typing'; |
| 41 | import { upload } from '/@/api/oss/ossFileUploader'; | 41 | import { upload } from '/@/api/oss/ossFileUploader'; |
| 42 | import { getTenantRoles, updateOrCreateTenant } from '/@/api/tenant/tenantApi'; | 42 | import { getTenantRoles, updateOrCreateTenant } from '/@/api/tenant/tenantApi'; |
| 43 | - import { useMessage } from '/@/hooks/web/useMessage'; | ||
| 44 | export default defineComponent({ | 43 | export default defineComponent({ |
| 45 | name: 'TenantDrawer', | 44 | name: 'TenantDrawer', |
| 46 | components: { | 45 | components: { |
| @@ -140,29 +139,16 @@ | @@ -140,29 +139,16 @@ | ||
| 140 | entityType: 'TENANT_PROFILE', | 139 | entityType: 'TENANT_PROFILE', |
| 141 | }, | 140 | }, |
| 142 | }; | 141 | }; |
| 143 | - updateOrCreateTenant(req) | ||
| 144 | - .then((res) => { | ||
| 145 | - console.log(res); | ||
| 146 | - closeDrawer(); //关闭侧框 | ||
| 147 | - emit('success'); | ||
| 148 | - setTimeout(() => { | ||
| 149 | - setDrawerProps({ confirmLoading: false }); | ||
| 150 | - }, 300); | ||
| 151 | - }) | ||
| 152 | - .catch((e) => { | ||
| 153 | - const { createMessage } = useMessage(); | ||
| 154 | - createMessage.error(`${e.message}`); | ||
| 155 | - }) | ||
| 156 | - .finally(() => { | ||
| 157 | - setTimeout(() => { | ||
| 158 | - setDrawerProps({ confirmLoading: false }); | ||
| 159 | - }, 300); | ||
| 160 | - }); | 142 | + await updateOrCreateTenant(req); |
| 143 | + emit('success'); | ||
| 144 | + closeDrawer(); //关闭侧框 | ||
| 161 | } catch (e) { | 145 | } catch (e) { |
| 146 | + if ((e as { code: string }).code === 'ECONNABORTED') { | ||
| 147 | + emit('success'); | ||
| 148 | + closeDrawer(); //关闭侧框 | ||
| 149 | + } | ||
| 162 | } finally { | 150 | } finally { |
| 163 | - setTimeout(() => { | ||
| 164 | - setDrawerProps({ confirmLoading: false }); | ||
| 165 | - }, 300); | 151 | + setDrawerProps({ confirmLoading: false }); |
| 166 | } | 152 | } |
| 167 | } | 153 | } |
| 168 | return { | 154 | return { |