refactor: entriesTotals
gitea/salix-front/pipeline/head This commit looks good
Details
gitea/salix-front/pipeline/head This commit looks good
Details
This commit is contained in:
parent
55ac9e9329
commit
879373209e
|
@ -179,33 +179,31 @@ const entriesTableRows = computed(() => {
|
|||
return entries.value;
|
||||
});
|
||||
|
||||
const entriesTotalHb = computed(() =>
|
||||
entriesTableRows.value.reduce((acc, { hb }) => acc + hb, 0)
|
||||
);
|
||||
const entriesTotals = computed(() => {
|
||||
const totals = {
|
||||
hb: 0,
|
||||
freightValue: 0,
|
||||
packageValue: 0,
|
||||
cc: 0,
|
||||
pallet: 0,
|
||||
m3: 0,
|
||||
};
|
||||
|
||||
const entriesTotalFreight = computed(() =>
|
||||
toCurrency(
|
||||
entriesTableRows.value.reduce((acc, { freightValue }) => acc + freightValue, 0)
|
||||
)
|
||||
);
|
||||
entriesTableRows.value.forEach((row) => {
|
||||
for (const key in totals) {
|
||||
totals[key] += row[key] || 0;
|
||||
}
|
||||
});
|
||||
|
||||
const entriesTotalPackageValue = computed(() =>
|
||||
toCurrency(
|
||||
entriesTableRows.value.reduce((acc, { packageValue }) => acc + packageValue, 0)
|
||||
)
|
||||
);
|
||||
|
||||
const entriesTotalCc = computed(() =>
|
||||
entriesTableRows.value.reduce((acc, { cc }) => acc + cc, 0)
|
||||
);
|
||||
|
||||
const entriesTotalPallet = computed(() =>
|
||||
entriesTableRows.value.reduce((acc, { pallet }) => acc + pallet, 0)
|
||||
);
|
||||
|
||||
const entriesTotalM3 = computed(() =>
|
||||
entriesTableRows.value.reduce((acc, { m3 }) => acc + m3, 0)
|
||||
);
|
||||
return {
|
||||
hb: totals.hb.toFixed(2),
|
||||
freight: toCurrency(totals.freightValue),
|
||||
packageValue: toCurrency(totals.packageValue),
|
||||
cc: totals.cc.toFixed(2),
|
||||
pallet: totals.pallet.toFixed(2),
|
||||
m3: totals.m3.toFixed(2),
|
||||
};
|
||||
});
|
||||
|
||||
const getTravelEntries = async (id) => {
|
||||
const { data } = await axios.get(`Travels/${id}/getEntries`);
|
||||
|
@ -368,12 +366,12 @@ const getLink = (param) => `#/travel/${entityId.value}/${param}`;
|
|||
<QTd></QTd>
|
||||
<QTd></QTd>
|
||||
<QTd></QTd>
|
||||
<QTd class="text-bold">{{ entriesTotalHb }}</QTd>
|
||||
<QTd class="text-bold">{{ entriesTotalFreight }}</QTd>
|
||||
<QTd class="text-bold">{{ entriesTotalPackageValue }}</QTd>
|
||||
<QTd class="text-bold">{{ entriesTotalCc }}</QTd>
|
||||
<QTd class="text-bold">{{ entriesTotalPallet }}</QTd>
|
||||
<QTd class="text-bold">{{ entriesTotalM3 }}</QTd>
|
||||
<QTd class="text-bold">{{ entriesTotals.hb }}</QTd>
|
||||
<QTd class="text-bold">{{ entriesTotals.freight }}</QTd>
|
||||
<QTd class="text-bold">{{ entriesTotals.packageValue }}</QTd>
|
||||
<QTd class="text-bold">{{ entriesTotals.cc }}</QTd>
|
||||
<QTd class="text-bold">{{ entriesTotals.pallet }}</QTd>
|
||||
<QTd class="text-bold">{{ entriesTotals.m3 }}</QTd>
|
||||
</template>
|
||||
</QTable>
|
||||
</QCard>
|
||||
|
|
Loading…
Reference in New Issue