This commit is contained in:
parent
9611ea47cf
commit
561bc557c5
|
@ -30,7 +30,7 @@ const { notify } = useNotify();
|
||||||
const totalRows = ref({});
|
const totalRows = ref({});
|
||||||
const arrayData = useArrayData('SupplierConsumption', {
|
const arrayData = useArrayData('SupplierConsumption', {
|
||||||
url: 'Suppliers/consumption',
|
url: 'Suppliers/consumption',
|
||||||
order: ['itemTypeFk', 'item', 'itemSize'],
|
order: ['itemTypeFk', 'itemName', 'itemSize'],
|
||||||
userFilter: { where: { supplierFk: route.params.id } },
|
userFilter: { where: { supplierFk: route.params.id } },
|
||||||
});
|
});
|
||||||
const headerColumns = computed(() => [
|
const headerColumns = computed(() => [
|
||||||
|
@ -122,11 +122,13 @@ const dateRanges = computed(() => {
|
||||||
});
|
});
|
||||||
|
|
||||||
const reportParams = computed(() => {
|
const reportParams = computed(() => {
|
||||||
return {
|
console.log('reportParams', dateRanges.value);
|
||||||
|
const params = {
|
||||||
recipientId: Number(route.params.id),
|
recipientId: Number(route.params.id),
|
||||||
to: dateRange(dateRanges.value.to)[1],
|
from: dateRange(dateRanges.value.from)[0].toISOString(),
|
||||||
from: dateRange(dateRanges.value.from)[1],
|
to: dateRange(dateRanges.value.to)[1].toISOString(),
|
||||||
};
|
};
|
||||||
|
return params;
|
||||||
});
|
});
|
||||||
|
|
||||||
async function getSupplierConsumptionData() {
|
async function getSupplierConsumptionData() {
|
||||||
|
@ -183,27 +185,27 @@ const sendCampaignMetricsEmail = ({ address }) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const totalEntryPrice = (rows) => {
|
const totalEntryPrice = (rows) => {
|
||||||
let totalPrice = 0;
|
if (!rows) return [];
|
||||||
let totalQuantity = 0;
|
totalRows.value = rows.reduce(
|
||||||
if (!rows) return totalPrice;
|
(acc, row) => {
|
||||||
for (const row of rows) {
|
if (Array.isArray(row.buys)) {
|
||||||
let total = 0;
|
const { total, quantity } = row.buys.reduce(
|
||||||
let quantity = 0;
|
(buyAcc, buy) => {
|
||||||
|
buyAcc.total += buy.total || 0;
|
||||||
if (row.buys) {
|
buyAcc.quantity += buy.quantity || 0;
|
||||||
for (const buy of row.buys) {
|
return buyAcc;
|
||||||
total = total + buy.total;
|
},
|
||||||
quantity = quantity + buy.quantity;
|
{ total: 0, quantity: 0 },
|
||||||
|
);
|
||||||
|
row.total = total;
|
||||||
|
row.quantity = quantity;
|
||||||
|
acc.totalPrice += total;
|
||||||
|
acc.totalQuantity += quantity;
|
||||||
}
|
}
|
||||||
}
|
return acc;
|
||||||
|
},
|
||||||
row.total = total;
|
{ totalPrice: 0, totalQuantity: 0 },
|
||||||
row.quantity = quantity;
|
);
|
||||||
totalPrice = totalPrice + total;
|
|
||||||
totalQuantity = totalQuantity + quantity;
|
|
||||||
}
|
|
||||||
totalRows.value = { totalPrice, totalQuantity };
|
|
||||||
// expanded.value = rows.map((r) => r.id);
|
|
||||||
return rows;
|
return rows;
|
||||||
};
|
};
|
||||||
const tableRef = ref(null);
|
const tableRef = ref(null);
|
||||||
|
@ -212,64 +214,7 @@ onMounted(async () => {
|
||||||
await getSupplierConsumptionData();
|
await getSupplierConsumptionData();
|
||||||
});
|
});
|
||||||
const lastAction = ref(null);
|
const lastAction = ref(null);
|
||||||
const isAction = (action) => {
|
const expanded = ref([]);
|
||||||
if (lastAction.value === action) {
|
|
||||||
lastAction.value = null;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
lastAction.value = action;
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
const isActionExpand = (action) => {
|
|
||||||
if (action === 'expand_all') {
|
|
||||||
return isAction('expand_all');
|
|
||||||
}
|
|
||||||
if (action === 'unfold_all') {
|
|
||||||
return isAction('unfold_all');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
const isActionExpandAll = computed(() => {
|
|
||||||
return isActionExpand('expand_all');
|
|
||||||
});
|
|
||||||
const isActionUnfoldAll = computed(() => {
|
|
||||||
return isActionExpand('unfold_all');
|
|
||||||
});
|
|
||||||
const isActionExpandAllIcon = computed(() => {
|
|
||||||
return isActionExpandAll.value ? 'unfold_less' : 'expand_more';
|
|
||||||
});
|
|
||||||
const isActionUnfoldAllIcon = computed(() => {
|
|
||||||
return isActionUnfoldAll.value ? 'expand_more' : 'unfold_less';
|
|
||||||
});
|
|
||||||
const isActionExpandAllLabel = computed(() => {
|
|
||||||
return isActionExpandAll.value ? t('globals.unfold_all') : t('globals.expand_all');
|
|
||||||
});
|
|
||||||
const isActionUnfoldAllLabel = computed(() => {
|
|
||||||
return isActionUnfoldAll.value ? t('globals.expand_all') : t('globals.unfold_all');
|
|
||||||
});
|
|
||||||
const isActionExpandAllDisabled = computed(() => {
|
|
||||||
return !rows.value.length;
|
|
||||||
});
|
|
||||||
const isActionUnfoldAllDisabled = computed(() => {
|
|
||||||
return !rows.value.length;
|
|
||||||
});
|
|
||||||
const isActionExpandAllTooltip = computed(() => {
|
|
||||||
return isActionExpandAll.value ? t('globals.unfold_all') : t('globals.expand_all');
|
|
||||||
});
|
|
||||||
const isActionUnfoldAllTooltip = computed(() => {
|
|
||||||
return isActionUnfoldAll.value ? t('globals.expand_all') : t('globals.unfold_all');
|
|
||||||
});
|
|
||||||
const isActionExpandAllIconClass = computed(() => {
|
|
||||||
return isActionExpandAll.value ? 'vn:unfold_less' : 'vn:expand_more';
|
|
||||||
});
|
|
||||||
const isActionUnfoldAllIconClass = computed(() => {
|
|
||||||
return isActionUnfoldAll.value ? 'vn:expand_more' : 'vn:unfold_less';
|
|
||||||
});
|
|
||||||
const isActionExpandAllIconClassColor = computed(() => {
|
|
||||||
return isActionExpandAll.value ? 'primary' : 'grey-4';
|
|
||||||
});
|
|
||||||
const isActionUnfoldAllIconClassColor = computed(() => {
|
|
||||||
return isActionUnfoldAll.value ? 'primary' : 'grey-4';
|
|
||||||
});
|
|
||||||
const actions = (action) => {
|
const actions = (action) => {
|
||||||
if (action === 'expand_all') {
|
if (action === 'expand_all') {
|
||||||
expanded.value = rows.value.map((r) => r.id);
|
expanded.value = rows.value.map((r) => r.id);
|
||||||
|
@ -278,8 +223,6 @@ const actions = (action) => {
|
||||||
}
|
}
|
||||||
lastAction.value = action;
|
lastAction.value = action;
|
||||||
};
|
};
|
||||||
const expanded = ref([]);
|
|
||||||
// const initialExpanded = rows.filter((r, i) => i % 3 === 0).map((r) => r.index);
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|
Loading…
Reference in New Issue