diff --git a/frontend/src/views/workbench/homePage/components/apiAndScenarioCase.vue b/frontend/src/views/workbench/homePage/components/apiAndScenarioCase.vue index 0b1735f18d..b743dbc7f3 100644 --- a/frontend/src/views/workbench/homePage/components/apiAndScenarioCase.vue +++ b/frontend/src/views/workbench/homePage/components/apiAndScenarioCase.vue @@ -296,16 +296,15 @@ } function changeProject() { - nextTick(async () => { - await initApiOrScenarioCount(); + nextTick(() => { emit('change'); - if (hasPermission.value) { - initApiCountRate(); - } }); } + const isInit = ref(true); + onMounted(() => { + isInit.value = false; initApiOrScenarioCount(); }); @@ -330,13 +329,14 @@ ); watch( - () => innerProjectIds.value, + () => props.item.projectIds, (val) => { if (val) { const [newProjectId] = val; projectId.value = newProjectId; } - } + }, + { immediate: true } ); watch( @@ -360,14 +360,13 @@ } ); - watch( - () => props.refreshKey, - (val) => { - if (val) { - initApiOrScenarioCount(); - } + watch([() => props.refreshKey, () => projectId.value], async () => { + await nextTick(); + await initApiOrScenarioCount(); + if (hasPermission.value && !isInit.value) { + initApiCountRate(); } - ); + }); diff --git a/frontend/src/views/workbench/homePage/components/apiCount.vue b/frontend/src/views/workbench/homePage/components/apiCount.vue index 5c4ae83720..886b06296a 100644 --- a/frontend/src/views/workbench/homePage/components/apiCount.vue +++ b/frontend/src/views/workbench/homePage/components/apiCount.vue @@ -192,15 +192,13 @@ function changeProject() { nextTick(async () => { - await initApiCount(); emit('change'); - if (hasPermission.value) { - initApiCountRate(); - } }); } + const isInit = ref(true); onMounted(() => { + isInit.value = false; initApiCount(); emit('change'); }); @@ -235,13 +233,14 @@ ); watch( - () => innerProjectIds.value, + () => props.item.projectIds, (val) => { if (val) { const [newProjectId] = val; projectId.value = newProjectId; } - } + }, + { immediate: true } ); watch( @@ -265,14 +264,13 @@ } ); - watch( - () => props.refreshKey, - (val) => { - if (val) { - initApiCount(); - } + watch([() => props.refreshKey, () => projectId.value], async () => { + await nextTick(); + await initApiCount(); + if (hasPermission.value && !isInit.value) { + initApiCountRate(); } - ); + }); diff --git a/frontend/src/views/workbench/homePage/components/caseReviewedCount.vue b/frontend/src/views/workbench/homePage/components/caseReviewedCount.vue index 2f5f321215..e4ca55214d 100644 --- a/frontend/src/views/workbench/homePage/components/caseReviewedCount.vue +++ b/frontend/src/views/workbench/homePage/components/caseReviewedCount.vue @@ -135,7 +135,6 @@ function changeProject() { nextTick(() => { - initReviewCount(); emit('change'); }); } @@ -145,13 +144,14 @@ }); watch( - () => innerProjectIds.value, + () => props.item.projectIds, (val) => { if (val) { const [newProjectId] = val; projectId.value = newProjectId; } - } + }, + { immediate: true } ); watch( @@ -175,14 +175,10 @@ } ); - watch( - () => props.refreshKey, - (val) => { - if (val) { - initReviewCount(); - } - } - ); + watch([() => props.refreshKey, () => projectId.value], async () => { + await nextTick(); + initReviewCount(); + }); diff --git a/frontend/src/views/workbench/homePage/components/defectCount.vue b/frontend/src/views/workbench/homePage/components/defectCount.vue index 80c9ed507a..11aea89a55 100644 --- a/frontend/src/views/workbench/homePage/components/defectCount.vue +++ b/frontend/src/views/workbench/homePage/components/defectCount.vue @@ -168,7 +168,6 @@ function changeProject() { nextTick(() => { - initCount(); emit('change'); }); } @@ -178,14 +177,14 @@ }); watch( - () => innerProjectIds.value, + () => props.item.projectIds, (val) => { - const [newProjectId] = val; - projectId.value = newProjectId; + if (val) { + const [newProjectId] = val; + projectId.value = newProjectId; + } }, - { - immediate: true, - } + { immediate: true } ); watch( @@ -210,14 +209,10 @@ } ); - watch( - () => props.refreshKey, - (val) => { - if (val) { - initCount(); - } - } - ); + watch([() => props.refreshKey, () => projectId.value], async () => { + await nextTick(); + initCount(); + }); diff --git a/frontend/src/views/workbench/homePage/components/defectMemberBar.vue b/frontend/src/views/workbench/homePage/components/defectMemberBar.vue index 1a0da7b877..092d367d21 100644 --- a/frontend/src/views/workbench/homePage/components/defectMemberBar.vue +++ b/frontend/src/views/workbench/homePage/components/defectMemberBar.vue @@ -80,8 +80,6 @@ required: true, }); - const memberIds = ref(innerHandleUsers.value); - const timeForm = inject>( 'timeForm', ref({ @@ -179,10 +177,8 @@ } function changeProject() { - memberIds.value = []; + innerHandleUsers.value = []; nextTick(() => { - getMemberOptions(); - getDefectMemberDetail(); emit('change'); }); } @@ -195,13 +191,14 @@ } watch( - () => innerProjectIds.value, + () => props.item.projectIds, (val) => { if (val) { const [newProjectId] = val; projectId.value = newProjectId; } - } + }, + { immediate: true } ); watch( @@ -225,15 +222,11 @@ } ); - watch( - () => props.refreshKey, - (val) => { - if (val) { - getMemberOptions(); - getDefectMemberDetail(); - } - } - ); + watch([() => props.refreshKey, () => projectId.value], async () => { + await nextTick(); + getMemberOptions(); + getDefectMemberDetail(); + }); onMounted(() => { getMemberOptions(); diff --git a/frontend/src/views/workbench/homePage/components/overview.vue b/frontend/src/views/workbench/homePage/components/overview.vue index c487d0347f..8114cc3562 100644 --- a/frontend/src/views/workbench/homePage/components/overview.vue +++ b/frontend/src/views/workbench/homePage/components/overview.vue @@ -223,7 +223,6 @@ function changeProject() { if (isInit.value) return; nextTick(() => { - initOverViewDetail(); emit('change'); }); } @@ -260,6 +259,11 @@ } } ); + + watch([() => props.refreshKey, () => innerProjectIds.value], async () => { + await nextTick(); + initOverViewDetail(); + }); diff --git a/frontend/src/views/workbench/homePage/components/relatedCaseCount.vue b/frontend/src/views/workbench/homePage/components/relatedCaseCount.vue index a419e62ada..f0c9e00d6e 100644 --- a/frontend/src/views/workbench/homePage/components/relatedCaseCount.vue +++ b/frontend/src/views/workbench/homePage/components/relatedCaseCount.vue @@ -128,7 +128,6 @@ function changeProject() { nextTick(() => { - getRelatedCaseCount(); emit('change'); }); } @@ -168,14 +167,12 @@ } ); - watch( - () => props.refreshKey, - (val) => { - if (val) { - getRelatedCaseCount(); - } + watch([() => props.refreshKey, () => projectId.value], async ([refreshKey]) => { + if (refreshKey) { + await nextTick(); + getRelatedCaseCount(); } - ); + }); diff --git a/frontend/src/views/workbench/homePage/components/testPlanCount.vue b/frontend/src/views/workbench/homePage/components/testPlanCount.vue index f866b38870..d82b8ea32b 100644 --- a/frontend/src/views/workbench/homePage/components/testPlanCount.vue +++ b/frontend/src/views/workbench/homePage/components/testPlanCount.vue @@ -250,7 +250,6 @@ function changeProject() { nextTick(() => { - initTestPlanCount(); emit('change'); }); } @@ -265,17 +264,19 @@ if (val) { innerProjectIds.value = [val]; } - } + }, + { immediate: true } ); watch( - () => innerProjectIds.value, + () => props.item.projectIds, (val) => { if (val) { const [newProjectId] = val; projectId.value = newProjectId; } - } + }, + { immediate: true } ); watch( @@ -290,14 +291,10 @@ } ); - watch( - () => props.refreshKey, - (val) => { - if (val) { - initTestPlanCount(); - } - } - ); + watch([() => props.refreshKey, () => projectId.value], async () => { + await nextTick(); + initTestPlanCount(); + });