refactor: reduce data step show user
This commit is contained in:
parent
277d58d1f2
commit
b9a98fb1d8
1 changed files with 40 additions and 8 deletions
|
|
@ -13,6 +13,7 @@ import AvatarGroup from 'src/components/shared/AvatarGroup.vue';
|
|||
import { StateButton } from 'components/button';
|
||||
|
||||
// NOTE: Store
|
||||
import { baseUrl } from 'src/stores/utils';
|
||||
import { dateFormatJS } from 'src/utils/datetime';
|
||||
import { useRequestList } from 'src/stores/request-list';
|
||||
import {
|
||||
|
|
@ -37,6 +38,8 @@ import {
|
|||
import { PropVariant } from 'src/stores/product-service/types';
|
||||
import { Invoice } from 'src/stores/payment/types';
|
||||
|
||||
import { CreatedBy } from 'src/stores/types';
|
||||
|
||||
const { locale } = useI18n();
|
||||
|
||||
// NOTE: Variable
|
||||
|
|
@ -254,14 +257,25 @@ async function triggerViewFile(opt: {
|
|||
}
|
||||
|
||||
const responsiblePersonList = computed(() => {
|
||||
const temp = workList.value?.reduce<Record<number, User[]>>((acc, curr) => {
|
||||
console.log(curr.productService.service?.work);
|
||||
curr.stepStatus.forEach((v) => {
|
||||
// acc[v.step].push();
|
||||
});
|
||||
const temp = workList.value?.reduce<Record<string, CreatedBy[]>>(
|
||||
(acc, curr: RequestWork) => {
|
||||
curr.productService.service?.workflow?.step.forEach((v) => {
|
||||
const key = v.order.toString();
|
||||
|
||||
return acc;
|
||||
}, []);
|
||||
if (!acc[key]) {
|
||||
acc[key] = [];
|
||||
} else {
|
||||
v.responsiblePerson.forEach((lhs) => {
|
||||
if (acc[v.order].find((rhs) => rhs.id === lhs.userId)) return;
|
||||
acc[v.order].push(lhs.user);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
return acc;
|
||||
},
|
||||
{},
|
||||
);
|
||||
|
||||
return temp;
|
||||
});
|
||||
|
|
@ -359,7 +373,25 @@ function isInstallmentPaySuccess(installmentNo: number) {
|
|||
<div class="column">
|
||||
<span class="app-text-muted">{{ $t('flow.responsiblePerson') }}</span>
|
||||
<span>
|
||||
<AvatarGroup />
|
||||
<template
|
||||
v-if="
|
||||
responsiblePersonList &&
|
||||
responsiblePersonList[pageState.currentStep].length >= 1
|
||||
"
|
||||
>
|
||||
<AvatarGroup
|
||||
:data="
|
||||
responsiblePersonList[pageState.currentStep].map((v) => ({
|
||||
name:
|
||||
$i18n.locale === 'eng'
|
||||
? `${v.firstNameEN} ${v.lastNameEN}`
|
||||
: `${v.firstName} ${v.lastName}`,
|
||||
imgUrl: `${baseUrl}/user/${v.id}/profile-image/${v.selectedImage}`,
|
||||
}))
|
||||
"
|
||||
/>
|
||||
</template>
|
||||
<template v-else>-</template>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue