mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
añadido direcciones
This commit is contained in:
@ -0,0 +1,55 @@
|
|||||||
|
<div class="col-12 pb-2 d-flex flex-column align-items-center">
|
||||||
|
|
||||||
|
<div class="col-sm-8 mb-3 d-flex flex-column align-items-center">
|
||||||
|
<h5 class="mb-1 fw-bold titulo"></h5>
|
||||||
|
</div><!--//.mb-3 -->
|
||||||
|
|
||||||
|
<div class="col-sm-8 mb-3 d-flex flex-column align-items-center">
|
||||||
|
<h3 class="mb-1 fw-bold"> Direcciones de envío </h3>
|
||||||
|
</div><!--//.mb-3 -->
|
||||||
|
|
||||||
|
<div id="divInputDirecciones" name="div_input_direcciones" class="row col-sm-12 mb-5 justify-content-center">
|
||||||
|
|
||||||
|
<div id="containerTiradasEnvios" class="row mb-3">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row mb-3 justify-content-center">
|
||||||
|
|
||||||
|
<div class="col-sm-4 mb-3">
|
||||||
|
<label for="direcciones" class="form-label">Mis direcciones</label>
|
||||||
|
<select id="direcciones" name="direcciones" class="form-control select2bs2"
|
||||||
|
style="width: 100%;"></select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-sm-2 mb-3">
|
||||||
|
<label for="unidadesEnvio" class="form-label">
|
||||||
|
Unidades
|
||||||
|
</label>
|
||||||
|
<input type="number" class="form-control" id="unidadesEnvio" name="unidadesEnvio" maxLength="8" step="1"
|
||||||
|
class="form-control">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-sm-2 mb-3 mt-auto mb-0">
|
||||||
|
<button id="insertarDireccion" type="button"
|
||||||
|
class="btn btn-secondary waves-effect waves-light">Insertar</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row mb-3 justify-content-center">
|
||||||
|
<div class="col-sm-4 mb-3">
|
||||||
|
<div class="form-check form-switch mb-2">
|
||||||
|
<input class="form-check-input" type="checkbox" id="entregaPieCalle" name="entregaPieCalle"
|
||||||
|
value="1">
|
||||||
|
<label class="form-check-label"
|
||||||
|
for="add_entregaPieCalle"><?= lang('PresupuestosDirecciones.entregaPieCalle') ?></label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="divDirecciones" class="col-12 pb-2">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
@ -1,12 +1,13 @@
|
|||||||
class ClassSelect2 {
|
class ClassSelect2 {
|
||||||
|
|
||||||
constructor(domItem, url, placeholder = "", delay = 60, text_field = 'nombre', id_field = 'id') {
|
constructor(domItem, url, placeholder = "", delay = 60, text_field = 'nombre', id_field = 'id', params={}) {
|
||||||
this.domItem = domItem;
|
this.domItem = domItem;
|
||||||
this.url = url;
|
this.url = url;
|
||||||
this.placeholder = placeholder;
|
this.placeholder = placeholder;
|
||||||
this.delay = delay;
|
this.delay = delay;
|
||||||
this.text_field = text_field;
|
this.text_field = text_field;
|
||||||
this.id_field = id_field;
|
this.id_field = id_field;
|
||||||
|
this.params = params;
|
||||||
}
|
}
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
@ -20,11 +21,17 @@ class ClassSelect2 {
|
|||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
data: (params) => {
|
data: (params) => {
|
||||||
|
|
||||||
return {
|
let d = {
|
||||||
id: this.id_field,
|
id: this.id_field,
|
||||||
text: this.text_field,
|
text: this.text_field,
|
||||||
searchTerm: params.term,
|
searchTerm: params.term,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
for (let key in this.params) {
|
||||||
|
d[key] = this.params[key];
|
||||||
|
}
|
||||||
|
|
||||||
|
return d;
|
||||||
},
|
},
|
||||||
delay: this.delay,
|
delay: this.delay,
|
||||||
processResults: function (response) {
|
processResults: function (response) {
|
||||||
@ -38,6 +45,10 @@ class ClassSelect2 {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setParams(params) {
|
||||||
|
this.params = params;
|
||||||
|
}
|
||||||
|
|
||||||
// Método para obtener el valor seleccionado
|
// Método para obtener el valor seleccionado
|
||||||
getValue() {
|
getValue() {
|
||||||
return this.domItem.val();
|
return this.domItem.val();
|
||||||
@ -48,6 +59,10 @@ class ClassSelect2 {
|
|||||||
this.domItem.val(value).trigger('change');
|
this.domItem.val(value).trigger('change');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
clear() {
|
||||||
|
this.domItem.val(null).trigger('change');
|
||||||
|
}
|
||||||
|
|
||||||
// Método para oculatar el select2
|
// Método para oculatar el select2
|
||||||
hide() {
|
hide() {
|
||||||
this.domItem.select2('close');
|
this.domItem.select2('close');
|
||||||
|
|||||||
@ -0,0 +1,68 @@
|
|||||||
|
import ClassSelect from '../../components/select2.js';
|
||||||
|
|
||||||
|
class Direcciones {
|
||||||
|
|
||||||
|
constructor(domItem, wizardForm, validatorStepper) {
|
||||||
|
|
||||||
|
this.domItem = domItem;
|
||||||
|
this.wizardStep = wizardForm.querySelector('#direcciones-libro');
|
||||||
|
this.validatorStepper = validatorStepper;
|
||||||
|
|
||||||
|
this.direcciones = new ClassSelect($("#direcciones"), '/clientedirecciones/menuitems');
|
||||||
|
|
||||||
|
this.initValidation();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
init() {
|
||||||
|
|
||||||
|
$("#clienteId").on('change', this.#handleChangeCliente.bind(this));
|
||||||
|
|
||||||
|
this.direcciones.init();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
initValidation() {
|
||||||
|
|
||||||
|
const stepper = this.validatorStepper;
|
||||||
|
|
||||||
|
this.formValidation = FormValidation.formValidation(this.wizardStep, {
|
||||||
|
fields: {
|
||||||
|
|
||||||
|
},
|
||||||
|
plugins: {
|
||||||
|
trigger: new FormValidation.plugins.Trigger(),
|
||||||
|
bootstrap5: new FormValidation.plugins.Bootstrap5({
|
||||||
|
// Use this for enabling/changing valid/invalid class
|
||||||
|
// eleInvalidClass: '',
|
||||||
|
eleValidClass: '',
|
||||||
|
rowSelector: function (field, ele) {
|
||||||
|
// field is the field name
|
||||||
|
// ele is the field element
|
||||||
|
switch (field) {
|
||||||
|
case ' ':
|
||||||
|
return '.col-sm-10';
|
||||||
|
default:
|
||||||
|
return '.col-sm-3';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
autoFocus: new FormValidation.plugins.AutoFocus(),
|
||||||
|
submitButton: new FormValidation.plugins.SubmitButton()
|
||||||
|
}
|
||||||
|
}).on('core.form.valid', () => {
|
||||||
|
stepper.next();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#handleChangeCliente() {
|
||||||
|
this.direcciones.setParams({ 'cliente_id': $("#clienteId").select2('data')[0].id })
|
||||||
|
this.direcciones.clear();
|
||||||
|
// falta quitar las direcciones que haya!!!!
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export default Direcciones;
|
||||||
@ -1,6 +1,7 @@
|
|||||||
import DatosGenerales from './datosGenerales.js';
|
import DatosGenerales from './datosGenerales.js';
|
||||||
import DisenioInterior from './disenioInterior.js';
|
import DisenioInterior from './disenioInterior.js';
|
||||||
import DisenioCubierta from './disenioCubierta.js';
|
import DisenioCubierta from './disenioCubierta.js';
|
||||||
|
import Direcciones from './direcciones.js';
|
||||||
import Ajax from '../../components/ajax.js';
|
import Ajax from '../../components/ajax.js';
|
||||||
|
|
||||||
class PresupuestoCliente {
|
class PresupuestoCliente {
|
||||||
@ -21,6 +22,7 @@ class PresupuestoCliente {
|
|||||||
this.datosGenerales = new DatosGenerales($("#datos-generales"), this.clientePresupuestoWizard, this.validationStepper);
|
this.datosGenerales = new DatosGenerales($("#datos-generales"), this.clientePresupuestoWizard, this.validationStepper);
|
||||||
this.disenioInterior = new DisenioInterior($("#interior-libro"), this.clientePresupuestoWizard, this.validationStepper);
|
this.disenioInterior = new DisenioInterior($("#interior-libro"), this.clientePresupuestoWizard, this.validationStepper);
|
||||||
this.disenioCubierta = new DisenioCubierta($("#cubierta-libro"), this.clientePresupuestoWizard, this.validationStepper);
|
this.disenioCubierta = new DisenioCubierta($("#cubierta-libro"), this.clientePresupuestoWizard, this.validationStepper);
|
||||||
|
this.direcciones = new Direcciones($("#direcciones-libro"), this.clientePresupuestoWizard, this.validationStepper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -39,6 +41,7 @@ class PresupuestoCliente {
|
|||||||
this.datosGenerales.init();
|
this.datosGenerales.init();
|
||||||
this.disenioInterior.init();
|
this.disenioInterior.init();
|
||||||
this.disenioCubierta.init();
|
this.disenioCubierta.init();
|
||||||
|
this.direcciones.init();
|
||||||
|
|
||||||
this.RELLENAR_PRESUPUESTO();
|
this.RELLENAR_PRESUPUESTO();
|
||||||
|
|
||||||
@ -51,14 +54,14 @@ class PresupuestoCliente {
|
|||||||
$("#titulo").trigger('change');
|
$("#titulo").trigger('change');
|
||||||
|
|
||||||
const clienteId = $("#clienteId");
|
const clienteId = $("#clienteId");
|
||||||
const newOption = new Option("Cliente Potencial", "1", true, true);
|
const newOption = new Option("Cliente Potencial", "1817", true, true);
|
||||||
clienteId.append(newOption).trigger('change');
|
clienteId.append(newOption).trigger('change');
|
||||||
|
|
||||||
const papelFormatoId = $("#papelFormatoId");
|
const papelFormatoId = $("#papelFormatoId");
|
||||||
const newOption2 = new Option("Formato 1", "1", true, true);
|
const newOption2 = new Option("Formato 1", "1", true, true);
|
||||||
papelFormatoId.append(newOption2).trigger('change');
|
papelFormatoId.append(newOption2).trigger('change');
|
||||||
|
|
||||||
$("#paginasColor").val("5");
|
$("#paginasColor").val("6");
|
||||||
$("#paginasColor").trigger('change');
|
$("#paginasColor").trigger('change');
|
||||||
|
|
||||||
$("#fresado").trigger("click");
|
$("#fresado").trigger("click");
|
||||||
@ -70,6 +73,10 @@ class PresupuestoCliente {
|
|||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
$("#gramaje80").trigger("click");
|
$("#gramaje80").trigger("click");
|
||||||
}, 0);
|
}, 0);
|
||||||
|
|
||||||
|
setTimeout(function() {
|
||||||
|
$("#tapaDura").trigger("click");
|
||||||
|
}, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user