Uso de NumberInput en Edit BonoPie
This commit is contained in:
@ -33,6 +33,8 @@
|
|||||||
</form>
|
</form>
|
||||||
@endsection
|
@endsection
|
||||||
|
|
||||||
|
@include('layout.body.scripts.number_input')
|
||||||
|
|
||||||
@push('page_scripts')
|
@push('page_scripts')
|
||||||
<script>
|
<script>
|
||||||
$(document).ready(() => {
|
$(document).ready(() => {
|
||||||
@ -40,13 +42,17 @@
|
|||||||
fecha.calendar(calendar_date_options)
|
fecha.calendar(calendar_date_options)
|
||||||
fecha.calendar('set date', new Date({{$venta->formaPago()->bonoPie->pago->fecha->format('Y, m-1, j')}}))
|
fecha.calendar('set date', new Date({{$venta->formaPago()->bonoPie->pago->fecha->format('Y, m-1, j')}}))
|
||||||
|
|
||||||
|
const numberInput = new NumberInput({input: document.querySelector('input[name="valor"]'), isRational: true})
|
||||||
|
numberInput.watch()
|
||||||
|
|
||||||
$('#add_bono').submit(submitEvent => {
|
$('#add_bono').submit(submitEvent => {
|
||||||
submitEvent.preventDefault()
|
submitEvent.preventDefault()
|
||||||
const url = '{{$urls->api}}/venta/{{$venta->id}}/bono_pie/edit'
|
const url = '{{$urls->api}}/venta/{{$venta->id}}/bono_pie/edit'
|
||||||
const data = new FormData()
|
const method = 'post'
|
||||||
data.set('fecha', $('#fecha').calendar('get date').toISOString())
|
const body = new FormData()
|
||||||
data.set('valor', $('#valor').val())
|
body.set('fecha', $('#fecha').calendar('get date').toISOString())
|
||||||
return APIClient.fetch(url, {method: 'post', body: data}).then(response => {
|
body.set('valor', numberInput.currentValue)
|
||||||
|
return APIClient.fetch(url, {method, body}).then(response => {
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
return response.json()
|
return response.json()
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user