add autonumeric format & fix editor btn in tarifa impresion maquina

This commit is contained in:
amazuecos
2025-02-09 13:12:37 +01:00
parent 3efec5e6cb
commit 9b7c6c4ec1

View File

@ -389,13 +389,17 @@
}, {
name: "precio",
attr: {
type: "number"
}
type: "text",
name : "precio",
class :"autonumeric"
}
}, {
name: "margen",
attr: {
type: "number"
}
type: "text",
name : "margen",
class :"autonumeric"
}
}, {
"name": "maquina_id",
"type": "hidden"
@ -409,8 +413,37 @@
]
} );
editor.on('open', (event) => {
$("input.autonumeric").each(function () {
let autoNumericInstance = AutoNumeric.getAutoNumericElement(this)
if (autoNumericInstance) {
autoNumericInstance.remove()
}
new AutoNumeric(this, {
decimalCharacter: ",",
digitGroupSeparator: ".",
allowDecimalPadding : 'floats',
decimalPlaces: 2,
unformatOnSubmit: true,
});
})
})
editor.on( 'preSubmit', function ( e, d, type ) {
if (d.data) {
Object.keys(d.data).forEach(function (key) {
// Find all elements with class .autonumeric
$("input.autonumeric").each(function () {
let autoNumericInstance = AutoNumeric.getAutoNumericElement(this)
if (autoNumericInstance) {
// Get raw value and update the corresponding field
let rawValue = autoNumericInstance.getNumericString();
d.data[key][this.name] = rawValue; // Ensure the correct name attribute is used
}
});
});
}
if ( type === 'create'){
d.data[0]['maquina_id'] = id;
}
@ -511,9 +544,9 @@
return '<?= lang('MaquinasTarifasImpresions.colorhq') ?>';
}
},
{ 'data': 'precio' },
{ 'data': 'margen' },
{ 'data': 'is_deleted',},
{ 'data': 'precio',render : (d) => `<span class="autonumeric">${d}</span>` },
{ 'data': 'margen',render : (d) => `<span class="autonumeric">${d}</span>` },
{ 'data': 'is_deleted'},
{
data: actionBtns,
className: 'row-edit dt-center'
@ -523,7 +556,7 @@
columnDefs: [
{
target: 4,
visible: false
visible: true
},
{
orderable: false,
@ -585,7 +618,7 @@
},
{ 'data': 'papel_generico'},
{ 'data': 'papel_impresion'},
{ 'data': 'gramaje'},
{ 'data': 'gramaje',render : (d) => `<span class="autonumeric">${d}</span>`},
{ 'data': 'bn'},
{ 'data': 'color'},
{ 'data': 'cubierta'},
@ -731,9 +764,19 @@
fields: [ {
name: "formas"
}, {
name: "internas"
name: "internas",
attr: {
type: "text",
name : "internas",
class :"autonumeric"
}
}, {
name: "externas"
name: "externas",
attr: {
type: "text",
name : "externas",
class :"autonumeric"
}
}, {
"name": "maquina_id",
"type": "hidden"
@ -746,7 +789,37 @@
},
]
} );
editor3.on('open', (event) => {
$("input.autonumeric").each(function () {
let autoNumericInstance = AutoNumeric.getAutoNumericElement(this)
if (autoNumericInstance) {
autoNumericInstance.remove()
}
new AutoNumeric(this, {
decimalCharacter: ",",
digitGroupSeparator: ".",
allowDecimalPadding : 'floats',
decimalPlaces: 2,
unformatOnSubmit: true,
});
})
})
editor3.on('preSubmit', (e, d, type) => {
if (d.data) {
Object.keys(d.data).forEach(function (key) {
// Find all elements with class .autonumeric
$("input.autonumeric").each(function () {
let autoNumericInstance = AutoNumeric.getAutoNumericElement(this)
if (autoNumericInstance) {
// Get raw value and update the corresponding field
let rawValue = autoNumericInstance.getNumericString();
d.data[key][this.name] = rawValue; // Ensure the correct name attribute is used
}
});
});
}
})
editor3.on( 'preSubmit', function ( e, d, type ) {
if ( type === 'create'){
@ -799,8 +872,8 @@
}),
columns : [
{ 'data': 'formas' },
{ 'data': 'internas' },
{ 'data': 'externas' },
{ 'data': 'internas',render : (d) => `<span class="autonumeric">${d}</span>` },
{ 'data': 'externas',render : (d) => `<span class="autonumeric">${d}</span>` },
{ data: actionBtns,
className: 'row-edit dt-center'}
],