fix: refs #7351 fix onFetch
gitea/salix-front/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Carlos Satorres 2025-01-17 08:47:40 +01:00
parent 9b1554b123
commit 342b80032b
1 changed files with 27 additions and 3 deletions

View File

@ -26,7 +26,8 @@ const router = useRouter();
const { t } = useI18n();
const { getTokenMultimedia } = useSession();
const token = getTokenMultimedia();
const amount = ref();
const amountClaimed = ref();
const $props = defineProps({
id: {
type: Number,
@ -47,7 +48,24 @@ const claimDmsFilter = ref({
},
],
});
function onFetch(rows, newRows) {
console.log('rows: ', rows);
console.log('newRows: ', newRows);
if (newRows) rows = newRows;
amount.value = 0;
console.log('amount.value: ', amount.value);
amountClaimed.value = 0;
console.log('amountClaimed.value: ', amountClaimed.value);
if (!rows || !rows.length) return;
for (const row of rows) {
const { sale } = row;
amount.value = amount.value + totalRow(sale);
const price = row.quantity * sale.price;
const discount = (sale.discount * price) / 100;
amountClaimed.value = amountClaimed.value + (price - discount);
}
}
const detailsColumns = ref([
{
name: 'item',
@ -100,7 +118,11 @@ const detailsColumns = ref([
sortable: true,
},
]);
function totalRow({ price, quantity, discount }) {
const amount = price * quantity;
const appliedDiscount = (discount * amount) / 100;
return amount - appliedDiscount;
}
const markerLabels = [
{ value: 1, label: t('claim.company') },
{ value: 5, label: t('claim.person') },
@ -326,8 +348,10 @@ function claimUrl(section) {
</div>
</div>
</QCard>
<QCard class="vn-max" v-if="salesClaimed.length > 0">
<QCard class="vn-max" v-if="salesClaimed.length > 0" @on-fetch="onFetch">
<VnTitle :url="claimUrl('lines')" :text="t('claim.details')" />
{{ salesClaimed }}
<QTable
:columns="detailsColumns"
:rows="salesClaimed"