Listados separados por hojas (tabs)

This commit is contained in:
Juan Pablo Vial
2025-03-13 13:16:20 -03:00
parent 68aebdb4fe
commit 2e49e2c947

View File

@ -14,6 +14,13 @@
<b>Fecha Inicio:</b> {{ $contract->current()->date->format('d/m/Y') }} <br/>
</div>
<div class="ui active inline loader"></div>
<div id="results">
<div class="ui top attached tabular menu">
<a class="item active" data-tab="tipos">Tipos</a>
<a class="item" data-tab="lineas">Líneas</a>
<a class="item" data-tab="unidades">Unidades</a>
</div>
<div class="ui bottom attached tab basic horizontally fitted segment active" data-tab="tipos">
<table class="ui table" id="tipos">
<thead>
<tr>
@ -34,13 +41,14 @@
</thead>
<tbody></tbody>
</table>
</div>
<div class="ui bottom attached tab basic horizontally fitted segment" data-tab="lineas">
<table class="ui table" id="lineas">
<thead>
<tr>
<th rowspan="2">Tipo</th>
<th class="center aligned" rowspan="2">Línea</th>
<th class="center aligned" rowspan="2">Orientación</th>
<th class="center aligned" rowspan="2">Tipología</th>
<th class="center aligned" rowspan="2">Cantidad</th>
<th class="center aligned" colspan="3">Precio</th>
<th class="center aligned" colspan="3">Promoción</th>
@ -57,7 +65,8 @@
</thead>
<tbody></tbody>
</table>
<div id="unidades_container">
</div>
<div class="ui bottom attached tab basic horizontally fitted segment" data-tab="unidades">
<table class="ui table" id="unidades">
<thead>
<tr>
@ -76,6 +85,7 @@
<tbody></tbody>
</table>
</div>
</div>
@endsection
@include('layout.body.scripts.datatables')
@ -312,9 +322,8 @@
tbody.innerHTML += [
`<tr>`,
`<td>${tipo.charAt(0).toUpperCase() + tipo.slice(1)}</td>`,
`<td class="center aligned">${linea}</td>`,
`<td class="center aligned"><span data-tooltip="${unidades[0].proyecto_tipo_unidad.tipologia}" data-position="right center">${linea}</span></td>`,
`<td class="center aligned">${orientacion}</td>`,
`<td class="center aligned">${unidades[0].proyecto_tipo_unidad.tipologia}</td>`,
`<td class="center aligned">${unidades.length}</td>`,
`<td class="right aligned">UF ${units.formatters.ufs.format(precios.min)}</td>`,
`<td class="right aligned">UF ${units.formatters.ufs.format(precios.avg)}</td>`,
@ -363,18 +372,25 @@
}
$(`#${units.ids.units}`).DataTable(dto)
document.getElementById(units.ids.unidades_container).style.visibility = 'hidden'
document.getElementById(units.ids.tipos).style.visibility = 'hidden'
document.getElementById(units.ids.lineas).style.visibility = 'hidden'
$(`#${units.ids.results}`).find('.tabular.menu .item').tab({
onVisible: function(tabPath) {
if (tabPath !== 'unidades') {
return
}
$(this.querySelector('table')).DataTable().columns.adjust().draw()
this.querySelector('table').style.width = ''
}
})
document.getElementById(units.ids.results).style.visibility = 'hidden'
units.get().units().then(() => {
units.get().prices().then(() => {
units.get().promotions().then(() => {
units.get().sold().then(() => {
$(units.ids.loader).hide()
document.getElementById(units.ids.unidades_container).style.visibility = 'visible'
document.getElementById(units.ids.tipos).style.visibility = 'visible'
document.getElementById(units.ids.lineas).style.visibility = 'visible'
document.getElementById(units.ids.results).style.visibility = 'visible'
units.draw().units()
units.draw().tipos()
units.draw().lineas()
@ -385,7 +401,7 @@
}
}
$(document).ready(function () {
units.setup({units: 'unidades', unidades_container: 'unidades_container', tipos: 'tipos', lineas: 'lineas', loader: '.ui.loader'})
units.setup({results: 'results', units: 'unidades', tipos: 'tipos', lineas: 'lineas', loader: '.ui.loader'})
})
</script>
@endpush