From 48a1800b54597a55c96c59c78a2afd4a7021f999 Mon Sep 17 00:00:00 2001 From: puriphatt Date: Thu, 3 Jul 2025 16:14:06 +0700 Subject: [PATCH] refactor: request list role check --- src/pages/08_request-list/MainPage.vue | 4 +++- src/pages/08_request-list/RequestListAction .vue | 2 ++ src/pages/08_request-list/RequestListView.vue | 7 +++++-- src/pages/08_request-list/TableRequestList.vue | 11 +++++++++-- 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/pages/08_request-list/MainPage.vue b/src/pages/08_request-list/MainPage.vue index 64b339dc..f62f89b2 100644 --- a/src/pages/08_request-list/MainPage.vue +++ b/src/pages/08_request-list/MainPage.vue @@ -21,7 +21,7 @@ import { column } from './constants'; import useFlowStore from 'src/stores/flow'; import { useRequestList } from 'src/stores/request-list'; import { RequestData, RequestDataStatus } from 'src/stores/request-list/types'; -import { dialogWarningClose } from 'src/stores/utils'; +import { dialogWarningClose, canAccess } from 'src/stores/utils'; import { CancelButton, SaveButton } from 'src/components/button'; import { getRole } from 'src/services/keycloak'; import FloatingActionButton from 'src/components/FloatingActionButton.vue'; @@ -473,6 +473,7 @@ watch( " > diff --git a/src/pages/08_request-list/RequestListAction .vue b/src/pages/08_request-list/RequestListAction .vue index 09f62aa1..93a367f5 100644 --- a/src/pages/08_request-list/RequestListAction .vue +++ b/src/pages/08_request-list/RequestListAction .vue @@ -16,6 +16,7 @@ import useAddressStore from 'src/stores/address'; defineProps<{ requestList: RequestData[]; + noLink?: boolean; }>(); defineEmits<{ @@ -99,6 +100,7 @@ watch( hide-action hide-view checkable + :no-link="noLink" :list-same-area="listSameArea" :columns="column" :rows="requestList" diff --git a/src/pages/08_request-list/RequestListView.vue b/src/pages/08_request-list/RequestListView.vue index 982f3203..df5af821 100644 --- a/src/pages/08_request-list/RequestListView.vue +++ b/src/pages/08_request-list/RequestListView.vue @@ -26,6 +26,7 @@ import { getEmployeeName, getCustomerName, dialogWarningClose, + canAccess, } from 'src/stores/utils'; import { dateFormatJS } from 'src/utils/datetime'; import { useRequestList } from 'src/stores/request-list'; @@ -459,6 +460,7 @@ async function submitRejectCancel() { } function toCustomer(customer: RequestData['quotation']['customerBranch']) { + if (!canAccess('related', 'edit')) return; const url = new URL( `/customer-management?tab=customer&id=${customer.customerId}`, window.location.origin, @@ -468,6 +470,7 @@ function toCustomer(customer: RequestData['quotation']['customerBranch']) { } function toEmployee(employee: RequestData['employee']) { + if (!canAccess('related', 'edit')) return; const url = new URL( `/customer-management?tab=employee&id=${employee.id}`, window.location.origin, @@ -742,7 +745,7 @@ function toEmployee(employee: RequestData['employee']) { }" > (), { row: () => [], @@ -119,6 +120,7 @@ function getEmployeeName( } function toCustomer(customer: RequestData['quotation']['customerBranch']) { + if (props.noLink) return; const url = new URL( `/customer-management?tab=customer&id=${customer.customerId}`, window.location.origin, @@ -128,6 +130,7 @@ function toCustomer(customer: RequestData['quotation']['customerBranch']) { } function toEmployee(employee: RequestData['employee']) { + if (props.noLink) return; const url = new URL( `/customer-management?tab=employee&id=${employee.id}`, window.location.origin, @@ -234,7 +237,7 @@ function handleCheckAll() { {{ @@ -246,7 +249,10 @@ function handleCheckAll() { - + {{ getEmployeeName(props.row, { locale: $i18n.locale }) || '-' }} @@ -403,6 +409,7 @@ function handleCheckAll() { hide-kebab-delete :use-cancel="!hideAction" class="full-height" + :hide-action="hideAction" :use-reject-cancel=" props.row.customerRequestCancel && !props.row.rejectRequestCancel "