fix(工作台): 修复工作台系统卡片人员bug

This commit is contained in:
xinxin.wu 2024-11-27 12:48:17 +08:00 committed by 刘瑞斌
parent c0d70a8d0a
commit 18cdf76a95
4 changed files with 80 additions and 72 deletions

View File

@ -29,8 +29,7 @@
:prefix="t('workbench.homePage.staff')"
:multiple="true"
:has-all-select="true"
:default-all-select="innerHandleUsers.length === 0"
@change="changeMember"
@popup-visible-change="popupVisibleChange"
>
</MsSelect>
</div>
@ -60,7 +59,6 @@
import type { OverViewOfProject, SelectedCardItem, TimeFormParams } from '@/models/workbench/homePage';
import { getColorScheme, getCommonBarOptions, handleNoDataDisplay } from '../utils';
import type { SelectOptionData } from '@arco-design/web-vue';
const { t } = useI18n();
const appStore = useAppStore();
@ -92,7 +90,7 @@
})
);
const memberOptions = ref<SelectOptionData[]>([]);
const memberOptions = ref<{ label: string; value: string }[]>([]);
const options = ref<Record<string, any>>({});
@ -178,24 +176,30 @@
label: e.text,
value: e.value,
}));
innerHandleUsers.value = innerHandleUsers.value.filter((id: string) =>
memberOptions.value.some((member) => member.value === id)
);
innerHandleUsers.value = memberOptions.value.map((e) => e.value);
}
function changeProject() {
innerHandleUsers.value = [];
nextTick(() => {
async function handleProjectChange(isRefreshKey: boolean = false) {
await nextTick();
if (!isRefreshKey) {
await getMemberOptions();
}
await getDefectMemberDetail();
}
async function changeProject() {
await handleProjectChange(false);
emit('change');
});
}
function changeMember() {
function popupVisibleChange(val: boolean) {
if (!val) {
nextTick(() => {
getDefectMemberDetail();
emit('change');
});
}
}
watch(
() => props.item.projectIds,
@ -230,15 +234,12 @@
}
);
watch([() => props.refreshKey, () => projectId.value], async () => {
await nextTick();
getMemberOptions();
getDefectMemberDetail();
watch([() => props.refreshKey, () => projectId.value], ([refreshKey]) => {
handleProjectChange(!!refreshKey);
});
onMounted(() => {
getMemberOptions();
getDefectMemberDetail();
handleProjectChange(false);
});
</script>

View File

@ -1,7 +1,7 @@
<template>
<div class="card-wrapper">
<CardSkeleton v-if="showSkeleton" :show-skeleton="showSkeleton" />
<div v-show="!showSkeleton">
<div v-else>
<div class="flex items-center justify-between">
<a-tooltip :content="t(props.item.label)" position="tl">
<div class="title one-line-text"> {{ t(props.item.label) }} </div>
@ -21,7 +21,7 @@
:has-all-select="true"
:default-all-select="props.item.selectAll"
:at-least-one="true"
@change="changeProject"
@popup-visible-change="popupVisibleChange"
>
</MsSelect>
</div>
@ -152,7 +152,7 @@
projectIds: innerProjectIds.value,
organizationId: appStore.currentOrgId,
handleUsers: [],
selectAll: selectAll.value,
selectAll: innerSelectAll.value,
};
let detail;
if (props.item.key === WorkCardEnum.PROJECT_VIEW) {
@ -170,17 +170,33 @@
showSkeleton.value = false;
}
}
const isInit = ref(true);
function changeProject() {
if (isInit.value) return;
function handleProjectChange(shouldEmit = false) {
//
nextTick(() => {
innerSelectAll.value = selectAll.value;
emit('change');
initOverViewDetail();
if (shouldEmit) emit('change');
});
}
function popupVisibleChange(val: boolean) {
if (!val) {
handleProjectChange(true);
}
}
async function handleRefreshKeyChange() {
await nextTick(() => {
innerProjectIds.value = [...props.item.projectIds];
innerSelectAll.value = props.item.selectAll;
});
setTimeout(() => {
initOverViewDetail();
}, 0);
}
onMounted(() => {
isInit.value = false;
initOverViewDetail();
});
@ -191,15 +207,10 @@
initOverViewDetail();
}
},
{
deep: true,
}
{ deep: true }
);
watch([() => props.refreshKey, () => innerProjectIds.value], async () => {
await nextTick();
initOverViewDetail();
});
watch(() => props.refreshKey, handleRefreshKeyChange);
</script>
<style scoped lang="less">

View File

@ -16,6 +16,7 @@
:search-keys="['name']"
class="!w-[200px]"
:prefix="t('workbench.homePage.project')"
@change="changeProject"
>
</MsSelect>
@ -24,6 +25,7 @@
:options="memberOptions"
allow-search
allow-clear
:placeholder="t('ms.case.associate.allData')"
value-key="value"
label-key="label"
:search-keys="['label']"
@ -31,8 +33,7 @@
:prefix="t('workbench.homePage.staff')"
:multiple="true"
:has-all-select="true"
:default-all-select="innerHandleUsers.length === 0"
@change="changeMember"
@popup-visible-change="popupVisibleChange"
>
</MsSelect>
</div>
@ -58,7 +59,7 @@
import { workMemberViewDetail, workProjectMemberOptions } from '@/api/modules/workbench';
import { useI18n } from '@/hooks/useI18n';
import useAppStore from '@/store/modules/app';
import { characterLimit, sleep } from '@/utils';
import { characterLimit } from '@/utils';
import type { OverViewOfProject, SelectedCardItem, TimeFormParams } from '@/models/workbench/homePage';
@ -145,19 +146,30 @@
label: e.name,
value: e.id,
}));
innerHandleUsers.value = innerHandleUsers.value.filter((id: string) =>
memberOptions.value.some((member) => member.value === id)
);
innerHandleUsers.value = memberOptions.value.map((e) => e.value);
}
const isInit = ref(true);
function changeMember(value: string[]) {
async function handleProjectChange(isRefreshKey: boolean = false) {
await nextTick();
if (!isRefreshKey) {
await getMemberOptions();
}
await initOverViewMemberDetail();
}
async function changeProject() {
await handleProjectChange(false);
emit('change');
}
function popupVisibleChange(val: boolean) {
if (!val) {
nextTick(() => {
initOverViewMemberDetail();
innerHandleUsers.value = value;
emit('change');
});
}
}
watch(
() => props.item.projectIds,
@ -192,28 +204,12 @@
}
);
onMounted(() => {
isInit.value = false;
if (props.item.projectIds.length) {
getMemberOptions();
}
initOverViewMemberDetail();
watch([() => props.refreshKey, () => projectId.value], ([refreshKey]) => {
handleProjectChange(!!refreshKey);
});
watch([() => props.refreshKey, () => projectId.value], async ([_key, newProjectId]) => {
await nextTick();
if (newProjectId) {
innerHandleUsers.value = [];
emit('change');
}
if (props.item.projectIds.length) {
getMemberOptions();
}
await sleep(50);
initOverViewMemberDetail();
onMounted(() => {
handleProjectChange(false);
});
</script>

View File

@ -317,7 +317,7 @@
//
async function handleRefresh() {
initDefaultList();
await initDefaultList();
refreshKey.value = Date.now();
}