refactor: show person

This commit is contained in:
Thanaphon Frappet 2024-12-25 16:11:54 +07:00
parent ff896cd6b7
commit 5a5a0581de

View file

@ -1,5 +1,6 @@
<script setup lang="ts">
import { QTable, QTableProps, QTableSlots } from 'quasar';
import { baseUrl } from 'src/stores/utils';
import QuotationCard from 'src/components/05_quotation/QuotationCard.vue';
import BadgeComponent from 'src/components/BadgeComponent.vue';
@ -7,9 +8,11 @@ import AvatarGroup from 'src/components/shared/AvatarGroup.vue';
import { RequestData } from 'src/stores/request-list/types';
import { RequestDataStatus } from 'src/stores/request-list/types';
import { QuotationFull } from 'src/stores/quotations/types';
import useOptionStore from 'src/stores/options';
import KebabAction from 'src/components/shared/KebabAction.vue';
import { CreatedBy } from 'src/stores/types';
const props = withDefaults(
defineProps<{
@ -31,6 +34,26 @@ defineEmits<{
(e: 'delete', data: RequestData): void;
}>();
function responsiblePerson(quotation: QuotationFull): CreatedBy[] | undefined {
const productServiceList = quotation.productServiceList;
const tempPerson: CreatedBy[] = [];
for (const v of productServiceList) {
const tempStep = v.service?.workflow?.step;
if (tempStep) {
tempStep.forEach((lhs) => {
for (const rhs of lhs.responsiblePerson) {
tempPerson.push(rhs.user);
}
});
return tempPerson;
}
}
return undefined;
}
function getCustomerName(
record: RequestData,
opts?: {
@ -127,7 +150,23 @@ function getEmployeeName(
{{ props.row.quotation.code || '-' }}
</q-td>
<q-td v-if="visibleColumns.includes('responsiblePerson')">
{{ '-' }}
<AvatarGroup
:data="
responsiblePerson(props.row.quotation)?.map((v) => {
return {
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}`,
};
})
"
/>
</q-td>
<q-td v-if="visibleColumns.includes('status')">
<BadgeComponent