feat: enhance AvatarGroup to display responsible groups alongside users
Some checks failed
Spell Check / Spell Check with Typos (push) Failing after 8s

This commit is contained in:
puriphatt 2025-04-24 15:16:09 +07:00
parent 92b4db45d2
commit 9f6d972c91
3 changed files with 74 additions and 24 deletions

View file

@ -25,7 +25,11 @@ withDefaults(
alt="Image" alt="Image"
/> />
</div> </div>
<div v-if="data.length > 3" class="avatar remaining-count"> <div
v-if="data.length > 3"
class="avatar remaining-count"
style="cursor: default"
>
<q-tooltip> <q-tooltip>
<div v-for="(person, i) in data.slice(3)" :key="i + 3"> <div v-for="(person, i) in data.slice(3)" :key="i + 3">
{{ person.name }} {{ person.name }}

View file

@ -518,8 +518,8 @@ function toEmployee(employee: RequestData['employee']) {
v-if="responsibleList[pageState.currentStep]?.user.length" v-if="responsibleList[pageState.currentStep]?.user.length"
> >
<AvatarGroup <AvatarGroup
:data=" :data="[
(responsibleList[pageState.currentStep].user || []).map( ...(responsibleList[pageState.currentStep].user || []).map(
(v) => ({ (v) => ({
name: name:
$i18n.locale === 'eng' $i18n.locale === 'eng'
@ -531,8 +531,12 @@ function toEmployee(employee: RequestData['employee']) {
: `/no-img-female.png` : `/no-img-female.png`
: `${baseUrl}/user/${v.id}/profile-image/${v.selectedImage}`, : `${baseUrl}/user/${v.id}/profile-image/${v.selectedImage}`,
}), }),
) ),
" ...responsibleList[pageState.currentStep].group.map((g) => ({
name: `${$t('general.group')} ${g}`,
imgUrl: '/img-group.png',
})),
]"
/> />
</template> </template>
<template v-else>-</template> <template v-else>-</template>

View file

@ -42,9 +42,14 @@ defineEmits<{
const selected = defineModel<RequestData[]>('selected'); const selected = defineModel<RequestData[]>('selected');
function responsiblePerson(quotation: QuotationFull): CreatedBy[] | undefined { function responsiblePerson(quotation: QuotationFull) {
const productServiceList = quotation.productServiceList; const productServiceList = quotation.productServiceList;
const tempPerson: CreatedBy[] = []; const tempPerson: CreatedBy[] = [];
const tempGroup: {
group: string;
id: string;
workflowTemplateStepId: string;
}[] = [];
for (const v of productServiceList) { for (const v of productServiceList) {
const tempStep = v.service?.workflow?.step; const tempStep = v.service?.workflow?.step;
@ -55,7 +60,18 @@ function responsiblePerson(quotation: QuotationFull): CreatedBy[] | undefined {
tempPerson.push(rhs.user); tempPerson.push(rhs.user);
} }
}); });
return tempPerson; tempStep.forEach((lhs) => {
const newGroup = lhs.responsibleGroup as unknown as {
group: string;
id: string;
workflowTemplateStepId: string;
}[];
for (const rhs of newGroup) {
tempGroup.push(rhs);
}
});
console.log({ user: tempPerson, group: tempGroup });
return { user: tempPerson, group: tempGroup };
} }
} }
@ -261,7 +277,7 @@ function handleCheckAll() {
{{ props.row.quotation.code || '-' }} {{ props.row.quotation.code || '-' }}
</q-td> </q-td>
<q-td v-if="visibleColumns.includes('responsiblePerson')"> <q-td v-if="visibleColumns.includes('responsiblePerson')">
<AvatarGroup <!-- <AvatarGroup
:data=" :data="
responsiblePerson(props.row.quotation)?.map((v) => { responsiblePerson(props.row.quotation)?.map((v) => {
return { return {
@ -277,7 +293,26 @@ function handleCheckAll() {
}; };
}) })
" "
/> /> -->
<AvatarGroup
:data="[
...responsiblePerson(props.row.quotation).user.map((v) => ({
name:
$i18n.locale === 'eng'
? `${v.firstNameEN} ${v.lastNameEN}`
: `${v.firstName} ${v.lastName}`,
imgUrl: !v.selectedImage
? v.gender === 'male'
? `/no-img-man.png`
: `/no-img-female.png`
: `${baseUrl}/user/${v.id}/profile-image/${v.selectedImage}`,
})),
...responsiblePerson(props.row.quotation).group.map((g) => ({
name: `${$t('general.group')} ${g.group}`,
imgUrl: '/img-group.png',
})),
]"
></AvatarGroup>
</q-td> </q-td>
<q-td v-if="visibleColumns.includes('status')"> <q-td v-if="visibleColumns.includes('status')">
<BadgeComponent <BadgeComponent
@ -423,22 +458,29 @@ function handleCheckAll() {
</div> </div>
<div class="col-8"> <div class="col-8">
<AvatarGroup <AvatarGroup
v-if="(responsiblePerson(props.row.quotation) ?? []).length > 0" v-if="
:data=" (responsiblePerson(props.row.quotation).user ?? []).length >
responsiblePerson(props.row.quotation)?.map((v) => { 0 ||
return { (responsiblePerson(props.row.quotation).group ?? []).length >
name: 0
$i18n.locale === 'eng'
? `${v.firstNameEN} ${v.lastNameEN}`
: `${v.firstName} ${v.lastName}`,
imgUrl: !v.selectedImage
? v.gender === 'male'
? `/no-img-man.png`
: `/no-img-female.png`
: `${baseUrl}/user/${v.id}/profile-image/${v.selectedImage}`,
};
})
" "
:data="[
...responsiblePerson(props.row.quotation).user.map((v) => ({
name:
$i18n.locale === 'eng'
? `${v.firstNameEN} ${v.lastNameEN}`
: `${v.firstName} ${v.lastName}`,
imgUrl: !v.selectedImage
? v.gender === 'male'
? `/no-img-man.png`
: `/no-img-female.png`
: `${baseUrl}/user/${v.id}/profile-image/${v.selectedImage}`,
})),
...responsiblePerson(props.row.quotation).group.map((g) => ({
name: `${$t('general.group')} ${g.group}`,
imgUrl: '/img-group.png',
})),
]"
/> />
<span v-else>-</span> <span v-else>-</span>
</div> </div>