diff --git a/src/components/negative/dialog.vue b/src/components/negative/dialog.vue index ff3db5f..e745bf8 100644 --- a/src/components/negative/dialog.vue +++ b/src/components/negative/dialog.vue @@ -512,32 +512,40 @@ const visible = computed({ set: (val) => emit('update:modelValue', val) }); +let detailsRequestId = 0; watch( - () => props.id, - () => { - if (visible.value) { - getDetails(); - verifyEditFlag.value = false; - formData.value = {}; - currentComplaintStage.value = STAGE_COMPLETION; - } - } -); - -// 新增:监听弹窗打开,强制刷新数据 -watch(visible, (newVal) => { - if (newVal) { - getDetails(); + [visible, () => props.id], + ([isVisible, id]) => { verifyEditFlag.value = false; formData.value = {}; currentComplaintStage.value = STAGE_COMPLETION; + if (isVisible && id) { + getDetails(); + } else { + // 关闭时使尚未返回的详情请求失效。 + detailsRequestId++; + components.value = []; + loading.value = false; + } } -}); +); const confirmationCompletionFlag = ref(false); -function getDetails() { +async function getDetails() { + const requestId = ++detailsRequestId; + const negativeId = props.id; loading.value = true; - getNegativeDetails(props.id, work?.value.workId).then((data) => { + components.value = []; + flowActions.value = []; + try { + const data = await getNegativeDetails(negativeId, work?.value.workId); + if ( + requestId !== detailsRequestId || + !visible.value || + negativeId !== props.id + ) { + return; + } negative.value = { ...data.negative, remainingDuration: data.remainingDuration, @@ -560,8 +568,13 @@ function getDetails() { // 是否认定办结 confirmationCompletionFlag.value = data.confirmationCompletionFlag; - loading.value = false; - }); + } catch (error) { + // 请求层负责错误提示;失败时保持办理模块隐藏。 + } finally { + if (requestId === detailsRequestId) { + loading.value = false; + } + } } /** * 获取附件 diff --git a/src/components/negative/verify.vue b/src/components/negative/verify.vue index ac22ef4..d2a73fa 100644 --- a/src/components/negative/verify.vue +++ b/src/components/negative/verify.vue @@ -1665,7 +1665,8 @@ const problemIsTrue = computed(() => { return form.value.checkStatusCode === '1' || form.value.checkStatusCode === '2' || form.value.checkStatusCode === '3'; }); -getFormData(); +// 详情对象更新时重新初始化,避免复用组件时残留上一条核查信息。 +watch(negative, getFormData, { immediate: true }); async function getFormData() { form.value = {