feat: refs #7553 ticket component to vntable and fixed minor errors
gitea/salix-front/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Jon Elias 2024-09-06 13:59:50 +02:00
parent e962063753
commit 0e5607d685
5 changed files with 338 additions and 366 deletions

View File

@ -4,7 +4,6 @@ import { useI18n } from 'vue-i18n';
import ItemDescriptorProxy from 'src/pages/Item/Card/ItemDescriptorProxy.vue'; import ItemDescriptorProxy from 'src/pages/Item/Card/ItemDescriptorProxy.vue';
import FetchedTags from 'components/ui/FetchedTags.vue'; import FetchedTags from 'components/ui/FetchedTags.vue';
import RightMenu from 'src/components/common/RightMenu.vue';
import FetchData from 'components/FetchData.vue'; import FetchData from 'components/FetchData.vue';
import { useStateStore } from 'stores/useStateStore'; import { useStateStore } from 'stores/useStateStore';
@ -145,8 +144,7 @@ onUnmounted(() => (stateStore.rightDrawer = false));
@on-fetch="(data) => (ticketUpdateActions = data)" @on-fetch="(data) => (ticketUpdateActions = data)"
auto-load auto-load
/> />
<RightMenu> <QDrawer side="right" :width="270" v-model="stateStore.rightDrawer">
<template #right-panel>
<QCard <QCard
class="q-pa-md q-mb-md q-ma-md color-vn-text" class="q-pa-md q-mb-md q-ma-md color-vn-text"
bordered bordered
@ -220,8 +218,7 @@ onUnmounted(() => (stateStore.rightDrawer = false));
</QIcon> </QIcon>
</QCardSection> </QCardSection>
</QCard> </QCard>
</template> </QDrawer>
</RightMenu>
<QTable <QTable
:visible-columns="showMovablecolumn" :visible-columns="showMovablecolumn"
:rows="rows" :rows="rows"

View File

@ -5,15 +5,16 @@ import { useRoute } from 'vue-router';
import ItemDescriptorProxy from 'src/pages/Item/Card/ItemDescriptorProxy.vue'; import ItemDescriptorProxy from 'src/pages/Item/Card/ItemDescriptorProxy.vue';
import FetchedTags from 'components/ui/FetchedTags.vue'; import FetchedTags from 'components/ui/FetchedTags.vue';
import RightMenu from 'src/components/common/RightMenu.vue';
import FetchData from 'components/FetchData.vue'; import FetchData from 'components/FetchData.vue';
import ZoneDescriptorProxy from 'src/pages/Zone/Card/ZoneDescriptorProxy.vue'; import ZoneDescriptorProxy from 'src/pages/Zone/Card/ZoneDescriptorProxy.vue';
import VnImg from 'src/components/ui/VnImg.vue';
import { useStateStore } from 'stores/useStateStore'; import { useStateStore } from 'stores/useStateStore';
import { dashIfEmpty } from 'src/filters'; import { dashIfEmpty } from 'src/filters';
import { useArrayData } from 'composables/useArrayData'; import { useArrayData } from 'composables/useArrayData';
import { toCurrency } from 'filters/index'; import { toCurrency } from 'filters/index';
import axios from 'axios'; import axios from 'axios';
import VnTable from 'src/components/VnTable/VnTable.vue';
const route = useRoute(); const route = useRoute();
const stateStore = useStateStore(); const stateStore = useStateStore();
@ -75,32 +76,39 @@ const columns = computed(() => [
name: 'item', name: 'item',
align: 'left', align: 'left',
}, },
{
align: 'left',
label: t('lines.image'),
name: 'image',
columnField: {
component: VnImg,
attrs: (id) => {
return {
id,
width: '50px',
};
},
},
columnFilter: false,
},
{ {
label: t('ticketComponents.description'), label: t('ticketComponents.description'),
name: 'description', name: 'description',
align: 'left', align: 'left',
columnClass: 'expand',
}, },
{ {
label: t('ticketComponents.quantity'), label: t('ticketComponents.quantity'),
name: 'quantity', name: 'quantity',
field: 'quantity', field: 'quantity',
align: 'left', align: 'left',
format: (val) => dashIfEmpty(val), format: (row) => dashIfEmpty(row.quantity),
}, },
{ {
label: t('ticketComponents.serie'), label: t('ticketComponents.serie'),
name: 'serie', name: 'serie',
align: 'left', align: 'left',
}, format: (row) => dashIfEmpty(row.serie),
{
label: t('ticketComponents.components'),
name: 'components',
align: 'left',
},
{
label: t('ticketComponents.import'),
name: 'import',
align: 'left',
}, },
{ {
label: t('ticketComponents.total'), label: t('ticketComponents.total'),
@ -174,14 +182,8 @@ onUnmounted(() => (stateStore.rightDrawer = false));
@on-fetch="(data) => (components = data)" @on-fetch="(data) => (components = data)"
auto-load auto-load
/> />
<RightMenu> <QDrawer side="right" :width="270" v-model="stateStore.rightDrawer">
<template #right-panel> <QCard class="q-pa-sm color-vn-text" bordered flat style="border-color: black">
<QCard
class="q-pa-sm color-vn-text"
bordered
flat
style="border-color: black"
>
<QCardSection horizontal> <QCardSection horizontal>
<span class="text-weight-bold text-subtitle1 text-center full-width"> <span class="text-weight-bold text-subtitle1 text-center full-width">
{{ t('ticketComponents.total') }} {{ t('ticketComponents.total') }}
@ -200,12 +202,7 @@ onUnmounted(() => (stateStore.rightDrawer = false));
<span>{{ toCurrency(getTotal) }}</span> <span>{{ toCurrency(getTotal) }}</span>
</QCardSection> </QCardSection>
</QCard> </QCard>
<QCard <QCard class="q-pa-sm color-vn-text" bordered flat style="border-color: black">
class="q-pa-sm color-vn-text"
bordered
flat
style="border-color: black"
>
<QCardSection horizontal> <QCardSection horizontal>
<span class="text-weight-bold text-subtitle1 text-center full-width"> <span class="text-weight-bold text-subtitle1 text-center full-width">
{{ t('ticketComponents.components') }} {{ t('ticketComponents.components') }}
@ -224,12 +221,7 @@ onUnmounted(() => (stateStore.rightDrawer = false));
}}</span> }}</span>
</QCardSection> </QCardSection>
</QCard> </QCard>
<QCard <QCard class="q-pa-sm color-vn-text" bordered flat style="border-color: black">
class="q-pa-sm color-vn-text"
bordered
flat
style="border-color: black"
>
<QCardSection horizontal> <QCardSection horizontal>
<span class="text-weight-bold text-subtitle1 text-center full-width"> <span class="text-weight-bold text-subtitle1 text-center full-width">
{{ t('ticketComponents.zoneBreakdown') }} {{ t('ticketComponents.zoneBreakdown') }}
@ -269,12 +261,7 @@ onUnmounted(() => (stateStore.rightDrawer = false));
<span>{{ dashIfEmpty(ticketData?.packages) }}</span> <span>{{ dashIfEmpty(ticketData?.packages) }}</span>
</QCardSection> </QCardSection>
</QCard> </QCard>
<QCard <QCard class="q-pa-sm color-vn-text" bordered flat style="border-color: black">
class="q-pa-sm color-vn-text"
bordered
flat
style="border-color: black"
>
<QCardSection horizontal> <QCardSection horizontal>
<span class="text-weight-bold text-subtitle1 text-center full-width"> <span class="text-weight-bold text-subtitle1 text-center full-width">
{{ t('ticketComponents.theoricalCost') }} {{ t('ticketComponents.theoricalCost') }}
@ -287,68 +274,74 @@ onUnmounted(() => (stateStore.rightDrawer = false));
<span>{{ toCurrency(theoricalCost, 'EUR', 2) }}</span> <span>{{ toCurrency(theoricalCost, 'EUR', 2) }}</span>
</QCardSection> </QCardSection>
</QCard> </QCard>
</template> </QDrawer>
</RightMenu> <VnTable
<QTable ref="tableRef"
:rows="components" data-key="TicketComponents"
url="Sales"
:user-filter="salesFilter"
:columns="columns" :columns="columns"
row-key="id" :right-search="false"
:pagination="{ rowsPerPage: 0 }" auto-load
class="full-width q-mt-md" :disable-option="{ card: true }"
:no-data-label="t('globals.noResults')" :column-search="false"
> >
<template #body-cell-item="{ row }"> <template #column-item="{ row }">
<QTd @click.stop class="link"> <span @click.stop flat class="link">
<QBtn flat> {{ row.itemFk }}
<span>{{ row.itemFk }}</span>
<ItemDescriptorProxy :id="row.itemFk" /> <ItemDescriptorProxy :id="row.itemFk" />
</QBtn> </span>
</QTd>
</template> </template>
<template #body-cell-description="{ row }"> <template #column-image="{ row }">
<QTd> <div class="image-wrapper">
<VnImg :id="parseInt(row?.item?.id)" class="rounded" />
</div>
</template>
<template #column-description="{ row }">
<div class="column"> <div class="column">
<span>{{ row.item.name }}</span> <span>{{ row.item.name }}</span>
<span class="color-vn-label">{{ row.item.subName }}</span> <span class="color-vn-label">{{ row.item.subName }}</span>
<FetchedTags :item="row.item" /> <FetchedTags :item="row.item" />
</div> </div>
</QTd>
</template> </template>
<template #body-cell-serie="{ row }"> <template #column-serie="{ row }">
<QTd>
<div class="column"> <div class="column">
<span v-for="(saleComponent, index) in row.components" :key="index"> <span v-for="(saleComponent, index) in row.components" :key="index">
{{ saleComponent.component?.componentType?.name }} {{ saleComponent.component?.componentType?.name }}
</span> </span>
</div> </div>
</QTd>
</template> </template>
<template #body-cell-components="{ row }"> <!-- <template #column-components="{ row }">
<QTd>
<div class="column"> <div class="column">
<span v-for="(saleComponent, index) in row.components" :key="index"> <span v-for="(saleComponent, index) in row.components" :key="index">
{{ saleComponent.component?.name }} {{ saleComponent.component?.name }}
</span> </span>
</div> </div>
</QTd> </template> -->
</template> <!-- <template #column-import="{ row }">
<template #body-cell-import="{ row }"> <div class="column text-left">
<QTd>
<div class="column text-right">
<span v-for="(saleComponent, index) in row.components" :key="index"> <span v-for="(saleComponent, index) in row.components" :key="index">
{{ toCurrency(saleComponent.value, 'EUR', 3) }} {{ toCurrency(saleComponent.value, 'EUR', 3) }}
</span> </span>
</div> </div>
</QTd> </template> -->
</template> <template #column-total="{ row }">
<template #body-cell-total="{ row }"> <div class="column">
<QTd>
<div class="column text-right">
<span v-for="(saleComponent, index) in row.components" :key="index"> <span v-for="(saleComponent, index) in row.components" :key="index">
{{ toCurrency(saleComponent.value * row.quantity, 'EUR', 3) }} {{ toCurrency(saleComponent.value * row.quantity, 'EUR', 3) }}
<QTooltip>
{{ saleComponent.component?.name }}:
{{ toCurrency(saleComponent.value, 'EUR', 3) }}
</QTooltip>
</span> </span>
</div> </div>
</QTd>
</template> </template>
</QTable> </VnTable>
</template> </template>
<style lang="scss" scoped>
.image-wrapper {
width: 40px;
height: 40px;
}
</style>

View File

@ -14,8 +14,11 @@ import VnSelect from 'src/components/common/VnSelect.vue';
import FetchData from 'src/components/FetchData.vue'; import FetchData from 'src/components/FetchData.vue';
import { useVnConfirm } from 'composables/useVnConfirm'; import { useVnConfirm } from 'composables/useVnConfirm';
import useNotify from 'src/composables/useNotify.js'; import useNotify from 'src/composables/useNotify.js';
import { onMounted } from 'vue';
import { useStateStore } from 'src/stores/useStateStore';
const route = useRoute(); const route = useRoute();
const stateStore = useStateStore();
const { t } = useI18n(); const { t } = useI18n();
const tableRef = ref(); const tableRef = ref();
const attendersOptions = ref([]); const attendersOptions = ref([]);
@ -84,14 +87,12 @@ const columns = computed(() => [
condition: () => true, condition: () => true,
}, },
isId: true, isId: true,
hidden: true,
}, },
{ {
align: 'left', align: 'left',
label: t('purchaseRequest.description'), label: t('purchaseRequest.description'),
name: 'description', name: 'description',
columnClass: 'expand', columnClass: 'expand',
hidden: true,
}, },
{ {
align: 'left', align: 'left',
@ -99,7 +100,6 @@ const columns = computed(() => [
name: 'created', name: 'created',
format: (row) => toDateFormat(row.created), format: (row) => toDateFormat(row.created),
cardVisible: true, cardVisible: true,
hidden: true,
}, },
{ {
align: 'left', align: 'left',
@ -107,7 +107,6 @@ const columns = computed(() => [
name: 'requesterFk', name: 'requesterFk',
cardVisible: true, cardVisible: true,
format: (row) => dashIfEmpty(row.requester?.user?.nickname), format: (row) => dashIfEmpty(row.requester?.user?.nickname),
hidden: true,
}, },
{ {
align: 'left', align: 'left',
@ -115,33 +114,28 @@ const columns = computed(() => [
name: 'attenderFk', name: 'attenderFk',
cardVisible: true, cardVisible: true,
format: (row) => dashIfEmpty(row.atender?.user?.nickname), format: (row) => dashIfEmpty(row.atender?.user?.nickname),
hidden: true,
}, },
{ {
align: 'left', align: 'left',
label: t('purchaseRequest.quantity'), label: t('purchaseRequest.quantity'),
name: 'quantity', name: 'quantity',
hidden: true,
}, },
{ {
align: 'left', align: 'left',
label: t('purchaseRequest.price'), label: t('purchaseRequest.price'),
name: 'price', name: 'price',
hidden: true,
}, },
{ {
align: 'left', align: 'left',
label: t('purchaseRequest.saleFk'), label: t('purchaseRequest.saleFk'),
name: 'saleFk', name: 'saleFk',
cardVisible: true, cardVisible: true,
hidden: true,
}, },
{ {
align: 'left', align: 'left',
label: t('purchaseRequest.state'), label: t('purchaseRequest.state'),
name: 'isOk', name: 'isOk',
cardVisible: true, cardVisible: true,
isHidden: true,
}, },
{ {
align: 'right', align: 'right',
@ -186,6 +180,8 @@ async function removeLine(id) {
console.error('Error ', err); console.error('Error ', err);
} }
} }
onMounted(() => (stateStore.rightDrawer = false));
</script> </script>
<template> <template>
@ -212,6 +208,7 @@ async function removeLine(id) {
:columns="columns" :columns="columns"
:is-editable="true" :is-editable="true"
:right-search="false" :right-search="false"
:column-search="false"
auto-load auto-load
> >
<template #column-description="{ row }"> <template #column-description="{ row }">

View File

@ -63,7 +63,6 @@ const columns = computed(() => [
{ {
align: 'left', align: 'left',
name: 'statusIcons', name: 'statusIcons',
hidden: true,
}, },
{ {
align: 'center', align: 'center',
@ -85,20 +84,17 @@ const columns = computed(() => [
label: t('ticketSale.visible'), label: t('ticketSale.visible'),
name: 'visible', name: 'visible',
format: (row, dashIfEmpty) => dashIfEmpty(row.visible), format: (row, dashIfEmpty) => dashIfEmpty(row.visible),
hidden: true,
}, },
{ {
align: 'left', align: 'left',
label: t('ticketSale.available'), label: t('ticketSale.available'),
name: 'available', name: 'available',
format: (row, dashIfEmpty) => dashIfEmpty(row.available), format: (row, dashIfEmpty) => dashIfEmpty(row.available),
hidden: true,
}, },
{ {
align: 'left', align: 'left',
label: t('ticketSale.id'), label: t('ticketSale.id'),
name: 'itemFk', name: 'itemFk',
hidden: true,
}, },
{ {
align: 'left', align: 'left',
@ -106,7 +102,6 @@ const columns = computed(() => [
name: 'quantity', name: 'quantity',
cardVisible: true, cardVisible: true,
format: (row) => toCurrency(row.quantity), format: (row) => toCurrency(row.quantity),
hidden: true,
}, },
{ {
align: 'left', align: 'left',
@ -115,7 +110,6 @@ const columns = computed(() => [
format: (row) => row?.item?.name, format: (row) => row?.item?.name,
columnClass: 'expand', columnClass: 'expand',
cardVisible: true, cardVisible: true,
hidden: true,
}, },
{ {
align: 'left', align: 'left',
@ -123,7 +117,6 @@ const columns = computed(() => [
name: 'price', name: 'price',
cardVisible: true, cardVisible: true,
format: (row) => toCurrency(row.price), format: (row) => toCurrency(row.price),
hidden: true,
}, },
{ {
align: 'left', align: 'left',
@ -131,14 +124,12 @@ const columns = computed(() => [
name: 'discount', name: 'discount',
cardVisible: true, cardVisible: true,
format: (row) => toPercentage(row.discount), format: (row) => toPercentage(row.discount),
hidden: true,
}, },
{ {
align: 'left', align: 'left',
label: t('ticketSale.amount'), label: t('ticketSale.amount'),
name: 'amount', name: 'amount',
format: (row) => parseInt(row.amount * row.quantity), format: (row) => parseInt(row.amount * row.quantity),
hidden: true,
}, },
{ {
align: 'left', align: 'left',
@ -146,7 +137,6 @@ const columns = computed(() => [
name: 'itemPackingTypeFk', name: 'itemPackingTypeFk',
cardVisible: true, cardVisible: true,
format: (row, dashIfEmpty) => dashIfEmpty(row?.item?.itemPackingTypeFk), format: (row, dashIfEmpty) => dashIfEmpty(row?.item?.itemPackingTypeFk),
hidden: true,
}, },
{ {
align: 'right', align: 'right',
@ -578,10 +568,10 @@ async function save(item) {
selection: 'multiple', selection: 'multiple',
}" }"
:right-search="false" :right-search="false"
:column-search="false"
auto-load auto-load
> >
<template #column-statusIcons="{ row }"> <template #column-statusIcons="{ row }">
<QTd class="q-gutter-x-xs">
<router-link <router-link
v-if="row.claim?.claimFk" v-if="row.claim?.claimFk"
:to="{ name: 'ClaimBasicData', params: { id: row.claim?.claimFk } }" :to="{ name: 'ClaimBasicData', params: { id: row.claim?.claimFk } }"
@ -623,7 +613,6 @@ async function save(item) {
{{ t('ticketSale.hasComponentLack') }} {{ t('ticketSale.hasComponentLack') }}
</QTooltip> </QTooltip>
</QIcon> </QIcon>
</QTd>
</template> </template>
<template #column-image="{ row }"> <template #column-image="{ row }">
<div class="image-wrapper"> <div class="image-wrapper">
@ -677,7 +666,6 @@ async function save(item) {
</VnSelect> </VnSelect>
</template> </template>
<template #column-quantity="{ row }"> <template #column-quantity="{ row }">
<QTd @click.stop>
<VnInput <VnInput
v-if="isTicketEditable" v-if="isTicketEditable"
v-model.number="row.quantity" v-model.number="row.quantity"
@ -686,10 +674,8 @@ async function save(item) {
@focus="edit.oldQuantity = row.quantity" @focus="edit.oldQuantity = row.quantity"
/> />
<span v-else>{{ row.quantity }}</span> <span v-else>{{ row.quantity }}</span>
</QTd>
</template> </template>
<template #column-price="{ row }"> <template #column-price="{ row }">
<QTd>
<template v-if="isTicketEditable && row.id"> <template v-if="isTicketEditable && row.id">
<QBtn flat class="link" dense @click="onOpenEditPricePopover(row)"> <QBtn flat class="link" dense @click="onOpenEditPricePopover(row)">
{{ toCurrency(row.price) }} {{ toCurrency(row.price) }}
@ -708,10 +694,8 @@ async function save(item) {
</TicketEditManaProxy> </TicketEditManaProxy>
</template> </template>
<span v-else>{{ toCurrency(row.price) }}</span> <span v-else>{{ toCurrency(row.price) }}</span>
</QTd>
</template> </template>
<template #column-discount="{ row }"> <template #column-discount="{ row }">
<QTd>
<template v-if="!isLocked && row.id"> <template v-if="!isLocked && row.id">
<QBtn flat class="link" dense @click="onOpenEditDiscountPopover(row)"> <QBtn flat class="link" dense @click="onOpenEditDiscountPopover(row)">
{{ toPercentage(row.discount / 100) }} {{ toPercentage(row.discount / 100) }}
@ -729,7 +713,6 @@ async function save(item) {
</TicketEditManaProxy> </TicketEditManaProxy>
</template> </template>
<span v-else>{{ toPercentage(row.discount / 100) }}</span> <span v-else>{{ toPercentage(row.discount / 100) }}</span>
</QTd>
</template> </template>
<template #column-amount="{ row }"> <template #column-amount="{ row }">
{{ toCurrency(row.quantity * row.price) }} {{ toCurrency(row.quantity * row.price) }}

View File

@ -1,5 +1,5 @@
<script setup> <script setup>
import { ref, computed, onUnmounted, watch, nextTick } from 'vue'; import { ref, computed, onMounted, onUnmounted, watch, nextTick } from 'vue';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import { useRoute } from 'vue-router'; import { useRoute } from 'vue-router';
@ -93,6 +93,8 @@ const applyVolumes = async (salesData) => {
} }
}; };
onMounted(() => (stateStore.rightDrawer = false));
onUnmounted(() => (stateStore.rightDrawer = false)); onUnmounted(() => (stateStore.rightDrawer = false));
</script> </script>