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 packagingsOptions = 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 = {
item: {
component: QBtn,
@ -46,7 +56,7 @@ const tableColumnComponents = {
label: col.label,
class: 'input-number',
}),
event: (colField, props) => getInputEvents(colField, props),
event: getInputEvents,
},
packagingFk: {
component: VnSelectFilter,
@ -59,7 +69,7 @@ const tableColumnComponents = {
'hide-selected': true,
options: packagingsOptions.value,
}),
event: (colField, props) => getInputEvents(colField, props),
event: getInputEvents,
},
stickers: {
component: VnInput,
@ -69,7 +79,7 @@ const tableColumnComponents = {
label: col.label,
class: 'input-number',
}),
event: (colField, props) => getInputEvents(colField, props),
event: getInputEvents,
},
weight: {
component: VnInput,
@ -78,7 +88,7 @@ const tableColumnComponents = {
min: 0,
label: col.label,
}),
event: (colField, props) => getInputEvents(colField, props),
event: getInputEvents,
},
packing: {
component: VnInput,
@ -87,7 +97,7 @@ const tableColumnComponents = {
min: 0,
label: col.label,
}),
event: (colField, props) => getInputEvents(colField, props),
event: getInputEvents,
},
grouping: {
component: VnInput,
@ -96,7 +106,7 @@ const tableColumnComponents = {
min: 0,
label: col.label,
}),
event: (colField, props) => getInputEvents(colField, props),
event: getInputEvents,
},
buyingValue: {
component: VnInput,
@ -105,7 +115,7 @@ const tableColumnComponents = {
min: 0,
label: col.label,
}),
event: (colField, props) => getInputEvents(colField, props),
event: getInputEvents,
},
price2: {
component: VnInput,
@ -114,7 +124,7 @@ const tableColumnComponents = {
min: 0,
label: col.label,
}),
event: (colField, props) => getInputEvents(colField, props),
event: getInputEvents,
},
price3: {
component: VnInput,
@ -123,7 +133,7 @@ const tableColumnComponents = {
min: 0,
label: col.label,
}),
event: (colField, props) => getInputEvents(colField, props),
event: getInputEvents,
},
import: {
component: 'span',
@ -209,15 +219,6 @@ const copyOriginalRowsData = (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 }) => {
try {
if (originalRowDataCopy.value[rowIndex][field] == row[field]) return;