feat: creditNote => add conditional delete button visibility in credit note table

This commit is contained in:
puriphatt 2025-01-14 09:40:31 +07:00
parent dfa60d9288
commit 506b73eac2
2 changed files with 8 additions and 4 deletions

View file

@ -22,14 +22,12 @@ import useFlowStore from 'src/stores/flow';
import { pageTabs, columns, hslaColors } from './constants';
import { CreditNoteStatus, useCreditNote } from 'src/stores/credit-note';
import TableCreditNote from './TableCreditNote.vue';
import { ref } from 'vue';
import { dialogWarningClose } from 'src/stores/utils';
const { t } = useI18n();
const flow = useFlowStore();
const navigator = useNavigator();
const creditNote = useCreditNote();
const selectedQuotationId = ref<string>('');
const { stats, pageMax, page, data, pageSize } = storeToRefs(creditNote);
// NOTE: Variable
@ -346,6 +344,7 @@ watch(
<TableCreditNote
:grid="pageState.gridView"
:visible-columns="pageState.fieldSelected"
:hide-delete="pageState.currentTab === CreditNoteStatus.Success"
@view="(v) => navigateTo({ statusDialog: 'info', creditId: v.id })"
@delete="(v) => triggerDelete(v.id)"
>

View file

@ -10,7 +10,11 @@ import KebabAction from 'src/components/shared/KebabAction.vue';
const creditNote = useCreditNote();
const { data, page } = storeToRefs(creditNote);
const prop = defineProps<{ grid: boolean; visibleColumns: string[] }>();
const prop = defineProps<{
grid: boolean;
visibleColumns: string[];
hideDelete: boolean;
}>();
defineEmits<{ (evt: 'view' | 'delete', val: CreditNote): void }>();
const visible = computed(() =>
@ -52,7 +56,7 @@ const visible = computed(() =>
} & Omit<Parameters<QTableSlots['body']>[0], 'row'>"
>
<q-tr :class="{ dark: $q.dark.isActive }" class="text-center">
<q-td v-for="col in visible" :align="col.align">
<q-td v-for="(col, i) in visible" :align="col.align" :key="i">
<!-- NOTE: custom column will starts with # -->
<template v-if="!col.name.startsWith('#')">
<span v-if="col.name !== 'quotationPayment'">
@ -72,6 +76,7 @@ const visible = computed(() =>
<KebabAction
hide-edit
hide-toggle
:hide-delete
@delete="$emit('delete', props.row)"
@view="$emit('view', props.row)"
/>