From b55620b3d4a0c163f2995b55a76232b96857a6ae Mon Sep 17 00:00:00 2001 From: puriphatt Date: Tue, 20 Aug 2024 10:44:11 +0700 Subject: [PATCH] feat(04): role control --- src/pages/04_product-service/MainPage.vue | 66 ++++++++++++++++++----- 1 file changed, 53 insertions(+), 13 deletions(-) diff --git a/src/pages/04_product-service/MainPage.vue b/src/pages/04_product-service/MainPage.vue index 2bbce39c..087915b4 100644 --- a/src/pages/04_product-service/MainPage.vue +++ b/src/pages/04_product-service/MainPage.vue @@ -39,7 +39,7 @@ import useFlowStore from 'stores/flow'; import useMyBranchStore from 'stores/my-branch'; import { dateFormat } from 'src/utils/datetime'; -import { formatNumberDecimal } from 'stores/utils'; +import { formatNumberDecimal, isRoleInclude } from 'stores/utils'; const userBranchStore = useMyBranchStore(); @@ -145,6 +145,27 @@ const stat = ref< const { t } = useI18n(); const baseUrl = ref(import.meta.env.VITE_API_BASE_URL); +const priceDisplay = computed(() => ({ + price: !isRoleInclude(['agency']), + agentPrice: isRoleInclude([ + 'admin', + 'head_of_admin', + 'system', + 'owner', + 'accountant', + 'agency', + ]), + serviceCharge: isRoleInclude([ + 'admin', + 'head_of_admin', + 'system', + 'owner', + 'accountant', + ]), +})); +const actionDisplay = computed(() => + isRoleInclude(['admin', 'head_of_admin', 'system', 'owner', 'accountant']), +); const holdDialog = ref(false); const imageDialog = ref(false); const currentNode = ref(); @@ -164,14 +185,14 @@ const treeProductTypeAndGroup = computed(() => { type: 'group', children: item.id === currentIdGrop.value - ? recordTreeProductType.value[currentIdGrop.value]?.map((x) => ({ + ? (recordTreeProductType.value[currentIdGrop.value]?.map((x) => ({ ...x, type: 'type', - })) ?? [] - : recordTreeProductType.value[item.id]?.map((x) => ({ + })) ?? []) + : (recordTreeProductType.value[item.id]?.map((x) => ({ ...x, type: 'type', - })) ?? item._count.type > 0 + })) ?? item._count.type > 0) ? [ { id: '', @@ -1365,7 +1386,7 @@ watch(