mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
papel rotativa
This commit is contained in:
@ -1,19 +1,21 @@
|
||||
import ClassSelect from "../../../components/select2.js";
|
||||
import Ajax from "../../../components/ajax.js";
|
||||
|
||||
|
||||
class PlanningRotativa {
|
||||
constructor(domItem) {
|
||||
this.item = domItem
|
||||
this.tablePlanningRot = this.item.find("#planning-rotativa-datatable")
|
||||
this.papelGramajeTablePlanning = this.item.find("#planning-papel-datatable")
|
||||
|
||||
this.papelImpresionHeader = this.item.find('#papel-impresion-name-header')
|
||||
this.datatableColumns = [
|
||||
{ data: 'otId', searchable: false, sortable: false },
|
||||
{ data: 'fecha_entrega_real_at', searchable: true, sortable: false },
|
||||
{ data: 'presupuesto_titulo', searchable: true, sortable: false },
|
||||
{ data: 'maquina_planning_nombre', searchable: true, sortable: false },
|
||||
{ data: 'ot_tirada', searchable: false, sortable: false },
|
||||
{ data: 'maquina_ancho', searchable: false, sortable: false },
|
||||
{ data: 'maquina_alto', searchable: false, sortable: false },
|
||||
{ data: 'maquina_ancho', searchable: false, sortable: false,render: d => `<span class="autonumeric">${d}</span>` },
|
||||
{ data: 'maquina_alto', searchable: false, sortable: false ,render: d => `<span class="autonumeric">${d}</span>` },
|
||||
{ data: 'papel_impresion', searchable: false, sortable: false },
|
||||
{ data: 'papel_gramaje', searchable: false, sortable: false },
|
||||
{ data: 'action', searchable: false, sortable: false, render: this._renderBtnAction },
|
||||
@ -24,31 +26,35 @@ class PlanningRotativa {
|
||||
{ data: 'papelImpresionGramaje', searchable: true, sortable: true },
|
||||
{ data: 'tareasCount', searchable: true, sortable: true },
|
||||
{ data: 'totalTirada', searchable: false, sortable: false },
|
||||
{ data: 'metros', searchable: false, sortable: false },
|
||||
{ data: 'tiempoReal', searchable: false, sortable: false },
|
||||
{
|
||||
data: 'action', searchable: false, sortable: false, render: (d) => {
|
||||
return `<button type="button" class="btn btn-primary btn-sm w-100 papel-gramaje-btn" data-id="${d.data.papelImpresionId}" data-name="${d.data.papelImpresionNombre}" data-bs-toggle="button">${d.title}</button>`
|
||||
return `<button type="button" class="btn btn-primary btn-sm w-100 papel-gramaje-btn" data-id="${d.data.papelImpresionId}" data-bs-toggle="button">${d.title}</button>`
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
]
|
||||
this.maquinaSelectFilter = new ClassSelect($("#maquina-select-filter"), `/maquinas/select`, "Seleccione una maquina", true);
|
||||
this.papelImpresionFilter = new ClassSelect($("#papel-impresion-select-filter"), `/papelesimpresion/select`, "Seleccione un papel", true);
|
||||
this.maquinaSelectFilter = new ClassSelect($("#maquina-select-filter"), `/maquinas/select`, "Seleccione una maquina", true, {}, $('body'));
|
||||
this.papelImpresionFilter = new ClassSelect($("#papel-impresion-select-filter"), `/papelesimpresion/select`, "Seleccione un papel", true, {}, $('body'));
|
||||
this.maquinaSelectFilter.config.dropdownParent = this.item
|
||||
}
|
||||
init() {
|
||||
this.maquinaSelectFilter.init()
|
||||
this.papelImpresionFilter.init()
|
||||
this.papelGramajeTablePlanning.on('click','.papel-gramaje-btn',this.filterPapelGramaje.bind(this))
|
||||
|
||||
this.papelGramajeTablePlanning.on('click', '.papel-gramaje-btn', this.filterPapelGramaje.bind(this))
|
||||
this.papelImpresionFilter.onChange(() => {
|
||||
this.papelImpresionHeader.text(this.papelImpresionFilter.getText())
|
||||
})
|
||||
|
||||
this.datatablePlanningRot = this.tablePlanningRot.DataTable({
|
||||
processing: true,
|
||||
orderCellsTop : true,
|
||||
orderCellsTop: true,
|
||||
layout: {
|
||||
topStart: 'pageLength',
|
||||
topEnd: 'search',
|
||||
bottomStart: 'info',
|
||||
topStart: 'info',
|
||||
topEnd: null,
|
||||
bottomStart: 'pageLength',
|
||||
bottomEnd: 'paging'
|
||||
},
|
||||
|
||||
@ -63,11 +69,12 @@ class PlanningRotativa {
|
||||
});
|
||||
this.papelGramajeDatatable = this.papelGramajeTablePlanning.DataTable({
|
||||
processing: true,
|
||||
orderCellsTop : true,
|
||||
orderCellsTop: true,
|
||||
|
||||
layout: {
|
||||
topStart: 'pageLength',
|
||||
topEnd: 'search',
|
||||
bottomStart: 'info',
|
||||
topStart: 'info',
|
||||
topEnd: null,
|
||||
bottomStart: 'pageLength',
|
||||
bottomEnd: 'paging'
|
||||
},
|
||||
|
||||
@ -93,6 +100,7 @@ class PlanningRotativa {
|
||||
let columnIndex = this.datatableColumns.findIndex((element) => element.data == $(event.currentTarget).attr("name"))
|
||||
this.datatablePlanningRot.column(columnIndex).search(this.papelImpresionFilter.getText()).draw()
|
||||
})
|
||||
this.papelGramajeDatatable.on('draw', this.addTotalFooter.bind(this))
|
||||
}
|
||||
_renderBtnAction(d) {
|
||||
return `<a href="/produccion/ordentrabajo/edit/${d.otId}" class="ot-tarea-comment" data-id="${d.otId}"><i class="ti ti-eye"></i></a>`
|
||||
@ -101,15 +109,49 @@ class PlanningRotativa {
|
||||
this.api().columns()
|
||||
console.log(this.api().columns())
|
||||
}
|
||||
filterPapelGramaje(event)
|
||||
{
|
||||
filterPapelGramaje(event) {
|
||||
const papelImpresionId = $(event.currentTarget).data('id')
|
||||
const papelImpresionName = $(event.currentTarget).data('name')
|
||||
|
||||
|
||||
this.papelImpresionFilter.setOption(papelImpresionId,papelImpresionName)
|
||||
this.getPapelImpresion(papelImpresionId)
|
||||
}
|
||||
getPapelImpresion(papelImpresionId) {
|
||||
let ajax = new Ajax('/papelesimpresion/show/' + papelImpresionId,
|
||||
null,
|
||||
null,
|
||||
this.getPapelImpresionSuccess.bind(this),
|
||||
this.getPapelImpresionError.bind(this)
|
||||
)
|
||||
ajax.get()
|
||||
}
|
||||
getPapelImpresionSuccess(response) {
|
||||
this.papelImpresionFilter.setOption(response.id, response.nombre)
|
||||
this.papelImpresionHeader.text(response.nombre)
|
||||
}
|
||||
getPapelImpresionError(response) { }
|
||||
formatSeconds(s){
|
||||
return [parseInt(s / 60 / 60), parseInt(s / 60 % 60)].join(':').replace(/\b(\d)\b/g, '0$1');
|
||||
}
|
||||
addTotalFooter() {
|
||||
const data = this.papelGramajeDatatable.column(5).data().reduce((a, b) => {
|
||||
let sa = a.split(":")
|
||||
let ha = parseInt(sa[0]) * 3600
|
||||
let ma = parseInt(sa[1]) * 60
|
||||
let sb = b.split(":")
|
||||
let hb = parseInt(sb[0]) * 3600
|
||||
let mb = parseInt(sb[1]) * 60
|
||||
return hb + mb + ha + ma
|
||||
})
|
||||
const metros = this.papelGramajeDatatable.column(4).data().reduce((a, b) => {
|
||||
|
||||
return a + b
|
||||
})
|
||||
$('#total-tiempo-papel').text(this.formatSeconds(data))
|
||||
$('#total-metros').text(metros)
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
export default PlanningRotativa;
|
||||
Reference in New Issue
Block a user