Validaciones
This commit is contained in:
@ -8,7 +8,7 @@
|
||||
<div class="inline field">
|
||||
<div class="ui calendar" id="fecha_venta_calendar">
|
||||
<div class="ui icon input">
|
||||
<input type="text" name="fecha_venta" id="fecha_venta" />
|
||||
<input type="text" name="fecha_venta" id="fecha_venta" required />
|
||||
<i class="calendar icon"></i>
|
||||
</div>
|
||||
</div>
|
||||
@ -34,6 +34,7 @@
|
||||
<div class="four wide field">
|
||||
<div class="ui fluid search selection dropdown" id="proyecto">
|
||||
<input type="hidden" name="proyecto" />
|
||||
<i class="dropdown icon"></i>
|
||||
<div class="default text">Proyecto</div>
|
||||
<div class="menu">
|
||||
@foreach($proyectos as $proyecto)
|
||||
@ -67,7 +68,7 @@
|
||||
<label for="valor">Valor</label>
|
||||
<div class="inline field">
|
||||
<div class="ui right labeled input">
|
||||
<input type="text" name="valor" id="valor" />
|
||||
<input type="text" name="valor" id="valor" required />
|
||||
<div class="ui label">UF</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -261,7 +262,9 @@
|
||||
provincias: []
|
||||
}
|
||||
|
||||
$(this.id).dropdown()
|
||||
$(this.id).dropdown({
|
||||
forceSelection: true
|
||||
})
|
||||
}
|
||||
|
||||
get() {
|
||||
@ -331,6 +334,7 @@
|
||||
const dd = $(this.id)
|
||||
dd.dropdown({
|
||||
fireOnInit: true,
|
||||
forceSelection: true,
|
||||
onChange: value => {
|
||||
this.comuna.data.region = value
|
||||
this.comuna.get().provincias()
|
||||
@ -348,7 +352,7 @@
|
||||
const lines = [
|
||||
'<label for="rut">RUT</label>',
|
||||
'<div class="inline field">',
|
||||
'<input type="text" id="rut" name="rut" placeholder="00000000-0" />',
|
||||
'<input type="text" id="rut" name="rut" placeholder="00000000-0" required />',
|
||||
'<span class="ui error message" id="alert_rut">',
|
||||
'<i class="exclamation triangle icon"></i>',
|
||||
'RUT Inválido',
|
||||
@ -357,22 +361,22 @@
|
||||
'<label for="nombres">Nombre</label>',
|
||||
'<div class="inline fields">',
|
||||
'<div class="field">',
|
||||
'<input type="text" name="nombres" id="nombres" placeholder="Nombre(s)" />',
|
||||
'<input type="text" name="nombres" id="nombres" placeholder="Nombre(s)" required />',
|
||||
'</div>',
|
||||
'<div class="field">',
|
||||
'<input type="text" name="apellido_paterno" placeholder="Apellido Paterno" />',
|
||||
'<input type="text" name="apellido_paterno" placeholder="Apellido Paterno" required />',
|
||||
'</div>',
|
||||
'<div class="field">',
|
||||
'<input type="text" name="apellido_materno" placeholder="Apellido Materno" />',
|
||||
'<input type="text" name="apellido_materno" placeholder="Apellido Materno" required />',
|
||||
'</div>',
|
||||
'</div>',
|
||||
'<label for="calle">Dirección</label>',
|
||||
'<div class="inline fields">',
|
||||
'<div class="eight wide field">',
|
||||
'<input type="text" name="calle" id="calle" size="16" placeholder="Calle" />',
|
||||
'<input type="text" name="calle" id="calle" size="16" placeholder="Calle" required />',
|
||||
'</div>',
|
||||
'<div class="field">',
|
||||
'<input type="text" name="numero" size="5" placeholder="Número" />',
|
||||
'<input type="text" name="numero" size="5" placeholder="Número" required />',
|
||||
'</div>',
|
||||
'<div class="field">',
|
||||
'<input type="text" name="extra" placeholder="Otros Detalles" />',
|
||||
@ -383,6 +387,7 @@
|
||||
'<div class="four wide field">',
|
||||
'<div class="ui fluid search selection dropdown" id="comuna">',
|
||||
'<input type="hidden" name="comuna" />',
|
||||
'<i class="dropdown icon"></i>',
|
||||
'<div class="default text">Comuna</div>',
|
||||
'<div class="menu"></div>',
|
||||
'</div>',
|
||||
@ -390,6 +395,7 @@
|
||||
'<div class="six wide field">',
|
||||
'<div class="ui fluid search selection dropdown" id="region">',
|
||||
'<input type="hidden" name="region" />',
|
||||
'<i class="dropdown icon"></i>',
|
||||
'<div class="default text">Región</div>',
|
||||
'<div class="menu">',
|
||||
...regiones,
|
||||
@ -415,7 +421,7 @@
|
||||
const lines = [
|
||||
'<label for="rut">RUT Sociedad</label>',
|
||||
'<div class="inline field">',
|
||||
'<input type="text" id="rut_sociedad" name="rut_sociedad" />',
|
||||
'<input type="text" id="rut_sociedad" name="rut_sociedad" required />',
|
||||
'<span class="ui error message" id="alert_rut_sociedad">',
|
||||
'<i class="exclamation triangle icon"></i>',
|
||||
'RUT Inválido',
|
||||
@ -423,15 +429,15 @@
|
||||
'</div>',
|
||||
'<label for="razon_social">Razón Social</label>',
|
||||
'<div class="field">',
|
||||
'<input type="text" name="razon_social" id="razon_social" />',
|
||||
'<input type="text" name="razon_social" id="razon_social" required />',
|
||||
'</div>',
|
||||
'<label for="calle_comercial">Dirección Comercial</label>',
|
||||
'<div class="inline fields">',
|
||||
'<div class="eight wide field">',
|
||||
'<input type="text" name="calle_comercial" id="calle_comercial" size="16" />',
|
||||
'<input type="text" name="calle_comercial" id="calle_comercial" size="16" required />',
|
||||
'</div>',
|
||||
'<div class="field">',
|
||||
'<input type="text" name="numero_comercial" size="5" />',
|
||||
'<input type="text" name="numero_comercial" size="5" required />',
|
||||
'</div>',
|
||||
'<div class="field">',
|
||||
'<input type="text" name="extra_comercial" />',
|
||||
@ -442,6 +448,7 @@
|
||||
'<div class="four wide field">',
|
||||
'<div class="ui fluid search selection dropdown" id="comuna_sociedad">',
|
||||
'<input type="hidden" name="comuna_sociedad" />',
|
||||
'<i class="dropdown icon"></i>',
|
||||
'<div class="default text">Comuna</div>',
|
||||
'<div class="menu"></div>',
|
||||
'</div>',
|
||||
@ -449,6 +456,7 @@
|
||||
'<div class="six wide field">',
|
||||
'<div class="ui fluid search selection dropdown" id="region_sociedad">',
|
||||
'<input type="hidden" name="region_sociedad" />',
|
||||
'<i class="dropdown icon"></i>',
|
||||
'<div class="default text">Región</div>',
|
||||
'<div class="menu">',
|
||||
...regiones,
|
||||
@ -478,7 +486,7 @@
|
||||
this.persona.draw(),
|
||||
'<label for="rut">RUT Otro</label>',
|
||||
'<div class="inline field">',
|
||||
'<input type="text" id="rut_otro" name="rut_otro" />',
|
||||
'<input type="text" id="rut_otro" name="rut_otro" required />',
|
||||
'<span class="ui error message" id="alert_rut_otro">',
|
||||
'<i class="exclamation triangle icon"></i>',
|
||||
'RUT Inválido',
|
||||
@ -487,22 +495,22 @@
|
||||
'<label for="nombres_otro">Nombre Otro</label>',
|
||||
'<div class="inline fields">',
|
||||
'<div class="field">',
|
||||
'<input type="text" name="nombres_otro" id="nombres_otro" />',
|
||||
'<input type="text" name="nombres_otro" id="nombres_otro" required />',
|
||||
'</div>',
|
||||
'<div class="field">',
|
||||
'<input type="text" name="apellido_paterno_otro" />',
|
||||
'<input type="text" name="apellido_paterno_otro" required />',
|
||||
'</div>',
|
||||
'<div class="field">',
|
||||
'<input type="text" name="apellido_materno_otro" />',
|
||||
'<input type="text" name="apellido_materno_otro" required />',
|
||||
'</div>',
|
||||
'</div>',
|
||||
'<label for="calle_otro">Dirección Otro</label>',
|
||||
'<div class="inline fields">',
|
||||
'<div class="eight wide field">',
|
||||
'<input type="text" name="calle_otro" id="calle_otro" size="16" />',
|
||||
'<input type="text" name="calle_otro" id="calle_otro" size="16" required />',
|
||||
'</div>',
|
||||
'<div class="field">',
|
||||
'<input type="text" name="numero_otro" size="5" />',
|
||||
'<input type="text" name="numero_otro" size="5" required />',
|
||||
'</div>',
|
||||
'<div class="field">',
|
||||
'<input type="text" name="extra_otro" />',
|
||||
@ -513,6 +521,7 @@
|
||||
'<div class="four wide field">',
|
||||
'<div class="ui fluid search selection dropdown" id="comuna_otro">',
|
||||
'<input type="hidden" name="comuna_otro" />',
|
||||
'<i class="dropdown icon"></i>',
|
||||
'<div class="default text">Comuna</div>',
|
||||
'<div class="menu"></div>',
|
||||
'</div>',
|
||||
@ -520,6 +529,7 @@
|
||||
'<div class="six wide field">',
|
||||
'<div class="ui fluid search selection dropdown" id="region_otro">',
|
||||
'<input type="hidden" name="region_otro" />',
|
||||
'<i class="dropdown icon"></i>',
|
||||
'<div class="default text">Región</div>',
|
||||
'<div class="menu">',
|
||||
...regiones,
|
||||
@ -633,6 +643,7 @@
|
||||
|
||||
$(this.ids.proyecto).dropdown({
|
||||
fireOnInit: true,
|
||||
forceSelection: true,
|
||||
onChange: (value, text, $choice) => {
|
||||
this.data.id = value
|
||||
this.ids.buttons.forEach(button => {
|
||||
@ -640,8 +651,10 @@
|
||||
})
|
||||
this.reset()
|
||||
this.fetch().unidades().then(() => {
|
||||
this.ids.buttons.forEach(button => {
|
||||
$(button).prop('disabled', false)
|
||||
Object.keys(this.unidades).forEach(name => {
|
||||
if (this.unidades[name].length > 0) {
|
||||
$(`#agregar_${name}`).prop('disabled', false)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
@ -653,7 +666,7 @@
|
||||
'terraza'
|
||||
]
|
||||
buttons.forEach(name => {
|
||||
const id = '#agregar_' + name
|
||||
const id = `#agregar_${name}`
|
||||
this.ids.buttons.push(id)
|
||||
$(id).click(event => {
|
||||
this.add(name)
|
||||
@ -793,9 +806,18 @@
|
||||
button.prop('disabled', true)
|
||||
button.css('cursor', 'wait')
|
||||
const body = new FormData(event.currentTarget)
|
||||
/*const unidades = event.currentTarget.querySelectorAll("[name^='unidad_']")
|
||||
console.debug(unidades)
|
||||
return;*/
|
||||
const unidades = event.currentTarget.querySelectorAll("[name^='unidad']")
|
||||
const emptyUnidades = []
|
||||
unidades.forEach(unidad => {
|
||||
if (unidad.value.trim() === '') {
|
||||
emptyUnidades.push(unidad)
|
||||
body.delete(unidad.name)
|
||||
}
|
||||
})
|
||||
if (unidades.length === emptyUnidades.length) {
|
||||
alert("No hay unidades seleccionadas")
|
||||
return;
|
||||
}
|
||||
const uri = '{{$urls->api}}/ventas/add'
|
||||
return fetchAPI(uri, {method: 'post', body}).then(response => {
|
||||
if (!response) {
|
||||
|
Reference in New Issue
Block a user