refactor: request list role check
Some checks failed
Spell Check / Spell Check with Typos (push) Failing after 6s

This commit is contained in:
puriphatt 2025-07-03 16:14:06 +07:00
parent 963ed11073
commit 48a1800b54
4 changed files with 19 additions and 5 deletions

View file

@ -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(
"
>
<TableRequestList
:no-link="!canAccess('related', 'edit')"
:columns="column"
:rows="data"
:grid="pageState.gridView"
@ -574,6 +575,7 @@ watch(
v-if="requestListActionData"
v-model="pageState.requestListActionDialog"
:request-list="requestListActionData"
:no-link="!canAccess('related', 'edit')"
@submit="submitRequestListAction"
/>
</div>

View file

@ -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"

View file

@ -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']) {
}"
>
<DataDisplay
clickable
:clickable="canAccess('related', 'edit')"
class="col"
icon="mdi-account-settings-outline"
:label="$t('customer.employer')"
@ -755,7 +758,7 @@ function toEmployee(employee: RequestData['employee']) {
@label-click="toCustomer(data.quotation.customerBranch)"
/>
<DataDisplay
clickable
:clickable="canAccess('related', 'edit')"
class="col"
icon="mdi-account-settings-outline"
:label="$t('customer.employee')"

View file

@ -25,6 +25,7 @@ const props = withDefaults(
hideView?: boolean;
checkable?: boolean;
listSameArea?: string[];
noLink?: boolean;
}>(),
{
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() {
</q-td>
<q-td v-if="visibleColumns.includes('employer')" class="text-left">
<span
class="link"
:class="{ link: !noLink }"
@click="toCustomer(props.row.quotation.customerBranch)"
>
{{
@ -246,7 +249,10 @@ function handleCheckAll() {
</span>
</q-td>
<q-td v-if="visibleColumns.includes('employee')" class="text-left">
<span class="link" @click="toEmployee(props.row.employee)">
<span
:class="{ link: !noLink }"
@click="toEmployee(props.row.employee)"
>
{{ getEmployeeName(props.row, { locale: $i18n.locale }) || '-' }}
</span>
</q-td>
@ -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
"