fix(工作台): 修复工作台卡片项目切换人员偶发性bug

This commit is contained in:
xinxin.wu 2024-11-27 16:42:22 +08:00 committed by 刘瑞斌
parent 82fc924888
commit dd0c8e2295
3 changed files with 34 additions and 20 deletions

View File

@ -22,7 +22,6 @@
<MsSelect <MsSelect
v-model:model-value="innerHandleUsers" v-model:model-value="innerHandleUsers"
:options="memberOptions" :options="memberOptions"
allow-clear
allow-search allow-search
:search-keys="['label']" :search-keys="['label']"
class="!w-[220px]" class="!w-[220px]"
@ -176,19 +175,26 @@
label: e.text, label: e.text,
value: e.value, value: e.value,
})); }));
innerHandleUsers.value = memberOptions.value.map((e) => e.value);
} }
async function handleProjectChange(isRefreshKey: boolean = false) { async function handleProjectChange(isRefreshKey: boolean = false, setAll = false) {
await nextTick(); await nextTick();
if (!isRefreshKey) { if (!isRefreshKey) {
await getMemberOptions(); await getMemberOptions();
if (setAll) {
innerHandleUsers.value = [...memberOptions.value.map((e) => e.value)];
} else {
innerHandleUsers.value = innerHandleUsers.value.filter((id: string) =>
memberOptions.value.some((member) => member.value === id)
);
}
} }
await getDefectMemberDetail(); await nextTick();
getDefectMemberDetail();
} }
async function changeProject() { async function changeProject() {
await handleProjectChange(false); await handleProjectChange(false, true);
emit('change'); emit('change');
} }
@ -234,9 +240,12 @@
} }
); );
watch([() => props.refreshKey, () => projectId.value], ([refreshKey]) => { watch(
handleProjectChange(!!refreshKey); () => props.refreshKey,
}); (refreshKey) => {
handleProjectChange(!!refreshKey);
}
);
onMounted(() => { onMounted(() => {
handleProjectChange(false); handleProjectChange(false);

View File

@ -10,7 +10,6 @@
<MsSelect <MsSelect
v-model:model-value="innerProjectIds" v-model:model-value="innerProjectIds"
:options="appStore.projectList" :options="appStore.projectList"
allow-clear
allow-search allow-search
value-key="id" value-key="id"
label-key="name" label-key="name"
@ -172,7 +171,6 @@
} }
function handleProjectChange(shouldEmit = false) { function handleProjectChange(shouldEmit = false) {
//
nextTick(() => { nextTick(() => {
innerSelectAll.value = selectAll.value; innerSelectAll.value = selectAll.value;
initOverViewDetail(); initOverViewDetail();

View File

@ -19,13 +19,10 @@
@change="changeProject" @change="changeProject"
> >
</MsSelect> </MsSelect>
<MsSelect <MsSelect
v-model:model-value="innerHandleUsers" v-model:model-value="innerHandleUsers"
:options="memberOptions" :options="memberOptions"
allow-search allow-search
allow-clear
:placeholder="t('ms.case.associate.allData')"
value-key="value" value-key="value"
label-key="label" label-key="label"
:search-keys="['label']" :search-keys="['label']"
@ -146,19 +143,26 @@
label: e.name, label: e.name,
value: e.id, value: e.id,
})); }));
innerHandleUsers.value = memberOptions.value.map((e) => e.value);
} }
async function handleProjectChange(isRefreshKey: boolean = false) { async function handleProjectChange(isRefreshKey: boolean = false, setAll = false) {
await nextTick(); await nextTick();
if (!isRefreshKey) { if (!isRefreshKey) {
await getMemberOptions(); await getMemberOptions();
if (setAll) {
innerHandleUsers.value = [...memberOptions.value.map((e) => e.value)];
} else {
innerHandleUsers.value = innerHandleUsers.value.filter((id: string) =>
memberOptions.value.some((member) => member.value === id)
);
}
} }
await initOverViewMemberDetail(); await nextTick();
initOverViewMemberDetail();
} }
async function changeProject() { async function changeProject() {
await handleProjectChange(false); await handleProjectChange(false, true);
emit('change'); emit('change');
} }
@ -204,9 +208,12 @@
} }
); );
watch([() => props.refreshKey, () => projectId.value], ([refreshKey]) => { watch(
handleProjectChange(!!refreshKey); () => props.refreshKey,
}); (refreshKey) => {
handleProjectChange(!!refreshKey);
}
);
onMounted(() => { onMounted(() => {
handleProjectChange(false); handleProjectChange(false);