Просмотр исходного кода

fix:提见按钮时间限制加长

张旭伟 5 дней назад
Родитель
Сommit
a8da79105d

+ 2 - 2
src/view/animal/application/components/Application.vue

@@ -584,8 +584,8 @@ const onSubmit = async () => {
   setTimeout(() => {
     closeDialog()
     emit('refresh')
-    submitting.value = false // 2秒后重置提交状态
-  }, 2000)
+    submitting.value = false // 5秒后重置提交状态
+  }, 5000)
 }
 
 watch(

+ 17 - 6
src/view/animal/application/components/ReturnCageDialog.vue

@@ -25,7 +25,7 @@
 		<template #footer>
 			<span class="dialog-footer">
 				<el-button type="info" @click="() => ((showRefundableDialog = false), (refundableId = 0))" size="default">取 消</el-button>
-				<el-button color="#2c78ff" @click="onRefundableSubmit()" size="default">提交</el-button>
+				<el-button color="#2c78ff" @click="onRefundableSubmit()" size="default" :loading="submitting" :disabled="submitting">提交</el-button>
 			</span>
 		</template>
 	</el-dialog>
@@ -50,6 +50,7 @@ const platAnimalCageApplicationApi = usePlatAnimalCageApplicationApi();
 const uploadRef = ref<any>(null);
 const showRefundableDialog = ref<boolean>(false);
 const refundableId = ref<number>(0);
+const submitting = ref<boolean>(false);
 const refundableForm = reactive<{ number: number; endDate: string }>({
 	number: 0,
 	endDate: '',
@@ -66,18 +67,28 @@ const handleOpenRefundableDialog = (id: number) => {
 };
 
 const onRefundableSubmit = () => {
+	submitting.value = true;
 	uploadRef.value?.validate(async (valid: boolean) => {
-		if (!valid) return;
+		if (!valid) {
+			submitting.value = false;
+			return;
+		}
 		const params = {
 			cageApplicationId: refundableId.value,
 			endDate: dayjs(refundableForm.endDate).format('YYYY-MM-DD'),
 			number: refundableForm.number,
 		};
 		const [err]: ToResponse = await to(platAnimalCageApplicationApi.releaseCage(params));
-		if (err) return;
+		if (err) {
+			submitting.value = false;
+			return;
+		}
 		ElMessage.success('操作成功');
-		showRefundableDialog.value = false;
-		emit('getTableData');
+		setTimeout(() => {
+			submitting.value = false;
+			showRefundableDialog.value = false;
+			emit('getTableData');
+		}, 5000);
 	});
 };
 
@@ -90,4 +101,4 @@ watch(showRefundableDialog, (val) => {
 defineExpose({
 	handleOpenRefundableDialog,
 });
-</script>
+</script>

+ 19 - 6
src/view/animal/applicationRemoval/components/addEdit.vue

@@ -275,6 +275,9 @@ const onCancel = () => {
 }
 
 const onSubmit = async () => {
+  // 设置提交状态为加载中
+  state.loading = true
+  
   try {
     await expertDialogFormRef.value?.validate()
   } catch (error: any) {
@@ -295,6 +298,7 @@ const onSubmit = async () => {
       type: 'warning',
       message: errorMessage,
     })
+    state.loading = false // 重置提交状态
     return
   }
 
@@ -303,6 +307,7 @@ const onSubmit = async () => {
       type: 'warning',
       message: '请阅读并勾选安全承诺!',
     })
+    state.loading = false // 重置提交状态
     return
   }
 
@@ -311,10 +316,10 @@ const onSubmit = async () => {
       type: 'warning',
       message: '请添加雄性或雌性数量!',
     })
+    state.loading = false // 重置提交状态
     return
   }
 
-  state.loading = true
   const post = platAnimalCageApplicationApi.createAnimalTakeawayApplications
   const [err]: ToResponse = await to(
     post(
@@ -328,14 +333,22 @@ const onSubmit = async () => {
     ),
   )
 
-  state.loading = false
-  if (err) return
+  if (err) {
+    state.loading = false // 重置提交状态
+    return
+  }
+  
   showToast({
     type: 'success',
     message: '操作成功',
   })
-  closeDialog()
-  emit('refresh')
+  
+  // 接口成功后继续保持加载状态2秒,提供更好的用户体验
+  setTimeout(() => {
+    closeDialog()
+    emit('refresh')
+    state.loading = false // 5秒后重置提交状态
+  }, 5000)
 }
 
 const onCategoryConfirm = ({ selectedOptions }: { selectedOptions: any[] }) => {
@@ -485,4 +498,4 @@ defineExpose({
   top: 16px;
   right: 16px;
 }
-</style>
+</style>

+ 2 - 2
src/view/entry/add.vue

@@ -388,8 +388,8 @@
       setTimeout(() => {
         debounceTimer.value = 0
         router.push('/entry')
-        submitting.value = false // 2秒后重置提交状态
-      }, 2000)
+        submitting.value = false // 5秒后重置提交状态
+      }, 5000)
     }, 500)
   }
   onMounted(async () => {

+ 2 - 2
src/view/instr/appoint.vue

@@ -482,8 +482,8 @@
           }
         })
         debounceTimer.value = 0
-        state.loading = false // 2秒后重置加载状态
-      }, 2000)
+        state.loading = false // 5秒后重置加载状态
+      }, 5000)
     }, 500) // 500ms防抖延迟
   }
   onMounted(() => {