diff --git a/src/components/VnTable/VnChip.vue b/src/components/VnTable/VnChip.vue index 74207b943..f70ba7423 100644 --- a/src/components/VnTable/VnChip.vue +++ b/src/components/VnTable/VnChip.vue @@ -35,7 +35,9 @@ function stopEventPropagation(event) { dense square > - {{ row[col.name] }} + + {{ col.format ? col.format(row) : row[col.name] }} + diff --git a/src/components/VnTable/VnFilter.vue b/src/components/VnTable/VnFilter.vue index 15e1cc947..e6eeb713c 100644 --- a/src/components/VnTable/VnFilter.vue +++ b/src/components/VnTable/VnFilter.vue @@ -64,6 +64,7 @@ const components = { attrs: { ...defaultAttrs, clearable: true, + type: 'number', }, forceAttrs, }, diff --git a/src/components/VnTable/VnTable.vue b/src/components/VnTable/VnTable.vue index dc5410e93..bf89ab6e1 100644 --- a/src/components/VnTable/VnTable.vue +++ b/src/components/VnTable/VnTable.vue @@ -423,6 +423,7 @@ defineExpose({ > import axios from 'axios'; -import { ref, computed } from 'vue'; +import { computed } from 'vue'; import { useI18n } from 'vue-i18n'; import { useQuasar } from 'quasar'; -import { useArrayData } from 'composables/useArrayData'; -import VnPaginate from 'components/ui/VnPaginate.vue'; +import { toDate, toCurrency } from 'filters/index'; + +import VnTable from 'src/components/VnTable/VnTable.vue'; import VnConfirm from 'components/ui/VnConfirm.vue'; import CustomerDescriptorProxy from '../Card/CustomerDescriptorProxy.vue'; -import { toDate, toCurrency } from 'filters/index'; import CustomerPaymentsFilter from './CustomerPaymentsFilter.vue'; import RightMenu from 'src/components/common/RightMenu.vue'; const quasar = useQuasar(); const { t } = useI18n(); -const arrayData = useArrayData('CustomerTransactions'); async function confirm(transaction) { quasar @@ -36,59 +35,69 @@ async function confirmTransaction({ id }) { }); } -const grid = ref(false); const columns = computed(() => [ { name: 'id', label: t('Transaction ID'), - field: (row) => row.id, - sortable: true, - }, - { - name: 'customerId', - label: t('Customer ID'), - field: (row) => row.clientFk, - align: 'right', - sortable: true, - }, - { - name: 'customer', - label: t('Customer Name'), - field: (row) => row.customerName, - }, - { - name: 'state', - label: t('State'), - field: (row) => row.isConfirmed, - format: (value) => (value ? t('Confirmed') : t('Unconfirmed')), + isId: true, align: 'left', - sortable: true, + columnFilter: { + inWhere: true, + alias: 't', + }, }, { - name: 'dated', + align: 'left', + name: 'clientFk', + label: t('Customer'), + columnFilter: { + component: 'select', + attrs: { + url: 'Clients', + fields: ['id', 'name'], + }, + }, + class: 'expand', + }, + { + name: 'isConfirmed', + label: t('State'), + align: 'left', + format: ({ isConfirmed }) => (isConfirmed ? t('Confirmed') : t('Unconfirmed')), + chip: { + condition: () => true, + color: ({ isConfirmed }) => (isConfirmed ? 'bg-positive' : 'bg-primary'), + }, + visible: false, + }, + { + name: 'created', label: t('Dated'), - field: (row) => toDate(row.created), - sortable: true, + format: ({ created }) => toDate(created), + columnFilter: false, }, { name: 'amount', label: t('Amount'), - field: (row) => row.amount, - format: (value) => toCurrency(value), - sortable: true, + format: ({ amount }) => toCurrency(amount), + columnFilter: { + component: 'number', + }, }, { - name: 'actions', - label: t('Actions'), - grid: false, + align: 'right', + name: 'tableActions', + actions: [ + { + title: t('Confirm transaction'), + icon: 'check', + action: (row) => confirm(row), + show: ({ isConfirmed }) => !isConfirmed, + isPrimary: true, + }, + ], }, ]); -const isLoading = computed(() => arrayData.isLoading.value); - -function stateColor(row) { - if (row.isConfirmed) return 'positive'; - return 'primary'; -} - -
- - - - {{ t('Change view') }} - - - - - -
-
+ + +