diff --git a/src/components/VnTable/VnColumn.vue b/src/components/VnTable/VnColumn.vue index 6cd62d83e..70035d6e6 100644 --- a/src/components/VnTable/VnColumn.vue +++ b/src/components/VnTable/VnColumn.vue @@ -8,6 +8,8 @@ import VnSelect from 'components/common/VnSelect.vue'; import VnInput from 'components/common/VnInput.vue'; import VnInputDate from 'components/common/VnInputDate.vue'; import VnComponent from 'components/common/VnComponent.vue'; +import VnDescriptor from 'components/VnTable/VnDescriptor.vue'; +import { QBtn } from 'quasar'; const model = defineModel(undefined, { required: true }); const $props = defineProps({ @@ -102,6 +104,17 @@ const defaultComponents = { icon: { component: markRaw(QIcon), }, + descriptor: { + component: markRaw(VnDescriptor), + attrs: { + class: 'link', + flat: true, + dense: true, + }, + forceAttrs: { + row: $props.row, + }, + }, }; const value = computed(() => { diff --git a/src/components/VnTable/VnDescriptor.vue b/src/components/VnTable/VnDescriptor.vue new file mode 100644 index 000000000..b280c7f6c --- /dev/null +++ b/src/components/VnTable/VnDescriptor.vue @@ -0,0 +1,49 @@ + + + {{ $props.label($props.row) }} + + + + + + diff --git a/src/components/VnTable/VnTable.vue b/src/components/VnTable/VnTable.vue index 493f1480e..7acec4fe7 100644 --- a/src/components/VnTable/VnTable.vue +++ b/src/components/VnTable/VnTable.vue @@ -59,6 +59,10 @@ const $props = defineProps({ type: Boolean, default: false, }, + hasSubtoolbar: { + type: Boolean, + default: true, + }, }); const { t } = useI18n(); const stateStore = useStateStore(); @@ -175,11 +179,14 @@ function columnName(col) { } function getColAlign(col) { - return 'text-' + (col.align ?? 'left') + return 'text-' + (col.align ?? 'left'); } + +const emit = defineEmits(['onFetch', 'update:selected', 'saveChanges']); defineExpose({ reload, redirect: redirectFn, + selected, }); @@ -225,11 +232,18 @@ defineExpose({ :search-url="searchUrl" :disable-infinite-scroll="mode == TABLE_MODE" @save-changes="reload" - :has-subtoolbar="isEditable" + :has-subtoolbar="$attrs['hasSubtoolbar'] ?? isEditable" > + + + rowClickFunction(row)" + @update:selected="$emit('update:selected', $event)" > @@ -477,6 +492,7 @@ defineExpose({ default="input" v-model="data[column.name]" :show-label="true" + component-prop="columnCreate" /> diff --git a/src/pages/Ticket/Negative/TicketLackList.vue b/src/pages/Ticket/Negative/TicketLackList.vue index 6497227c9..f91554f3b 100644 --- a/src/pages/Ticket/Negative/TicketLackList.vue +++ b/src/pages/Ticket/Negative/TicketLackList.vue @@ -2,14 +2,15 @@ import { computed, ref, reactive } from 'vue'; import { useI18n } from 'vue-i18n'; import { useStateStore } from 'stores/useStateStore'; -import VnPaginate from 'components/ui/VnPaginate.vue'; -import TicketLackFilter from 'pages/Ticket/Negative/TicketLackFilter.vue'; -import TicketLackDetail from 'pages/Ticket/Negative/TicketLackDetail.vue'; +// import VnPaginate from 'components/ui/VnPaginate.vue'; +// import TicketLackFilter from 'pages/Ticket/Negative/TicketLackFilter.vue'; +// import TicketLackDetail from 'pages/Ticket/Negative/TicketLackDetail.vue'; // import FetchData from 'components/FetchData.vue'; +import VnTable from 'components/VnTable/VnTable.vue'; import NegativeOriginDialog from 'pages/Ticket/Negative/components/NegativeOriginDialog.vue'; -import TotalNegativeOriginDialog from 'pages/Ticket/Negative/components/TotalNegativeOriginDialog.vue'; -import ItemDescriptorProxy from 'src/pages/Item/Card/ItemDescriptorProxy.vue'; +// import TotalNegativeOriginDialog from 'pages/Ticket/Negative/components/TotalNegativeOriginDialog.vue'; +// import ItemDescriptorProxy from 'src/pages/Item/Card/ItemDescriptorProxy.vue'; import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue'; import { onBeforeMount } from 'vue'; import { dashIfEmpty, toDate, toHour } from 'src/filters'; @@ -17,6 +18,11 @@ import { useRouter } from 'vue-router'; // import { useUserConfig } from 'src/composables/useUserConfig'; import { useState } from 'src/composables/useState'; import { useRole } from 'src/composables/useRole'; +import ItemDescriptorProxy from 'src/pages/Item/Card/ItemDescriptorProxy.vue'; +// import TicketLackDetail from './TicketLackDetail.vue'; +// import { useSummaryDialog } from 'src/composables/useSummaryDialog'; + +// const { viewSummary } = useSummaryDialog(); // const DEFAULT_WAREHOUSE = 'Algemesi'; const router = useRouter(); @@ -25,7 +31,7 @@ const stateStore = useStateStore(); const { t } = useI18n(); const selectedRows = ref([]); const showNegativeOriginDialog = ref(false); -const showTotalNegativeOriginDialog = ref(false); +// const showTotalNegativeOriginDialog = ref(false); // const showFilterPanel = ref(false); const currentRow = ref(null); // const state = useState(); @@ -34,11 +40,10 @@ const negativeParams = reactive({ days: useRole().likeAny('buyer') ? 2 : 0, warehouseFk: useState().getUser().value.warehouseFk, }); -const viewSummary = (row) => { - const id = row.itemFk; +const redirectToCreateView = ({ itemFk }) => { // stateStore.rightDrawer = false; // currentRow.value = row; - router.push({ name: 'NegativeDetail', params: { id } }); + router.push({ name: 'NegativeDetail', params: { id: itemFk } }); }; const originDialogRef = ref(); // const totalNegativeDialogRef = ref(); @@ -47,15 +52,18 @@ const columns = computed(() => [ name: 'date', label: t('negative.date'), field: 'timed', - format: (val) => toDate(val), + format: ({ timed }) => toDate(timed), sortable: true, + cardVisible: true, + isId: true, }, { name: 'timed', label: t('negative.timed'), field: 'timed', - format: (val) => toHour(val), + format: ({ timed }) => toHour(timed), sortable: true, + cardVisible: true, }, { name: 'itemFk', @@ -67,9 +75,20 @@ const columns = computed(() => [ name: 'longName', label: t('negative.longName'), field: ({ longName }) => longName, - align: 'center', + columnField: { + component: 'descriptor', + attrs: { + label: ({ longName }) => longName, + proxy: { + key: 'itemFk', + component: ItemDescriptorProxy, + }, + }, + }, + sortable: true, headerStyle: 'width: 350px', + cardVisible: true, }, { name: 'producer', @@ -83,34 +102,44 @@ const columns = computed(() => [ label: t('negative.colour'), field: ({ inkFk }) => inkFk, sortable: true, + cardVisible: true, }, { name: 'size', label: t('negative.size'), field: ({ size }) => size, sortable: true, + cardVisible: true, }, { name: 'category', label: t('negative.origen'), field: ({ category }) => dashIfEmpty(category), sortable: true, + cardVisible: true, }, { name: 'lack', label: t('negative.lack'), field: ({ lack }) => lack, - align: 'center', + sortable: true, headerStyle: 'padding-left: 33px', + cardVisible: true, }, { - name: 'icons', - align: 'center', - field: (row) => row, + align: 'right', + name: 'tableActions', + actions: [ + { + title: t('Client ticket list'), + icon: 'preview', + action: redirectToCreateView, + }, + ], }, ]); -const vnPaginateRef = ref(); +const tableRef = ref(); // const ticketDetailRef = ref(); onBeforeMount(() => { @@ -119,7 +148,7 @@ onBeforeMount(() => { // const handleWarehouses = async (data) => { // negativeParams.warehouse = data.find((w) => w.name === DEFAULT_WAREHOUSE).id; -// await vnPaginateRef.value.fetch(); +// await tableRef.value.fetch(); // showFilterPanel.value = true; // }; @@ -167,88 +196,26 @@ onBeforeMount(() => { - - - - - - - {{ `${rows.length} ${t('globals.results')}` }} - - - - - - - - - - - - - {{ value }} - - - - - - - {{ value }} - {{ value }} - - - - - - - - {{ t('globals.preview') }} - - - - - - - +