From aa53feea39b370639572710afebe5b7ead3dbfe5 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Wed, 5 Feb 2025 15:37:16 +0100 Subject: [PATCH] feat: refs #6321 changes --- src/pages/Item/components/ItemProposal.vue | 67 ++++++++++++------- src/pages/Ticket/Negative/TicketLackTable.vue | 4 +- src/pages/Ticket/locale/en.yml | 1 - src/pages/Ticket/locale/es.yml | 1 - src/router/modules/ticket.js | 1 - 5 files changed, 45 insertions(+), 29 deletions(-) diff --git a/src/pages/Item/components/ItemProposal.vue b/src/pages/Item/components/ItemProposal.vue index 2a3f5d424..e899b4029 100644 --- a/src/pages/Item/components/ItemProposal.vue +++ b/src/pages/Item/components/ItemProposal.vue @@ -7,8 +7,10 @@ import VnStockValueDisplay from 'src/components/ui/VnStockValueDisplay.vue'; import VnTable from 'src/components/VnTable/VnTable.vue'; import axios from 'axios'; import notifyResults from 'src/utils/notifyResults'; +import FetchData from 'components/FetchData.vue'; + +const MATCH = 'match'; -const MATCH_VALUES = [5, 6, 7, 8]; const { t } = useI18n(); const $props = defineProps({ itemLack: { @@ -34,6 +36,7 @@ const filter = computed(() => ({ itemFk: $props.itemLack.itemFk, sales: saleFk.value, })); + const proposalTableRef = ref(null); const defaultColumnAttrs = { align: 'center', @@ -45,13 +48,12 @@ const columns = computed(() => [ label: t('proposal.available'), name: 'available', field: 'available', - columnClass: 'shrink', - style: 'max-width: 75px', columnFilter: { component: 'input', type: 'number', columnClass: 'shrink', }, + columnClass: 'shrink', }, { ...defaultColumnAttrs, @@ -145,28 +147,32 @@ const columns = computed(() => [ }, ]); -const compatibilityItem = (value) => 100 * (value / MATCH_VALUES.length); - +function extractMatchValues(obj) { + return Object.keys(obj) + .filter((key) => key.startsWith(MATCH)) + .map((key) => parseInt(key.replace(MATCH, ''), 10)); +} const gradientStyle = (value) => { let color = 'white'; - const perc = parseFloat(compatibilityItem(value)); + const perc = parseFloat(value); switch (true) { case perc >= 0 && perc < 33: - color = 'orange'; + color = 'primary'; break; case perc >= 33 && perc < 66: - color = 'yellow'; + color = 'warning'; break; default: - color = 'green'; + color = 'secondary'; break; } return color; }; const statusConditionalValue = (row) => { - const total = MATCH_VALUES.reduce((acc, i) => acc + row[`match${i}`], 0); - return total; + const matches = extractMatchValues(row); + const value = matches.reduce((acc, i) => acc + row[`${MATCH}${i}`], 0); + return 100 * (value / matches.length); }; const emit = defineEmits(['onDialogClosed', 'itemReplaced']); @@ -196,11 +202,11 @@ async function change({ itemFk: substitutionFk }) { console.error(error); } } - +const ticketConfig = ref({}); const isSelectionAvailable = (itemProposal) => { const { price2 } = itemProposal; const salePrice = sale.value.price; - const byPrice = (100 * price2) / salePrice > 30; + const byPrice = (100 * price2) / salePrice > ticketConfig.value.lackAlertPrice; if (byPrice) { return byPrice; } @@ -208,15 +214,26 @@ const isSelectionAvailable = (itemProposal) => { (100 * itemProposal.available) / Math.abs($props.itemLack.lack) < 30; return byQuantity; }; +async function handleTicketConfig(data) { + ticketConfig.value = data[0]; +}