diff --git a/src/pages/Entry/Card/EntryBuys.vue b/src/pages/Entry/Card/EntryBuys.vue index 142f6d45b..252618f03 100644 --- a/src/pages/Entry/Card/EntryBuys.vue +++ b/src/pages/Entry/Card/EntryBuys.vue @@ -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;