This commit is contained in:
parent
9b1554b123
commit
342b80032b
|
@ -26,7 +26,8 @@ const router = useRouter();
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const { getTokenMultimedia } = useSession();
|
const { getTokenMultimedia } = useSession();
|
||||||
const token = getTokenMultimedia();
|
const token = getTokenMultimedia();
|
||||||
|
const amount = ref();
|
||||||
|
const amountClaimed = ref();
|
||||||
const $props = defineProps({
|
const $props = defineProps({
|
||||||
id: {
|
id: {
|
||||||
type: Number,
|
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([
|
const detailsColumns = ref([
|
||||||
{
|
{
|
||||||
name: 'item',
|
name: 'item',
|
||||||
|
@ -100,7 +118,11 @@ const detailsColumns = ref([
|
||||||
sortable: true,
|
sortable: true,
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
function totalRow({ price, quantity, discount }) {
|
||||||
|
const amount = price * quantity;
|
||||||
|
const appliedDiscount = (discount * amount) / 100;
|
||||||
|
return amount - appliedDiscount;
|
||||||
|
}
|
||||||
const markerLabels = [
|
const markerLabels = [
|
||||||
{ value: 1, label: t('claim.company') },
|
{ value: 1, label: t('claim.company') },
|
||||||
{ value: 5, label: t('claim.person') },
|
{ value: 5, label: t('claim.person') },
|
||||||
|
@ -326,8 +348,10 @@ function claimUrl(section) {
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</QCard>
|
</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')" />
|
<VnTitle :url="claimUrl('lines')" :text="t('claim.details')" />
|
||||||
|
{{ salesClaimed }}
|
||||||
|
|
||||||
<QTable
|
<QTable
|
||||||
:columns="detailsColumns"
|
:columns="detailsColumns"
|
||||||
:rows="salesClaimed"
|
:rows="salesClaimed"
|
||||||
|
|
Loading…
Reference in New Issue