From d2f37985cbd97c909e947edea45159c71b1e6dd0 Mon Sep 17 00:00:00 2001 From: cykj Date: Wed, 25 Nov 2026 15:51:00 +0800 Subject: [PATCH] fix(web-admin): refresh assignment filter project options after save MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 归属调整成功后递增 ProjectSelect refreshKey,立即重拉筛选区项目组/项目选项。 Co-authored-by: Cursor --- web-admin/src/components/business/ProjectSelect.vue | 4 +++- web-admin/src/utils/filter-options-epoch.test.ts | 11 +++++++++++ web-admin/src/utils/filter-options-epoch.ts | 4 ++++ web-admin/src/views/project-management/RecordList.vue | 8 ++++++++ 4 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 web-admin/src/utils/filter-options-epoch.test.ts create mode 100644 web-admin/src/utils/filter-options-epoch.ts diff --git a/web-admin/src/components/business/ProjectSelect.vue b/web-admin/src/components/business/ProjectSelect.vue index fe680c22..a91af791 100644 --- a/web-admin/src/components/business/ProjectSelect.vue +++ b/web-admin/src/components/business/ProjectSelect.vue @@ -55,6 +55,8 @@ bizType?: BizType disabled?: boolean projectName?: string + /** Bump to reload options without remounting (e.g. after assignment). */ + refreshKey?: number | string }>() const emit = defineEmits<{ 'update:modelValue': [value: string] @@ -79,7 +81,7 @@ retry = ref(0) let version = 0 watch( - () => [props.bizType, props.disabled, props.filter, retry.value], + () => [props.bizType, props.disabled, props.filter, props.refreshKey, retry.value], async () => { const requestVersion = ++version if (props.disabled) { diff --git a/web-admin/src/utils/filter-options-epoch.test.ts b/web-admin/src/utils/filter-options-epoch.test.ts new file mode 100644 index 00000000..d542eca6 --- /dev/null +++ b/web-admin/src/utils/filter-options-epoch.test.ts @@ -0,0 +1,11 @@ +import { describe, it } from 'node:test' +import assert from 'node:assert/strict' +import { nextFilterOptionsEpoch } from './filter-options-epoch' + +describe('nextFilterOptionsEpoch', () => { + it('bumps only when at least one assignment succeeded', () => { + assert.equal(nextFilterOptionsEpoch(3, 1), 4) + assert.equal(nextFilterOptionsEpoch(3, 2), 4) + assert.equal(nextFilterOptionsEpoch(3, 0), 3) + }) +}) diff --git a/web-admin/src/utils/filter-options-epoch.ts b/web-admin/src/utils/filter-options-epoch.ts new file mode 100644 index 00000000..2a746801 --- /dev/null +++ b/web-admin/src/utils/filter-options-epoch.ts @@ -0,0 +1,4 @@ +/** After successful assignment saves, bump so filter ProjectSelect reloads options. */ +export function nextFilterOptionsEpoch(epoch: number, successCount: number) { + return successCount > 0 ? epoch + 1 : epoch +} diff --git a/web-admin/src/views/project-management/RecordList.vue b/web-admin/src/views/project-management/RecordList.vue index f31e202f..9469859d 100644 --- a/web-admin/src/views/project-management/RecordList.vue +++ b/web-admin/src/views/project-management/RecordList.vue @@ -37,6 +37,7 @@ team v-model="query.teamId" :biz-type="query.bizType" + :refresh-key="filterOptionsEpoch" /> void } | null>(null) + const filterOptionsEpoch = ref(0) const rows = ref([]), total = ref(0), statusCounts = ref>({}), @@ -509,6 +513,10 @@ } else { ElMessage.warning(`成功 ${successCount} 条,失败 ${failCount} 条`) } + filterOptionsEpoch.value = nextFilterOptionsEpoch( + filterOptionsEpoch.value, + successCount + ) await load() } } finally {