From 64ff5e44460be30d3566d8779aa6b76f0fc14f07 Mon Sep 17 00:00:00 2001 From: wbuezas Date: Mon, 8 Apr 2024 11:40:44 -0300 Subject: [PATCH] Add pagination and table actions --- src/pages/Item/ItemList.vue | 212 ++++++++++++++++++++---------------- 1 file changed, 119 insertions(+), 93 deletions(-) diff --git a/src/pages/Item/ItemList.vue b/src/pages/Item/ItemList.vue index 9baf3061a..773cb0771 100644 --- a/src/pages/Item/ItemList.vue +++ b/src/pages/Item/ItemList.vue @@ -11,6 +11,7 @@ import VnSelectFilter from 'src/components/common/VnSelectFilter.vue'; import ItemDescriptorProxy from '../Item/Card/ItemDescriptorProxy.vue'; import WorkerDescriptorProxy from 'src/pages/Worker/Card/WorkerDescriptorProxy.vue'; import ItemSummary from '../Item/Card/ItemSummary.vue'; +import VnPaginate from 'components/ui/VnPaginate.vue'; import { useStateStore } from 'stores/useStateStore'; import { toDate, toCurrency } from 'src/filters'; @@ -18,13 +19,16 @@ import { useSession } from 'composables/useSession'; import { dashIfEmpty } from 'src/filters'; import { useArrayData } from 'composables/useArrayData'; import { useSummaryDialog } from 'src/composables/useSummaryDialog'; +import { useVnConfirm } from 'composables/useVnConfirm'; +import axios from 'axios'; const router = useRouter(); -const session = useSession(); -const token = session.getToken(); +const { getTokenMultimedia } = useSession(); +const token = getTokenMultimedia(); const stateStore = useStateStore(); const { t } = useI18n(); const { viewSummary } = useSummaryDialog(); +const { openConfirmationModal } = useVnConfirm(); const itemTypesOptions = ref([]); const originsOptions = ref([]); @@ -66,13 +70,6 @@ const exprBuilder = (param, value) => { }; const params = reactive({}); -const arrayData = useArrayData('ItemList', { - url: 'Items/filter', - order: ['isActive DESC', 'name', 'id'], - exprBuilder: exprBuilder, -}); -const store = arrayData.store; -const rows = computed(() => store.data); // const getInputEvents = (col) => { // return col.columnFilter.type === 'select' @@ -389,15 +386,25 @@ const redirectToItemSummary = (id) => { // } // }; -const cloneRow = () => { - console.log('cloneRow'); +const cloneItem = async (itemFk) => { + try { + console.log('cloneRow: ', itemFk); + const { data } = await axios.post(`Items/${itemFk}/clone`); + if (!data) return; + router.push({ name: 'ItemTags', params: { id: data.id } }); + } catch (err) { + console.error('Error cloning row', err); + } +}; + +const test = (ev) => { + console.log('test: ', ev); }; onMounted(async () => { stateStore.rightDrawer = true; const filteredColumns = columns.value.filter((col) => col.name !== 'picture'); allColumnNames.value = filteredColumns.map((col) => col.name); - await arrayData.fetch({ append: false }); }); onUnmounted(() => (stateStore.rightDrawer = false)); @@ -440,23 +447,29 @@ onUnmounted(() => (stateStore.rightDrawer = false));
- - - - - - - - - - + + - + {{ t('New item') }} @@ -553,4 +575,8 @@ onUnmounted(() => (stateStore.rightDrawer = false)); es: New item: Nuevo artículo + All it's properties will be copied: Todas sus propiedades serán copiadas + Do you want to clone this item?: ¿Desea clonar este artículo? + Clone: Clonar + Preview: Vista previa