Separacion de Promocion de Contrato y Precio
"Simplificacion" de datos en listado de precios
This commit is contained in:
@ -0,0 +1,124 @@
|
||||
<table class="ui table" id="unidades">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Tipo</th>
|
||||
<th>Tipo Order</th>
|
||||
<th class="right aligned">Unidad</th>
|
||||
<th>Unidad Orden</th>
|
||||
<th>Estado</th>
|
||||
<th class="right aligned">Precio Lista</th>
|
||||
<th class="right aligned">Porcentaje</th>
|
||||
<th class="right aligned">Precio Final</th>
|
||||
<th>Fecha Inicio</th>
|
||||
<th>Fecha Término</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody></tbody>
|
||||
</table>
|
||||
|
||||
@push('page_scripts')
|
||||
<script>
|
||||
class UnitsTable extends TableHandler {
|
||||
ids = {
|
||||
units: 'unidades',
|
||||
}
|
||||
constructor(commission) {
|
||||
super(commission)
|
||||
|
||||
const dto = structuredClone(datatables_defaults)
|
||||
dto.pageLength = 100
|
||||
dto.columnDefs = [
|
||||
{
|
||||
target: [1, 3],
|
||||
visible: false
|
||||
},
|
||||
{
|
||||
target: 0,
|
||||
orderData: 1
|
||||
},
|
||||
{
|
||||
target: 2,
|
||||
orderData: 3
|
||||
},
|
||||
{
|
||||
target: [2, 5, 6, 7],
|
||||
className: 'dt-right right aligned'
|
||||
}
|
||||
]
|
||||
dto.order = [[1, 'asc'], [3, 'asc']]
|
||||
dto.language.searchBuilder = searchBuilder
|
||||
dto.layout = {
|
||||
top1Start: {
|
||||
searchBuilder: {
|
||||
columns: [0, 2, 4, 5, 6, 7, 8, 9],
|
||||
}
|
||||
},
|
||||
top1End: {
|
||||
buttons: [
|
||||
{
|
||||
extend: 'excelHtml5',
|
||||
className: 'green',
|
||||
text: 'Exportar a Excel <i class="file excel icon"></i>',
|
||||
title: 'Comisiones {{ $contract->broker->name }} {{ $contract->project->descripcion }}',
|
||||
download: 'open',
|
||||
exportOptions: {
|
||||
columns: [0, 2, 4, 5, 6, 7],
|
||||
/*format: {
|
||||
body: (data, row, columnIdx, node) => {
|
||||
const formats = this.columns.filter(columnDef => columnDef.format)
|
||||
const match = formats.map(({title}) => title).indexOf(this.columns[columnIdx].title)
|
||||
if (match > -1) {
|
||||
return formats[match].format(data)
|
||||
}
|
||||
if (typeof data === 'string' && data.includes('<span data-tooltip')) {
|
||||
return data.replace(/<span data-tooltip="(.*)">(.*)<\/span>/, '$2')
|
||||
}
|
||||
return data
|
||||
}
|
||||
}*/
|
||||
},
|
||||
customize: xlsx => {
|
||||
const sheet = xlsx.xl.worksheets['sheet1.xml']
|
||||
const columns = Object.values($('row[r="2"] t', sheet).map((idx, column) => column.textContent))
|
||||
const columnStylesMap = {
|
||||
Valor: '63',
|
||||
Fecha: '15'
|
||||
}
|
||||
Object.entries(columnStylesMap).forEach((column, style) => {
|
||||
const columnIndex = String.fromCharCode('A'.charCodeAt(0) + columns.indexOf(column))
|
||||
$(`c[r^="${columnIndex}"]`, sheet).attr('s', style)
|
||||
})
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
$(`#${this.ids.units}`).DataTable(dto)
|
||||
}
|
||||
draw({units, formatters}) {
|
||||
const table = $(`#${this.ids.units}`).DataTable()
|
||||
table.clear()
|
||||
const tableData = []
|
||||
const prices = this.prices(units)
|
||||
units.forEach(unidad => {
|
||||
const tipo = unidad.proyecto_tipo_unidad.tipo_unidad.descripcion
|
||||
const price = prices.find(p => p.id === unidad.id)
|
||||
tableData.push([
|
||||
tipo.charAt(0).toUpperCase() + tipo.slice(1),
|
||||
unidad.proyecto_tipo_unidad.tipo_unidad.orden,
|
||||
unidad.descripcion,
|
||||
unidad.descripcion.padStart(4, '0'),
|
||||
unidad.sold ? 'Vendida' : 'Disponible',
|
||||
'UF ' + formatters.ufs.format(price.base ?? 0),
|
||||
formatters.percent.format(price.amount ?? 0),
|
||||
'UF ' + formatters.ufs.format(price.final ?? 0),
|
||||
unidad.promotion?.start_date ?? '',
|
||||
unidad.promotion?.end_date ?? '',
|
||||
])
|
||||
})
|
||||
table.rows.add(tableData)
|
||||
table.draw()
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@endpush
|
Reference in New Issue
Block a user