feat: add ClaimSummaryAction
gitea/salix-front/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Alex Moreno 2024-07-05 10:51:20 +02:00
parent d3ea1986d5
commit 3a117a9f0e
6 changed files with 123 additions and 134 deletions

View File

@ -138,14 +138,6 @@ const showFilter = computed(
); );
</script> </script>
<template> <template>
<div
v-if="showTitle"
class="q-pt-sm q-px-sm ellipsis"
:class="`text-${column?.align ?? 'left'}`"
:style="!showFilter ? { 'min-height': 72 + 'px' } : ''"
>
{{ column?.label }}
</div>
<div v-if="showFilter" class="full-width" :class="alignRow()"> <div v-if="showFilter" class="full-width" :class="alignRow()">
<VnTableColumn <VnTableColumn
:column="$props.column" :column="$props.column"

View File

@ -67,6 +67,10 @@ const $props = defineProps({
type: Object, type: Object,
default: () => ({ card: false, table: false }), default: () => ({ card: false, table: false }),
}, },
withoutHeader: {
type: Boolean,
default: false,
},
}); });
const { t } = useI18n(); const { t } = useI18n();
const stateStore = useStateStore(); const stateStore = useStateStore();
@ -268,10 +272,10 @@ defineExpose({
@row-click="(_, row) => rowClickFunction(row)" @row-click="(_, row) => rowClickFunction(row)"
@update:selected="emit('update:selected', $event)" @update:selected="emit('update:selected', $event)"
> >
<template #top-left> <template #top-left v-if="!$props.withoutHeader">
<slot name="top-left"></slot> <slot name="top-left"></slot>
</template> </template>
<template #top-right> <template #top-right v-if="!$props.withoutHeader">
<!-- <QBtn <!-- <QBtn
icon="visibility" icon="visibility"
title="asd" title="asd"
@ -292,15 +296,22 @@ defineExpose({
class="bg-vn-section-color q-ml-md" class="bg-vn-section-color q-ml-md"
dense dense
@click="stateStore.toggleRightDrawer()" @click="stateStore.toggleRightDrawer()"
v-if="$props.rightSearch"
/> />
</template> </template>
<template #header-cell="{ col }"> <template #header-cell="{ col }">
<QTh <QTh auto-width style="min-width: 100px">
auto-width <div
style="min-width: 100px" class="q-pt-sm q-px-sm ellipsis"
v-if="$props.columnSearch" :class="`text-${col?.align ?? 'left'}`"
:style="
$props.columnSearch ? { 'min-height': 72 + 'px' } : ''
"
> >
{{ col?.label }}
</div>
<VnTableFilter <VnTableFilter
v-if="$props.columnSearch"
:column="col" :column="col"
:show-title="true" :show-title="true"
:data-key="$attrs['data-key']" :data-key="$attrs['data-key']"

View File

@ -9,7 +9,7 @@ const state = useState();
const user = state.getUser(); const user = state.getUser();
const $props = defineProps({ const $props = defineProps({
id: { type: Number, default: null }, id: { type: [Number, String], default: null },
addNote: { type: Boolean, default: true }, addNote: { type: Boolean, default: true },
}); });
const claimId = computed(() => $props.id || route.params.id); const claimId = computed(() => $props.id || route.params.id);

View File

@ -15,6 +15,7 @@ import VnTitle from 'src/components/common/VnTitle.vue';
import CustomerDescriptorProxy from 'src/pages/Customer/Card/CustomerDescriptorProxy.vue'; import CustomerDescriptorProxy from 'src/pages/Customer/Card/CustomerDescriptorProxy.vue';
import axios from 'axios'; import axios from 'axios';
import dashIfEmpty from 'src/filters/dashIfEmpty'; import dashIfEmpty from 'src/filters/dashIfEmpty';
import ClaimSummaryAction from 'src/pages/Claim/Card/ClaimSummaryAction.vue';
const route = useRoute(); const route = useRoute();
const router = useRouter(); const router = useRouter();
@ -50,26 +51,26 @@ onMounted(async () => {
const detailsColumns = ref([ const detailsColumns = ref([
{ {
name: 'item', name: 'item',
label: 'claim.summary.item', label: 'claim.item',
field: (row) => row.sale.itemFk, field: (row) => row.sale.itemFk,
sortable: true, sortable: true,
}, },
{ {
name: 'landed', name: 'landed',
label: 'claim.summary.landed', label: 'claim.landed',
field: (row) => row.sale.ticket.landed, field: (row) => row.sale.ticket.landed,
format: (value) => toDate(value), format: (value) => toDate(value),
sortable: true, sortable: true,
}, },
{ {
name: 'quantity', name: 'quantity',
label: 'claim.summary.quantity', label: 'claim.quantity',
field: (row) => row.sale.quantity, field: (row) => row.sale.quantity,
sortable: true, sortable: true,
}, },
{ {
name: 'claimed', name: 'claimed',
label: 'claim.summary.claimed', label: 'claim.claimed',
field: (row) => row.quantity, field: (row) => row.quantity,
sortable: true, sortable: true,
}, },
@ -80,20 +81,20 @@ const detailsColumns = ref([
}, },
{ {
name: 'price', name: 'price',
label: 'claim.summary.price', label: 'claim.price',
field: (row) => row.sale.price, field: (row) => row.sale.price,
sortable: true, sortable: true,
}, },
{ {
name: 'discount', name: 'discount',
label: 'claim.summary.discount', label: 'claim.discount',
field: (row) => row.sale.discount, field: (row) => row.sale.discount,
format: (value) => `${value} %`, format: (value) => `${value} %`,
sortable: true, sortable: true,
}, },
{ {
name: 'total', name: 'total',
label: 'claim.summary.total', label: 'claim.total',
field: ({ sale }) => field: ({ sale }) =>
toCurrency(sale.quantity * sale.price * ((100 - sale.discount) / 100)), toCurrency(sale.quantity * sale.price * ((100 - sale.discount) / 100)),
sortable: true, sortable: true,
@ -113,31 +114,31 @@ function stateColor(code) {
const developmentColumns = ref([ const developmentColumns = ref([
{ {
name: 'claimReason', name: 'claimReason',
label: 'claim.summary.reason', label: 'claim.reason',
field: (row) => row.claimReason.description, field: (row) => row.claimReason.description,
sortable: true, sortable: true,
}, },
{ {
name: 'claimResult', name: 'claimResult',
label: 'claim.summary.result', label: 'claim.result',
field: (row) => row.claimResult.description, field: (row) => row.claimResult.description,
sortable: true, sortable: true,
}, },
{ {
name: 'claimResponsible', name: 'claimResponsible',
label: 'claim.summary.responsible', label: 'claim.responsible',
field: (row) => row.claimResponsible.description, field: (row) => row.claimResponsible.description,
sortable: true, sortable: true,
}, },
{ {
name: 'worker', name: 'worker',
label: 'claim.summary.worker', label: 'claim.worker',
field: (row) => row.worker?.user.nickname, field: (row) => row.worker?.user.nickname,
sortable: true, sortable: true,
}, },
{ {
name: 'claimRedelivery', name: 'claimRedelivery',
label: 'claim.summary.redelivery', label: 'claim.redelivery',
field: (row) => row.claimRedelivery.description, field: (row) => row.claimRedelivery.description,
sortable: true, sortable: true,
}, },
@ -221,16 +222,13 @@ async function changeState(value) {
</QBtnDropdown> </QBtnDropdown>
</template> </template>
<template #body="{ entity: { claim, salesClaimed, developments } }"> <template #body="{ entity: { claim, salesClaimed, developments } }">
<QCard class="vn-one"> <QCard class="vn-one" v-if="$route.name != 'ClaimSummary'">
<VnTitle <VnTitle
:url="`#/claim/${entityId}/basic-data`" :url="`#/claim/${entityId}/basic-data`"
:text="t('globals.pageTitles.basicData')" :text="t('globals.pageTitles.basicData')"
/> />
<VnLv <VnLv :label="t('claim.created')" :value="toDate(claim.created)" />
:label="t('claim.summary.created')" <VnLv :label="t('claim.state')">
:value="toDate(claim.created)"
/>
<VnLv :label="t('claim.summary.state')">
<template #value> <template #value>
<QChip :color="stateColor(claim.claimState.code)" dense> <QChip :color="stateColor(claim.claimState.code)" dense>
{{ claim.claimState.description }} {{ claim.claimState.description }}
@ -245,7 +243,7 @@ async function changeState(value) {
/> />
</template> </template>
</VnLv> </VnLv>
<VnLv :label="t('claim.summary.attendedBy')"> <VnLv :label="t('claim.attendedBy')">
<template #value> <template #value>
<VnUserLink <VnUserLink
:name="claim.worker?.user?.nickname" :name="claim.worker?.user?.nickname"
@ -253,7 +251,7 @@ async function changeState(value) {
/> />
</template> </template>
</VnLv> </VnLv>
<VnLv :label="t('claim.summary.customer')"> <VnLv :label="t('claim.customer')">
<template #value> <template #value>
<span class="link cursor-pointer"> <span class="link cursor-pointer">
{{ claim.client?.name }} {{ claim.client?.name }}
@ -262,15 +260,12 @@ async function changeState(value) {
</template> </template>
</VnLv> </VnLv>
<VnLv <VnLv
:label="t('claim.basicData.pickup')" :label="t('claim.pickup')"
:value="`${dashIfEmpty(claim.pickup)}`" :value="`${dashIfEmpty(claim.pickup)}`"
/> />
</QCard> </QCard>
<QCard class="vn-three"> <QCard class="vn-two">
<VnTitle <VnTitle :url="`#/claim/${entityId}/notes`" :text="t('claim.notes')" />
:url="`#/claim/${entityId}/notes`"
:text="t('claim.summary.notes')"
/>
<ClaimNotes <ClaimNotes
:id="entityId" :id="entityId"
:add-note="false" :add-note="false"
@ -278,53 +273,8 @@ async function changeState(value) {
order="created ASC" order="created ASC"
/> />
</QCard> </QCard>
<QCard class="vn-two" v-if="salesClaimed.length > 0">
<VnTitle
:url="`#/claim/${entityId}/lines`"
:text="t('claim.summary.details')"
/>
<QTable
:columns="detailsColumns"
:rows="salesClaimed"
flat
dense
:rows-per-page-options="[0]"
hide-bottom
>
<template #header="props">
<QTr :props="props">
<QTh v-for="col in props.cols" :key="col.name" :props="props">
{{ t(col.label) }}
</QTh>
</QTr>
</template>
<template #body="props">
<QTr :props="props">
<QTh v-for="col in props.cols" :key="col.name" :props="props">
<span v-if="col.name != 'description'">{{
t(col.value)
}}</span>
<QBtn
v-if="col.name == 'description'"
flat
color="blue"
>{{ col.value }}</QBtn
>
<ItemDescriptorProxy
v-if="col.name == 'description'"
:id="props.row.sale.itemFk"
:sale-fk="props.row.saleFk"
></ItemDescriptorProxy>
</QTh>
</QTr>
</template>
</QTable>
</QCard>
<QCard class="vn-two" v-if="claimDms.length > 0"> <QCard class="vn-two" v-if="claimDms.length > 0">
<VnTitle <VnTitle :url="`#/claim/${entityId}/photos`" :text="t('claim.photos')" />
:url="`#/claim/${entityId}/photos`"
:text="t('claim.summary.photos')"
/>
<div class="container"> <div class="container">
<div <div
class="multimedia-container" class="multimedia-container"
@ -362,11 +312,47 @@ async function changeState(value) {
</div> </div>
</div> </div>
</QCard> </QCard>
<QCard class="vn-two" v-if="salesClaimed.length > 0">
<VnTitle :url="`#/claim/${entityId}/lines`" :text="t('claim.details')" />
<QTable
:columns="detailsColumns"
:rows="salesClaimed"
flat
dense
:rows-per-page-options="[0]"
hide-bottom
>
<template #header="props">
<QTr :props="props">
<QTh v-for="col in props.cols" :key="col.name" :props="props">
{{ t(col.label) }}
</QTh>
</QTr>
</template>
<template #body="props">
<QTr :props="props">
<QTh v-for="col in props.cols" :key="col.name" :props="props">
<span v-if="col.name != 'description'">{{
t(col.value)
}}</span>
<QBtn
v-if="col.name == 'description'"
flat
color="blue"
>{{ col.value }}</QBtn
>
<ItemDescriptorProxy
v-if="col.name == 'description'"
:id="props.row.sale.itemFk"
:sale-fk="props.row.saleFk"
></ItemDescriptorProxy>
</QTh>
</QTr>
</template>
</QTable>
</QCard>
<QCard class="vn-two" v-if="developments.length > 0"> <QCard class="vn-two" v-if="developments.length > 0">
<VnTitle <VnTitle :url="claimUrl + 'development'" :text="t('claim.development')" />
:url="claimUrl + 'development'"
:text="t('claim.summary.development')"
/>
<QTable <QTable
:columns="developmentColumns" :columns="developmentColumns"
:rows="developments" :rows="developments"
@ -385,24 +371,25 @@ async function changeState(value) {
</QTable> </QTable>
</QCard> </QCard>
<QCard class="vn-max"> <QCard class="vn-max">
<VnTitle :url="claimUrl + 'action'" :text="t('claim.summary.actions')" /> <VnTitle :url="claimUrl + 'action'" :text="t('claim.actions')" />
<div id="slider-container" class="q-px-xl q-py-md"> <div id="slider-container" class="q-px-xl q-py-md">
<QSlider <QSlider
v-model="claim.responsibility" v-model="claim.responsibility"
label label
:label-value="t('claim.summary.responsibility')" :label-value="t('claim.responsibility')"
label-always label-always
color="var()" color="var()"
markers markers
:marker-labels="[ :marker-labels="[
{ value: 1, label: t('claim.summary.company') }, { value: 1, label: t('claim.company') },
{ value: 5, label: t('claim.summary.person') }, { value: 5, label: t('claim.person') },
]" ]"
:min="1" :min="1"
:max="5" :max="5"
readonly readonly
/> />
</div> </div>
<ClaimSummaryAction :id="entityId" />
</QCard> </QCard>
<QDialog <QDialog
v-model="multimediaDialog" v-model="multimediaDialog"

View File

@ -1,86 +1,71 @@
<script setup> <script setup>
import { ref, computed, onMounted } from 'vue';
import { useQuasar } from 'quasar';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import { useRoute } from 'vue-router'; import { toDate, toPercentage } from 'filters/index';
import axios from 'axios';
import { useStateStore } from 'src/stores/useStateStore';
import { toDate, toPercentage, toCurrency } from 'filters/index';
import VnTable from 'src/components/VnTable/VnTable.vue'; import VnTable from 'src/components/VnTable/VnTable.vue';
import FetchData from 'src/components/FetchData.vue';
import VnSelect from 'src/components/common/VnSelect.vue';
import ItemDescriptorProxy from 'src/pages/Item/Card/ItemDescriptorProxy.vue'; import ItemDescriptorProxy from 'src/pages/Item/Card/ItemDescriptorProxy.vue';
import TicketDescriptorProxy from 'src/pages/Ticket/Card/TicketDescriptorProxy.vue'; import TicketDescriptorProxy from 'src/pages/Ticket/Card/TicketDescriptorProxy.vue';
import { useArrayData } from 'composables/useArrayData';
const { t } = useI18n(); const { t } = useI18n();
const quasar = useQuasar();
const $props = defineProps({ const $props = defineProps({
id: { id: {
type: Number, type: [Number, String],
required: true, required: true,
}, },
}); });
const columns = computed(() => [ const columns = [
{ {
name: 'id', name: 'itemFk',
label: t('Id item'), label: t('Id item'),
field: (row) => row.itemFk, columnFilter: false,
align: 'left',
}, },
{ {
name: 'ticketFk', name: 'ticketFk',
label: t('Ticket'), label: t('Ticket'),
align: 'center', columnFilter: false,
},
{
name: 'destination',
label: t('Destination'),
field: (row) => row.claimDestinationFk,
align: 'left', align: 'left',
}, },
{ {
name: 'Landed', name: 'claimDestinationFk',
label: t('Destination'),
columnFilter: false,
align: 'left',
},
{
name: 'landed',
label: t('Landed'), label: t('Landed'),
field: (row) => toDate(row.landed), format: (row) => toDate(row.landed),
align: 'left',
}, },
{ {
name: 'quantity', name: 'quantity',
label: t('Quantity'), label: t('Quantity'),
field: (row) => row.quantity, align: 'left',
}, },
{ {
name: 'concept', name: 'concept',
label: t('Description'), label: t('Description'),
field: (row) => row.concept,
align: 'left', align: 'left',
}, },
{ {
name: 'price', name: 'price',
label: t('Price'), label: t('Price'),
field: (row) => row.price, align: 'left',
format: (value) => value,
align: 'center',
}, },
{ {
name: 'discount', name: 'discount',
label: t('Discount'), label: t('Discount'),
field: (row) => row.discount, format: ({ discount }) => toPercentage(discount / 100),
format: (value) => toPercentage(value / 100),
align: 'left', align: 'left',
}, },
{ {
name: 'total', name: 'total',
label: t('Total'), label: t('Total'),
field: (row) => row.total, align: 'left',
format: (value) => value,
align: 'center',
}, },
{ ];
name: 'delete',
},
]);
</script> </script>
<template> <template>
<VnTable <VnTable
@ -94,6 +79,20 @@ const columns = computed(() => [
:filter="{ where: { claimFk: $props.id } }" :filter="{ where: { claimFk: $props.id } }"
:columns="columns" :columns="columns"
:limit="0" :limit="0"
:without-header="true"
auto-load auto-load
/> >
<template #column-itemFk="{ row }">
<span class="link">
{{ row.itemFk }}
<ItemDescriptorProxy :id="row.itemFk" />
</span>
</template>
<template #column-ticketFk="{ row }">
<span class="link">
{{ row.ticketFk }}
<TicketDescriptorProxy :id="row.ticketFk" />
</span>
</template>
</VnTable>
</template> </template>

View File

@ -32,7 +32,7 @@ const entityId = computed(() => {
}); });
const data = ref(useCardDescription()); const data = ref(useCardDescription());
const setData = (entity) => (data.value = useCardDescription(entity.name, entity.id)); const setData = (entity) => (data.value = useCardDescription(entity?.name, entity?.id));
</script> </script>
<template> <template>