mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
trabajando en datoslibro
This commit is contained in:
@ -0,0 +1,162 @@
|
||||
import { getToken } from '../../common/common.js';
|
||||
import Ajax from '../../components/ajax.js';
|
||||
|
||||
import DatosGenerales from './sections/datosGenerales.js';
|
||||
import DatosLibro from './sections/datosLibro.js';
|
||||
|
||||
class PresupuestoAdminEdit {
|
||||
|
||||
constructor() {
|
||||
|
||||
this.domItem = $('#presupuestoForm');
|
||||
|
||||
this.csrf_token = getToken();
|
||||
this.csrf_hash = $('#presupuestoForm').find('input[name="' + this.csrf_token + '"]').val();
|
||||
|
||||
this.lc = $("#lomo_cubierta");
|
||||
this.lsc = $("#lomo_sobrecubierta");
|
||||
this.cosido = $("#isCosido");
|
||||
this.tipo_impresion = $("#tipo_impresion_id");
|
||||
this.cosido = $("#isCosido");
|
||||
|
||||
this.datosGenerales = new DatosGenerales(this.domItem.find('#accordionDatosPresupuestoTip'));
|
||||
this.datosLibro = new DatosLibro(this.domItem.find('#accordionDatosPresupuestoTip'));
|
||||
|
||||
this.calcularPresupuesto = false;
|
||||
}
|
||||
|
||||
init() {
|
||||
|
||||
// Fuerza el foco en el campo de búsqueda de select2
|
||||
$(document).on('select2:open', () => {
|
||||
document.querySelector('.select2-search__field').focus();
|
||||
});
|
||||
|
||||
this.datosGenerales.init();
|
||||
|
||||
if (window.location.href.includes("edit")) {
|
||||
|
||||
setTimeout(() => {
|
||||
this.#cargarPresupuesto();
|
||||
}, 0);
|
||||
|
||||
const successMessage = sessionStorage.getItem('message');
|
||||
if (successMessage) {
|
||||
popSuccessAlert(successMessage);
|
||||
sessionStorage.removeItem('message');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#cargarPresupuesto() {
|
||||
|
||||
const self = this;
|
||||
|
||||
$('#loader').modal('show');
|
||||
let id = window.location.href.split("/").pop()
|
||||
new Ajax('/presupuestoadmin/cargar/' + id,
|
||||
{},
|
||||
{},
|
||||
(response) => {
|
||||
|
||||
if (response.status === 1) {
|
||||
|
||||
self.lc.val(parseFloat(response.data.lc).toFixed(2));
|
||||
self.lsc.val(parseFloat(response.data.lsc).toFixed(2));
|
||||
self.cosido.val(response.data.cosido);
|
||||
self.tipo_impresion.val(response.data.tipo_impresion);
|
||||
|
||||
self.calcularPresupuesto = false;
|
||||
|
||||
self.datosGenerales.cargarDatos(response.data.datosGenerales);
|
||||
|
||||
/*self.direcciones.handleChangeCliente();
|
||||
|
||||
self.direcciones.cargarDatos(response.data.direcciones, response.data.datosGenerales);
|
||||
|
||||
self.disenioInterior.cargarDatos(response.data.interior, response.data.datosGenerales.papelInteriorDiferente);
|
||||
self.disenioCubierta.cargarDatos(response.data.cubierta, response.data.guardas, response.data.sobrecubierta);
|
||||
*/
|
||||
setTimeout(() => {
|
||||
|
||||
$('#loader').modal('hide');
|
||||
|
||||
if (response.data.state != 2) {
|
||||
|
||||
self.calcularPresupuesto = true;
|
||||
}
|
||||
|
||||
}, 0);
|
||||
|
||||
// Funciones para detectar cambios en el formulario
|
||||
this.#checkChangesPresupuesto();
|
||||
$('#bc-save').on("click", function () {
|
||||
showBreadCrumbSaveButton(false);
|
||||
$('#saveForm').trigger('click');
|
||||
});
|
||||
}
|
||||
},
|
||||
() => {
|
||||
$('#loader').modal('hide');
|
||||
this.calcularPresupuesto = true;
|
||||
}
|
||||
).get();
|
||||
}
|
||||
|
||||
#checkChangesPresupuesto() {
|
||||
// Detectar cambios en inputs de texto
|
||||
$('input[type="text"]').on('change', function () {
|
||||
showBreadCrumbSaveButton(true);
|
||||
});
|
||||
|
||||
// Detectar cambios en inputs de texto
|
||||
$('input[type="number"]').on('change', function () {
|
||||
showBreadCrumbSaveButton(true);
|
||||
});
|
||||
|
||||
// Detectar cambios en select
|
||||
$('select').on('change', function () {
|
||||
showBreadCrumbSaveButton(true);
|
||||
});
|
||||
|
||||
$('.select2bs').on('change', function (e) {
|
||||
showBreadCrumbSaveButton(true);
|
||||
});
|
||||
|
||||
// Detectar cambios en checkboxes
|
||||
$('input[type="checkbox"]').change(function () {
|
||||
showBreadCrumbSaveButton(true);
|
||||
});
|
||||
|
||||
// Detectar cambios en textareas
|
||||
$('textarea').on('input', function () {
|
||||
showBreadCrumbSaveButton(true);
|
||||
});
|
||||
|
||||
// Detectar cambios en otros tipos de input
|
||||
$('input[type="radio"]').change(function () {
|
||||
showBreadCrumbSaveButton(true);
|
||||
});
|
||||
|
||||
// Detectar cambios en otros tipos de input
|
||||
$('input:not([type])').on('input', function () {
|
||||
showBreadCrumbSaveButton(true);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
|
||||
const locale = document.querySelector('meta[name="locale"]').getAttribute('content');
|
||||
|
||||
new Ajax('/translate/getTranslation', { locale: locale, translationFile: ['Maquinas'] }, {},
|
||||
function (translations) {
|
||||
window.language = JSON.parse(translations);
|
||||
new PresupuestoAdminEdit().init();
|
||||
},
|
||||
function (error) {
|
||||
console.log("Error getting translations:", error);
|
||||
}
|
||||
).post();
|
||||
});
|
||||
@ -0,0 +1,56 @@
|
||||
import ClassSelect from '../../../components/select2.js';
|
||||
|
||||
class DatosGenerales{
|
||||
|
||||
constructor(domItem){
|
||||
|
||||
this.domItem = domItem;
|
||||
|
||||
this.id = this.domItem.find('#id');
|
||||
this.fecha = this.domItem.find('#updated_at');
|
||||
this.estado = this.domItem.find('#estado_id');
|
||||
this.inc_rei = this.domItem.find('#incRei');
|
||||
this.titulo = this.domItem.find('#titulo');
|
||||
this.autor = this.domItem.find('#autor');
|
||||
this.coleccion = this.domItem.find('#coleccion');
|
||||
this.numeroEdicion = this.domItem.find('#numeroEdicion');
|
||||
this.isbn = this.domItem.find('#isbn');
|
||||
this.pais = this.domItem.find('#paisId');
|
||||
|
||||
this.cliente = new ClassSelect($('#clienteId'), '/clientes/cliente/getSelect2', 'Seleccione cliente');
|
||||
this.referenciaCliente = this.domItem.find('#referenciaCliente');
|
||||
|
||||
}
|
||||
|
||||
init(){
|
||||
|
||||
this.cliente.init();
|
||||
|
||||
this.inc_rei.select2({
|
||||
allowClear: false,
|
||||
});
|
||||
|
||||
this.pais.select2({
|
||||
allowClear: false,
|
||||
});
|
||||
}
|
||||
|
||||
cargarDatos(datos){
|
||||
|
||||
this.id.val(datos.id);
|
||||
this.fecha.val(datos.updated_at);
|
||||
this.estado.val(datos.state);
|
||||
this.inc_rei.val(datos.inc_rei).trigger('change');
|
||||
this.titulo.val(datos.titulo);
|
||||
this.autor.val(datos.autor);
|
||||
this.coleccion.val(datos.coleccion);
|
||||
this.numeroEdicion.val(datos.numero_edicion);
|
||||
this.isbn.val(datos.isbn);
|
||||
this.pais.val(datos.pais).trigger('change');
|
||||
|
||||
this.cliente.setOption(datos.cliente.id, datos.cliente.nombre);
|
||||
this.referenciaCliente.val(datos.referenciaCliente);
|
||||
}
|
||||
}
|
||||
|
||||
export default DatosGenerales;
|
||||
@ -0,0 +1,55 @@
|
||||
class DatosLibro {
|
||||
|
||||
constructor(domItem) {
|
||||
|
||||
this.domItem = domItem;
|
||||
|
||||
this.paginas = this.domItem.find('#paginas');
|
||||
this.tirada = this.domItem.find('#tirada');
|
||||
this.tamanio = this.domItem.find('#papelFormatoId');
|
||||
this.tamanioPersonalizado = this.domItem.find('#papelFormatoPersonalizado');
|
||||
this.anchoPersonalizado = this.domItem.find('#papelFormatoAncho');
|
||||
this.altoPersonalizado = this.domItem.find('#papelFormatoAlto');
|
||||
this.merma = this.domItem.find('#merma');
|
||||
this.mermaCubierta = this.domItem.find('#mermaCubierta');
|
||||
this.solapasCubierta = this.domItem.find('#solapas');
|
||||
this.solapasSobrecubierta = this.domItem.find('#solapas_sobrecubierta');
|
||||
this.anchoSolapasCubierta = this.domItem.find('#anchoSolapasCubierta');
|
||||
this.anchoSolapasSobrecubierta = this.domItem.find('#anchoSolapasSobrecubierta');
|
||||
|
||||
this.divSolapasCubierta = this.domItem.find('#div_solapas_ancho');
|
||||
this.divSolapasSobrecubierta = this.domItem.find('#div_solapas_ancho_sobrecubierta');
|
||||
|
||||
this.acabadoCubierta = this.domItem.find('#acabado_cubierta_id');
|
||||
this.acabadoSobrecubierta = this.domItem.find('#acabado_sobrecubierta_id');
|
||||
|
||||
this.retractilado = this.domItem.find('#retractilado');
|
||||
this.retractilado5 = this.domItem.find('#retractilado5');
|
||||
this.imprimirFajaColor = this.domItem.find('#imprimirFajaColor');
|
||||
this.prototipo = this.domItem.find('#prototipo');
|
||||
this.ferro = this.domItem.find('#ferro');
|
||||
this.ferroDigital = this.domItem.find('#ferroDigital');
|
||||
this.marcapaginas = this.domItem.find('#marcapaginas');
|
||||
|
||||
}
|
||||
|
||||
init() {
|
||||
|
||||
}
|
||||
|
||||
cargarDatos(datos) {
|
||||
|
||||
if ($('#tipo_impresion_id').val() == 1 || $('#tipo_impresion_id').val() == 3 ||
|
||||
$('#tipo_impresion_id').val() == 5 || $('#tipo_impresion_id').val() == 7) {
|
||||
$(".impresion-con-solapas").addClass('d-none');
|
||||
}
|
||||
|
||||
if ($('#tipo_impresion_id').val() == 5 || $('#tipo_impresion_id').val() == 6 ||
|
||||
$('#tipo_impresion_id').val() == 7 || $('#tipo_impresion_id').val() == 8
|
||||
|| $('#tipo_impresion_id').val() == 21) {
|
||||
$(".impresion-con-sobrecubierta").addClass('d-none');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default DatosLibro;
|
||||
Reference in New Issue
Block a user