diff --git a/src/components/common/status-switch.vue b/src/components/common/status-switch.vue index e4ba711..206aaf9 100644 --- a/src/components/common/status-switch.vue +++ b/src/components/common/status-switch.vue @@ -14,7 +14,7 @@ const props = withDefaults(defineProps(), { }); interface Emits { - (e: 'fetch', value: Api.Common.EnableStatusNumber): void; + (e: 'fetch', value: Api.Common.EnableStatusNumber, callback: () => void): void; } const emit = defineEmits(); @@ -31,8 +31,9 @@ watch( const handleUpdateValue = (value: Api.Common.EnableStatusNumber) => { loading.value = true; - emit('fetch', value); - loading.value = false; + emit('fetch', value, () => { + loading.value = false; + }); }; @@ -40,6 +41,7 @@ const handleUpdateValue = (value: Api.Common.EnableStatusNumber) => { { - const fetchFn = async (jobStatus: Api.Common.EnableStatusNumber) => { + const fetchFn = async (jobStatus: Api.Common.EnableStatusNumber, callback: () => void) => { const { error } = await fetchUpdateJobStatus({ id: row.id!, jobStatus }); if (!error) { row.jobStatus = jobStatus; window.$message?.success($t('common.updateSuccess')); } + callback(); }; return (