feat: detect can edit request list
Some checks failed
Spell Check / Spell Check with Typos (push) Failing after 6s
Some checks failed
Spell Check / Spell Check with Typos (push) Failing after 6s
This commit is contained in:
parent
56a63185a1
commit
92b4db45d2
2 changed files with 55 additions and 21 deletions
|
|
@ -54,6 +54,7 @@ import { Invoice } from 'src/stores/payment/types';
|
|||
import { CreatedBy } from 'src/stores/types';
|
||||
import { getUserId } from 'src/services/keycloak';
|
||||
import { QuotationFull } from 'src/stores/quotations/types';
|
||||
import useUserStore from 'src/stores/user';
|
||||
|
||||
const { locale, t } = useI18n();
|
||||
|
||||
|
|
@ -62,7 +63,9 @@ const route = useRoute();
|
|||
const optionStore = useOptionStore();
|
||||
const requestListStore = useRequestList();
|
||||
const flowTemplateStore = useWorkflowTemplate();
|
||||
const userStore = useUserStore();
|
||||
|
||||
const currentUserGroup = ref<string[]>([]);
|
||||
const workList = ref<RequestWork[]>([]);
|
||||
const statusFile = ref<Attributes>({
|
||||
customer: {},
|
||||
|
|
@ -158,6 +161,10 @@ onMounted(async () => {
|
|||
initTheme();
|
||||
initLang();
|
||||
|
||||
const result = await userStore.fetchUserGroup();
|
||||
|
||||
currentUserGroup.value = result.map((v) => v.name);
|
||||
|
||||
// get data
|
||||
await getData();
|
||||
});
|
||||
|
|
@ -283,26 +290,38 @@ async function triggerViewFile(opt: {
|
|||
if (!opt.download) window.open(url, '_blank');
|
||||
}
|
||||
|
||||
const responsiblePersonList = computed(() => {
|
||||
const temp = workList.value?.reduce<Record<string, CreatedBy[]>>(
|
||||
(acc, curr: RequestWork) => {
|
||||
curr.productService.service?.workflow?.step.forEach((v) => {
|
||||
const key = v.order.toString();
|
||||
const responsibleList = computed(() => {
|
||||
const temp = workList.value?.reduce<
|
||||
Record<string, { user: CreatedBy[]; group: string[] }>
|
||||
>((acc, curr: RequestWork) => {
|
||||
curr.productService.service?.workflow?.step.forEach((v) => {
|
||||
const key = v.order.toString();
|
||||
const responsibleGroup = (
|
||||
v.responsibleGroup as unknown as { group: string }[]
|
||||
).map((v) => v.group);
|
||||
|
||||
if (!acc[key]) acc[key] = v.responsiblePerson.map((v) => v.user);
|
||||
if (!acc[key]) {
|
||||
acc[key] = {
|
||||
user: v.responsiblePerson.map((v) => v.user),
|
||||
group: responsibleGroup,
|
||||
};
|
||||
}
|
||||
|
||||
const current = acc[key];
|
||||
const current = acc[key];
|
||||
|
||||
v.responsiblePerson.forEach((lhs) => {
|
||||
if (current.find((rhs) => rhs.id === lhs.userId)) return;
|
||||
current.push(lhs.user);
|
||||
});
|
||||
v.responsiblePerson.forEach((lhs) => {
|
||||
if (current.user.find((rhs) => rhs.id === lhs.userId)) return;
|
||||
current.user.push(lhs.user);
|
||||
});
|
||||
|
||||
return acc;
|
||||
},
|
||||
{},
|
||||
);
|
||||
responsibleGroup.forEach((lhs) => {
|
||||
if (current.group.find((rhs) => rhs === lhs)) return;
|
||||
current.group.push(lhs);
|
||||
});
|
||||
});
|
||||
|
||||
return acc;
|
||||
}, {});
|
||||
|
||||
return temp || {};
|
||||
});
|
||||
|
|
@ -496,11 +515,11 @@ function toEmployee(employee: RequestData['employee']) {
|
|||
<span class="app-text-muted">{{ $t('flow.responsiblePerson') }}</span>
|
||||
<span>
|
||||
<template
|
||||
v-if="responsiblePersonList[pageState.currentStep]?.length"
|
||||
v-if="responsibleList[pageState.currentStep]?.user.length"
|
||||
>
|
||||
<AvatarGroup
|
||||
:data="
|
||||
(responsiblePersonList[pageState.currentStep] || []).map(
|
||||
(responsibleList[pageState.currentStep].user || []).map(
|
||||
(v) => ({
|
||||
name:
|
||||
$i18n.locale === 'eng'
|
||||
|
|
@ -798,11 +817,15 @@ function toEmployee(employee: RequestData['employee']) {
|
|||
:cancel="data.requestDataStatus === RequestDataStatus.Canceled"
|
||||
:readonly="
|
||||
data.requestDataStatus === RequestDataStatus.Canceled ||
|
||||
(responsiblePersonList &&
|
||||
!!responsiblePersonList[pageState.currentStep]?.length &&
|
||||
!responsiblePersonList[pageState.currentStep]?.find(
|
||||
(responsibleList &&
|
||||
!responsibleList[pageState.currentStep]?.user.find(
|
||||
(v) => v.id === getUserId(),
|
||||
))
|
||||
) &&
|
||||
!responsibleList[pageState.currentStep]?.group.some((v) =>
|
||||
currentUserGroup.includes(v),
|
||||
)) ||
|
||||
(!!responsibleList[pageState.currentStep]?.user?.length &&
|
||||
!!responsibleList[pageState.currentStep]?.user?.length)
|
||||
"
|
||||
:order-able="value._messengerExpansion"
|
||||
:installment-info="getInstallmentInfo()"
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ import axios from 'axios';
|
|||
import useBranchStore from '../branch';
|
||||
import { Branch } from '../branch/types';
|
||||
import { getSignature, setSignature } from './signature';
|
||||
import { getUserId } from 'src/services/keycloak';
|
||||
|
||||
const branchStore = useBranchStore();
|
||||
|
||||
|
|
@ -38,6 +39,14 @@ const useUserStore = defineStore('api-user', () => {
|
|||
|
||||
const data = ref<Pagination<User[]>>();
|
||||
|
||||
async function fetchUserGroup(id?: string) {
|
||||
return await api
|
||||
.get<
|
||||
{ id: string; name: string; path: string }[]
|
||||
>(`/user/${id || getUserId()}/group`)
|
||||
.then((res) => res.data);
|
||||
}
|
||||
|
||||
async function fetchHqOption() {
|
||||
if (userOption.value.hqOpts.length === 0) {
|
||||
const res = await branchStore.fetchList({
|
||||
|
|
@ -334,6 +343,8 @@ const useUserStore = defineStore('api-user', () => {
|
|||
setSignature,
|
||||
|
||||
typeStats,
|
||||
|
||||
fetchUserGroup,
|
||||
};
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue