get input events improvement
gitea/salix-front/pipeline/pr-dev There was a failure building this commit Details

This commit is contained in:
William Buezas 2024-02-05 12:31:57 -03:00
parent 0525f5fdd8
commit 5da5bb2047
1 changed files with 19 additions and 18 deletions

View File

@ -29,6 +29,16 @@ const rowsSelected = ref([]);
const entryBuysPaginateRef = ref(null); const entryBuysPaginateRef = ref(null);
const packagingsOptions = ref(null); const packagingsOptions = ref(null);
const originalRowDataCopy = ref(null); const originalRowDataCopy = ref(null);
const getInputEvents = (colField, props) => {
return colField === 'packagingFk'
? { 'update:modelValue': () => saveChange(colField, props) }
: {
'keyup.enter': () => saveChange(colField, props),
blur: () => saveChange(colField, props),
};
};
const tableColumnComponents = { const tableColumnComponents = {
item: { item: {
component: QBtn, component: QBtn,
@ -46,7 +56,7 @@ const tableColumnComponents = {
label: col.label, label: col.label,
class: 'input-number', class: 'input-number',
}), }),
event: (colField, props) => getInputEvents(colField, props), event: getInputEvents,
}, },
packagingFk: { packagingFk: {
component: VnSelectFilter, component: VnSelectFilter,
@ -59,7 +69,7 @@ const tableColumnComponents = {
'hide-selected': true, 'hide-selected': true,
options: packagingsOptions.value, options: packagingsOptions.value,
}), }),
event: (colField, props) => getInputEvents(colField, props), event: getInputEvents,
}, },
stickers: { stickers: {
component: VnInput, component: VnInput,
@ -69,7 +79,7 @@ const tableColumnComponents = {
label: col.label, label: col.label,
class: 'input-number', class: 'input-number',
}), }),
event: (colField, props) => getInputEvents(colField, props), event: getInputEvents,
}, },
weight: { weight: {
component: VnInput, component: VnInput,
@ -78,7 +88,7 @@ const tableColumnComponents = {
min: 0, min: 0,
label: col.label, label: col.label,
}), }),
event: (colField, props) => getInputEvents(colField, props), event: getInputEvents,
}, },
packing: { packing: {
component: VnInput, component: VnInput,
@ -87,7 +97,7 @@ const tableColumnComponents = {
min: 0, min: 0,
label: col.label, label: col.label,
}), }),
event: (colField, props) => getInputEvents(colField, props), event: getInputEvents,
}, },
grouping: { grouping: {
component: VnInput, component: VnInput,
@ -96,7 +106,7 @@ const tableColumnComponents = {
min: 0, min: 0,
label: col.label, label: col.label,
}), }),
event: (colField, props) => getInputEvents(colField, props), event: getInputEvents,
}, },
buyingValue: { buyingValue: {
component: VnInput, component: VnInput,
@ -105,7 +115,7 @@ const tableColumnComponents = {
min: 0, min: 0,
label: col.label, label: col.label,
}), }),
event: (colField, props) => getInputEvents(colField, props), event: getInputEvents,
}, },
price2: { price2: {
component: VnInput, component: VnInput,
@ -114,7 +124,7 @@ const tableColumnComponents = {
min: 0, min: 0,
label: col.label, label: col.label,
}), }),
event: (colField, props) => getInputEvents(colField, props), event: getInputEvents,
}, },
price3: { price3: {
component: VnInput, component: VnInput,
@ -123,7 +133,7 @@ const tableColumnComponents = {
min: 0, min: 0,
label: col.label, label: col.label,
}), }),
event: (colField, props) => getInputEvents(colField, props), event: getInputEvents,
}, },
import: { import: {
component: 'span', component: 'span',
@ -209,15 +219,6 @@ const copyOriginalRowsData = (rows) => {
originalRowDataCopy.value = JSON.parse(JSON.stringify(rows)); originalRowDataCopy.value = JSON.parse(JSON.stringify(rows));
}; };
const getInputEvents = (colField, props) => {
return colField === 'packagingFk'
? { 'update:modelValue': () => saveChange(colField, props) }
: {
'keyup.enter': () => saveChange(colField, props),
blur: () => saveChange(colField, props),
};
};
const saveChange = async (field, { rowIndex, row }) => { const saveChange = async (field, { rowIndex, row }) => {
try { try {
if (originalRowDataCopy.value[rowIndex][field] == row[field]) return; if (originalRowDataCopy.value[rowIndex][field] == row[field]) return;