From ae76bd0b0e524035a3fe92aa73bd2a819bab1c0c Mon Sep 17 00:00:00 2001 From: Jon Date: Mon, 16 Sep 2024 12:58:06 +0200 Subject: [PATCH] refactor: refs #6346 wagons to VnTable --- src/pages/Wagon/Type/WagonTypeList.vue | 105 +++++++------- src/pages/Wagon/WagonList.vue | 184 +++++++++++++++++-------- 2 files changed, 186 insertions(+), 103 deletions(-) diff --git a/src/pages/Wagon/Type/WagonTypeList.vue b/src/pages/Wagon/Type/WagonTypeList.vue index 7615dea02..2f0d55fbe 100644 --- a/src/pages/Wagon/Type/WagonTypeList.vue +++ b/src/pages/Wagon/Type/WagonTypeList.vue @@ -2,14 +2,13 @@ import { ref, computed } from 'vue'; import axios from 'axios'; import { useQuasar } from 'quasar'; -import VnPaginate from 'src/components/ui/VnPaginate.vue'; import { useArrayData } from 'src/composables/useArrayData'; import { useI18n } from 'vue-i18n'; import { useRouter } from 'vue-router'; -import CardList from 'components/ui/CardList.vue'; import FormModelPopup from 'src/components/FormModelPopup.vue'; import VnInput from 'src/components/common/VnInput.vue'; import VnRow from 'src/components/ui/VnRow.vue'; +import VnTable from 'src/components/VnTable/VnTable.vue'; const quasar = useQuasar(); const arrayData = useArrayData('WagonTypeList'); @@ -17,7 +16,7 @@ const store = arrayData.store; const dialog = ref(); const { push } = useRouter(); const { t } = useI18n(); -const paginate = ref(); +const tableRef = ref(); const initialData = computed(() => { return { @@ -25,10 +24,46 @@ const initialData = computed(() => { }; }); -function reloadData() { - initialData.value.name = null; - paginate.value.fetch(); -} +const columns = computed(() => [ + { + align: 'left', + name: 'id', + label: t('ID'), + isId: true, + cardVisible: true, + }, + { + align: 'left', + name: 'name', + label: t('Name'), + isTitle: true, + }, + { + align: 'left', + name: 'divisible', + label: t('Divisible'), + cardVisible: true, + component: 'checkbox', + }, + { + align: 'right', + name: 'tableActions', + actions: [ + { + title: t('components.smartCard.openCard'), + icon: 'arrow_forward', + isPrimary: true, + action: (row) => navigate(row.id, row.name), + }, + { + title: t('wagon.list.remove'), + icon: 'delete', + isPrimary: true, + action: (row) => remove(row), + }, + ], + }, +]); function navigate(id, name) { push({ path: `/wagon/type/${id}/edit`, query: { name } }); @@ -41,51 +76,25 @@ async function remove(row) { type: 'positive', }); store.data.splice(store.data.indexOf(row), 1); + window.location.reload(); }