From 954a6ff6c0c197821051e030a6a671586a1c7d09 Mon Sep 17 00:00:00 2001 From: Jon Date: Fri, 2 Aug 2024 13:55:51 +0200 Subject: [PATCH] refacotr: refs #7553 refactor sales, purchaseRequest and saleTracking --- src/pages/Monitor/SalesTicketsTable.vue | 4 +- .../Ticket/Card/TicketPurchaseRequest.vue | 310 +++++++++--------- src/pages/Ticket/Card/TicketSale.vue | 259 +++++++-------- src/pages/Ticket/Card/TicketSaleTracking.vue | 16 +- 4 files changed, 303 insertions(+), 286 deletions(-) diff --git a/src/pages/Monitor/SalesTicketsTable.vue b/src/pages/Monitor/SalesTicketsTable.vue index 1ca68240b..1dd0557ab 100644 --- a/src/pages/Monitor/SalesTicketsTable.vue +++ b/src/pages/Monitor/SalesTicketsTable.vue @@ -303,7 +303,7 @@ const columns = computed(() => [ { title: t('salesTicketsTable.goToLines'), icon: 'vn:lines', - color: 'priamry', + color: 'primary', action: (row) => redirectToSales(row.id), isPrimary: true, attrs: { @@ -314,7 +314,7 @@ const columns = computed(() => [ { title: t('salesTicketsTable.preview'), icon: 'preview', - color: 'priamry', + color: 'primary', action: (row) => viewSummary(row.id, TicketSummary), isPrimary: true, attrs: { diff --git a/src/pages/Ticket/Card/TicketPurchaseRequest.vue b/src/pages/Ticket/Card/TicketPurchaseRequest.vue index 35573cf2d..3efdcbef8 100644 --- a/src/pages/Ticket/Card/TicketPurchaseRequest.vue +++ b/src/pages/Ticket/Card/TicketPurchaseRequest.vue @@ -1,27 +1,32 @@ + es: New: Nueva diff --git a/src/pages/Ticket/Card/TicketSale.vue b/src/pages/Ticket/Card/TicketSale.vue index 13fea42b4..853913285 100644 --- a/src/pages/Ticket/Card/TicketSale.vue +++ b/src/pages/Ticket/Card/TicketSale.vue @@ -16,11 +16,12 @@ import TicketSaleMoreActions from './TicketSaleMoreActions.vue'; import TicketTransfer from './TicketTransfer.vue'; import { useStateStore } from 'stores/useStateStore'; -import { toCurrency, toPercentage, dashIfEmpty } from 'src/filters'; +import { toCurrency, toPercentage } from 'src/filters'; import { useArrayData } from 'composables/useArrayData'; import { useVnConfirm } from 'composables/useVnConfirm'; import useNotify from 'src/composables/useNotify.js'; import axios from 'axios'; +import VnTable from 'src/components/VnTable/VnTable.vue'; const route = useRoute(); const router = useRouter(); @@ -33,7 +34,8 @@ const stateBtnDropdownRef = ref(null); const arrayData = useArrayData('ticketData'); const { store } = arrayData; - +const selectedRows = ref([]); +const hasSelectedRows = computed(() => selectedRows.value.length > 0); const ticketConfig = ref(null); const isLocked = ref(false); const isTicketEditable = ref(false); @@ -56,86 +58,104 @@ watch( const columns = computed(() => [ { - label: '', + align: 'left', name: 'statusIcons', - align: 'left', + hidden: true, }, { - label: '', - name: 'picture', - align: 'left', + align: 'center', + label: t('lines.image'), + name: 'image', + columnField: { + component: VnImg, + attrs: (id) => { + return { + id, + width: '50px', + }; + }, + }, + columnFilter: false, }, { + align: 'left', label: t('ticketSale.visible'), name: 'visible', - field: 'visible', - align: 'left', - sortable: true, + format: (row, dashIfEmpty) => dashIfEmpty(row.visible), + hidden: true, }, { + align: 'left', label: t('ticketSale.available'), name: 'available', - field: 'available', - align: 'left', - sortable: true, + format: (row, dashIfEmpty) => dashIfEmpty(row.available), + hidden: true, }, { + align: 'left', label: t('ticketSale.id'), name: 'itemFk', - field: 'itemFk', - align: 'left', - sortable: true, + hidden: true, }, { + align: 'left', label: t('ticketSale.quantity'), name: 'quantity', - field: 'quantity', - align: 'left', - sortable: true, + cardVisible: true, + format: (row) => toCurrency(row.quantity), + hidden: true, }, { + align: 'left', label: t('ticketSale.item'), name: 'item', - field: 'item', - align: 'left', - sortable: true, + format: (row) => row?.item?.name, + columnClass: 'expand', + cardVisible: true, + hidden: true, }, { + align: 'left', label: t('ticketSale.price'), name: 'price', - field: 'price', - align: 'left', - sortable: true, - format: (val) => toCurrency(val), + cardVisible: true, + format: (row) => toCurrency(row.price), + hidden: true, }, { + align: 'left', label: t('ticketSale.discount'), name: 'discount', - field: 'discount', - align: 'left', - sortable: true, + cardVisible: true, + format: (row) => toPercentage(row.discount), + hidden: true, }, { + align: 'left', label: t('ticketSale.amount'), name: 'amount', - field: 'amount', - align: 'left', - sortable: true, - format: (val) => toCurrency(val), + format: (row) => parseInt(row.amount * row.quantity), + hidden: true, }, { + align: 'left', label: t('ticketSale.packaging'), name: 'itemPackingTypeFk', - field: 'item', - align: 'left', - sortable: true, - format: (val) => dashIfEmpty(val?.itemPackingTypeFk), + cardVisible: true, + format: (row, dashIfEmpty) => dashIfEmpty(row?.item?.itemPackingTypeFk), + hidden: true, }, { - label: '', - name: 'history', - align: 'left', - columnFilter: null, + align: 'right', + name: 'tableActions', + actions: [ + { + title: t('ticketSale.history'), + icon: 'history', + isPrimary: true, + action: (row) => goToLog(row.id), + }, + ], }, ]); @@ -478,7 +498,7 @@ onUnmounted(() => (stateStore.rightDrawer = false)); :ticket="store.data" :is-ticket-editable="isTicketEditable" :sales="selectedValidSales" - :disable="!selectedSales.length" + :disable="!hasSelectedRows" :mana="mana" :ticket-config="ticketConfig" @get-mana="getMana()" @@ -487,7 +507,7 @@ onUnmounted(() => (stateStore.rightDrawer = false)); {{ t('Transfer lines') }} @@ -540,17 +560,21 @@ onUnmounted(() => (stateStore.rightDrawer = false)); - + -