Merge branch 'main' into fix/permisos-mensajeria-sidebar

This commit is contained in:
amazuecos
2025-04-06 09:49:46 +02:00
32 changed files with 689 additions and 153 deletions

View File

@ -23,7 +23,7 @@ const PREVIEW_TEMPLATE = `
class FileUploadDropzone {
constructor({ domElement, nameId = "presupuesto_id", getUri = null, postUri = null }) {
constructor({ domElement, nameId = "presupuesto_id", getUri = null, postUri = null, resourcePath = "presupuestos" }) {
Dropzone.autoDiscover = false;
this.domElement = domElement
this.jqElement = $(domElement)
@ -35,6 +35,7 @@ class FileUploadDropzone {
this.getUri = getUri
this.postUri = postUri
this.dataPost[nameId] = this.modelId;
this.resourcePath = resourcePath
}
init() {
@ -58,19 +59,21 @@ class FileUploadDropzone {
maxFilesize: 5e+7, // Bytes
init: this._handleGetFiles.bind(this)
});
this.dropzone.on("addedfile", function (file) {
if (file.hash) {
var viewButton = Dropzone.createElement("<span class='dz-remove'>Ver</span>");
file.previewElement.appendChild(viewButton);
// Listen to the view button click event
viewButton.addEventListener("click", function (e) {
window.open(window.location.protocol + "//" + window.location.host + "/sistema/intranet/presupuestos/" + file.hash, '_blank');
});
}
});
this.dropzone.on("addedfile", this._handleAddedFile.bind(this));
}
}
_handleAddedFile(file) {
if (file.hash) {
var viewButton = Dropzone.createElement("<span class='dz-remove'>Ver</span>");
file.previewElement.appendChild(viewButton);
// Listen to the view button click event
viewButton.addEventListener("click", this.onViewButton.bind(this,file));
}
}
onViewButton(file) {
console.log(window.location.protocol + "//" + window.location.host + "/sistema/intranet/" + this.resourcePath + "/" + file.hash)
window.open(window.location.protocol + "//" + window.location.host + "/sistema/intranet/" + this.resourcePath + "/" + file.hash, '_blank');
}
_getDropzoneFilesFormData() {
var files = this.dropzone.files;
@ -81,7 +84,7 @@ class FileUploadDropzone {
if (files[i].upload) {
var file = files[i];
formData.append('file[' + counter + ']', file);
formData.append('file[]', file);
counter += 1;
}
else {
@ -146,7 +149,7 @@ class FileUploadDropzone {
dropZoneAddFile(mockFile) {
this.dropzone.files.push(mockFile); // add to files array
this.dropzone.emit("addedfile", mockFile);
this.dropzone.emit("thumbnail", mockFile, window.location.host + "/sistema/intranet/presupuestos/" + mockFile.hash);
this.dropzone.emit("thumbnail", mockFile, window.location.host + "/sistema/intranet/" + this.resourcePath + "/" + mockFile.hash);
this.dropzone.emit("complete", mockFile);
this.dropzone.options.success.call(this.dropzone, mockFile);

View File

@ -3,11 +3,12 @@ import ClassSelect from "../../components/select2.js";
import DatePicker from "../../components/datepicker.js";
import { alertConfirmationDelete, alertSuccess } from "../../components/alerts/sweetAlert.js";
import Modal from "../../components/modal.js"
import FileUploadDropzone from '../../components/forms/fileUploadDropzone.js';
class OrdenTrabajo {
constructor(domItem) {
this.item = domItem
this.otForm = this.item.find("#ot-edit-form")
this.block = document.querySelector('.section-block');
this.modelId = this.item.data("id");
this.tareasTableItem = this.item.find("#ot-task-table");
this.tareasId = []
@ -16,6 +17,10 @@ class OrdenTrabajo {
this.alertOrdenTrabajo = this.item.find("#alert-orden-trabajo");
this.btnFinalizarPedido = this.item.find("#btn-finalizar-orden-pedido")
this.btnResetTareas = this.item.find("#btn-reset-tareas")
this.pedidoEnEsperaCheck = this.item.find("#ot-pedido-espera");
this.pedidoEnEsperaBy = this.item.find("#pedido_espera_by");
this.otEstado = this.item.find("#ot-estado");
this.datatableColumns = [
{ data: 'orden', searchable: true, sortable: true, render: this._renderOrdenTarea.bind(this), width: "10%" },
{ data: 'nombre', searchable: true, sortable: true, width: "20%" },
@ -29,9 +34,24 @@ class OrdenTrabajo {
},
]
/**
* DROP ZONE FILES OT
*/
this.configUploadDropzone = {
domElement: '#dropzone-ot-files',
nameId: "orden_trabajo_id",
getUri: '/produccion/ordentrabajo/get_files',
postUri: '/produccion/ordentrabajo/upload_files',
resourcePath : 'orden_trabajo/' + this.modelId
}
if ($(this.configUploadDropzone.domElement).length > 0) {
this.fileUploadDropzone = new FileUploadDropzone(this.configUploadDropzone)
}
}
initDropFiles(){
if ($(this.configUploadDropzone.domElement).length > 0) {
this.fileUploadDropzone.init()
}
}
configDatePickers() {
const option = {
@ -90,6 +110,7 @@ class OrdenTrabajo {
this.otForm.off("click", ".decrease-order")
}
init() {
this.initDropFiles()
this.configDatePickers()
this.initDatatableTareas()
this.tareasTableItem.on("draw.dt", this.createSelectMaquinaTarea.bind(this))
@ -136,6 +157,7 @@ class OrdenTrabajo {
return data
}
_handleGetData() {
Notiflix.Block.circle('.section-block');
const ajax = new Ajax(`/produccion/ordentrabajo/summary/${this.modelId}`,
null,
null,
@ -265,11 +287,14 @@ class OrdenTrabajo {
} finally {
this.otForm.on("change", ".ot-date", this.handleDateChange.bind(this))
this.otForm.on("change", ".ot-preview", this.handlePreimpresionReviewChange.bind(this))
Notiflix.Block.remove('.section-block');
}
}
handleSummaryError(error) { }
handleSummaryError(error) {
Notiflix.Block.remove('.section-block');
}
fillPreimpresionReview() {
this.otForm.find("[name=fecha_entrega_warning]").prop("checked", this.summaryData.ot.fecha_entrega_warning)
this.otForm.find("[name=fecha_entrega_warning_revised]").prop("checked", this.summaryData.ot.fecha_entrega_warning_revised)
@ -281,6 +306,7 @@ class OrdenTrabajo {
this.otForm.find("[name=realizar_imposicion]").prop("checked", this.summaryData.ot.realizar_imposicion)
this.otForm.find("[name=enviar_impresion]").prop("checked", this.summaryData.ot.enviar_impresion)
}
fillOtDetails() {
const progreso = this.summaryData.ot.progreso
@ -307,6 +333,14 @@ class OrdenTrabajo {
this.espiral.setDate(this.summaryData.dates.fecha_impresion_at)
this.embalaje.setDate(this.summaryData.dates.embalaje_at)
this.envio.setDate(this.summaryData.dates.envio_at)
this.pedidoEnEsperaCheck.prop("checked",this.summaryData.ot.is_pedido_espera);
if(this.summaryData.ot.pedido_espera_by){
this.pedidoEnEsperaBy.text([this.summaryData.ot.pedido_espera_by.first_name,this.summaryData.ot.pedido_espera_by.last_name].join(" "))
}else{
this.pedidoEnEsperaBy.text("");
}
this.otEstado.val(this.summaryData.ot.estado)
}
@ -355,12 +389,15 @@ class OrdenTrabajo {
},
null,
(response) => {
this._handleGetData();
alertSuccess(response.message).fire()
},
null
)
ajax.post();
}
handleDateChange(event) {
const key = $(event.currentTarget).attr("name")
const data = {}
@ -382,6 +419,7 @@ class OrdenTrabajo {
handleDateChangeSuccess(formItem, response) {
formItem.addClass("is-valid")
alertSuccess(response.message).fire()
this._handleGetData();
if (response.user) {
formItem.parent().find(".form-text").remove()
formItem.parent().append(`<div class="form-text">${[response.user.first_name, response.user.last_name].join(" ")}</div>`)
@ -404,6 +442,7 @@ class OrdenTrabajo {
}
handlePreimpresionReviewChangeSuccess(response) {
this._handleGetData();
alertSuccess(response.message).fire()
}

View File

@ -13,8 +13,10 @@ class PlanningRotativa {
this.papelImpresionHeader = this.item.find('#papel-impresion-name-header')
this.papelImpresionPlanaHeader = this.item.find('#papel-impresion-name-plana-header')
this.checkAllMetros = this.item.find("#metros-check-all")
this.checkAllPliegos = this.item.find("#pliegos-check-all")
this.tiempoPlanaTotal = this.tablePlanningPlana.find('#horas-sel-total')
this.datatableColumns = [
{ data: 'otId', searchable: false, sortable: false, width: "3rem" },
@ -25,10 +27,11 @@ class PlanningRotativa {
{ data: 'papel_ancho', searchable: false, sortable: false, width: "5rem", render: d => `<span class="autonumeric">${d}</span>` },
{ data: 'papel_alto', searchable: false, sortable: false, width: "5rem", render: d => `<span class="autonumeric">${d}</span>` },
{ data: 'papel_impresion', searchable: false, sortable: false },
{ data: 'papel_gramaje', searchable: false, sortable: false, width: "5rem", render: d => `<span class="autonumeric">${d}</span>` },
{ data: 'papel_gramaje',name:"presupuesto_linea.gramaje", searchable: false, sortable: false, width: "5rem", render: d => `<span class="autonumeric">${d}</span>` },
{ data: 'corte', searchable: false, sortable: false, render: this.renderCorteImage.bind(this), width: "10rem" },
{ data: 'metros_check', searchable: false, sortable: false, render: d => `<input class="form-check-input metros-check" data-id="${d}" type="checkbox" value="" />` },
{ data: 'metros', searchable: false, sortable: false, render: d => `<span class="autonumeric">${d}</span>` },
{ data: 'action', searchable: false, sortable: false, render: this._renderBtnAction },
]
@ -41,9 +44,10 @@ class PlanningRotativa {
{ data: 'papel_ancho', searchable: false, sortable: false, width: "5rem", render: d => `<span class="autonumeric">${d}</span>` },
{ data: 'papel_alto', searchable: false, sortable: false, width: "5rem", render: d => `<span class="autonumeric">${d}</span>` },
{ data: 'papel_impresion', searchable: false, sortable: false },
{ data: 'papel_gramaje', searchable: false, sortable: false, width: "5rem", render: d => `<span class="autonumeric">${d}</span>` },
{ data: 'papel_gramaje', name:"presupuesto_linea.gramaje", searchable: false, sortable: false, width: "5rem", render: d => `<span class="autonumeric">${d}</span>` },
{ data: 'pliegos_check', searchable: false, sortable: false, render: d => `<input class="form-check-input pliegos-check" data-id="${d}" type="checkbox" value="" />` },
{ data: 'pliegosPedido', searchable: false, sortable: false, render: d => `<span class="autonumeric">${d}</span>` },
{ data: 'tiempo_real_sum', searchable: false, sortable: false,render: d => this.formatSeconds(parseFloat(d))},
{ data: 'action', searchable: false, sortable: false, render: this._renderBtnAction },
]
@ -86,6 +90,7 @@ class PlanningRotativa {
}, $('body'));
this.papelImpresionFilter = new ClassSelect(this.tablePlanningRot.find(".planning-papel-select"), `/produccion/ordentrabajo/planning/select/papel/rotativa`, "Seleccione un papel", true, {}, $('body'));
this.maquinaSelectFilterPlana = new ClassSelect(this.tablePlanningPlana.find(".planning-maquina-select"), `/produccion/ordentrabajo/planning/select/maquina/plana`, "Seleccione una maquina", true, {}, $('body'));
this.maquinaPadreSelectFilterPlana = new ClassSelect(this.tablePlanningPlana.find(".planning-maquina-padre-select"), `/produccion/ordentrabajo/planning/select/maquina/padre/plana`, "Máquina padre", true, {}, $('body'));
this.papelImpresionFilterPlana = new ClassSelect(this.tablePlanningPlana.find(".planning-papel-select"), `/produccion/ordentrabajo/planning/select/papel/plana`, "Seleccione un papel", true, {}, $('body'));
this.maquinaSelectFilter.config.dropdownParent = this.item
}
@ -112,10 +117,12 @@ class PlanningRotativa {
this.totalMetrosSel = new AutoNumeric(this.item.find('#metros-sel-total')[0], autoNumericOptions);
this.totalPliegos = new AutoNumeric(this.item.find('#total-pliegos')[0], autoNumericPliegosOptions);
this.totalPliegosSel = new AutoNumeric(this.item.find('#pliegos-sel-total')[0], autoNumericPliegosOptions);
this.maquinaSelectFilter.init()
this.papelImpresionFilter.init()
this.maquinaSelectFilterPlana.init()
this.papelImpresionFilterPlana.init()
this.maquinaPadreSelectFilterPlana.init();
this.checkAllMetros.on('change', () => {
let isChecked = this.checkAllMetros.prop('checked')
this.item.find(".metros-check").prop('checked', isChecked).trigger("change")
@ -158,7 +165,15 @@ class PlanningRotativa {
url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json"
},
columns: this.datatablePlanaColumns,
ajax: '/produccion/ordentrabajo/planning/plana/datatable'
ajax: {
url : '/produccion/ordentrabajo/planning/plana/datatable',
data : d => {
if(this.maquinaPadreSelectFilterPlana.getVal()){
d.padre_id = this.maquinaPadreSelectFilterPlana.getVal()
}
}
}
});
this.papelGramajeDatatable = this.papelGramajeTablePlanning.DataTable({
processing: true,
@ -218,9 +233,12 @@ class PlanningRotativa {
let columnIndex = this.datatablePlanaColumns.findIndex((element) => element.data == $(event.currentTarget).attr("name"))
this.datatablePlanningPlana.column(columnIndex).search(this.maquinaSelectFilterPlana.getText()).draw()
})
this.tablePlanningPlana.on("change", ".planning-papel-select", (event) => {
this.tablePlanningPlana.on("change", ".planning-maquina-select", (event) => {
let columnIndex = this.datatablePlanaColumns.findIndex((element) => element.data == $(event.currentTarget).attr("name"))
this.datatablePlanningPlana.column(columnIndex).search(this.papelImpresionFilterPlana.getText()).draw()
this.datatablePlanningPlana.column(columnIndex).search(this.maquinaSelectFilterPlana.getText()).draw()
})
this.tablePlanningPlana.on("change", ".planning-maquina-padre-select", (event) => {
this.datatablePlanningPlana.ajax.reload();
})
this.papelPliegoDatatable.on('draw', this.addTotalFooterPliego.bind(this))
@ -261,25 +279,27 @@ class PlanningRotativa {
}
getPapelImpresionSuccess(response) {
this.papelImpresionFilter.setOption(response.id, response.nombre)
this.tablePlanningRot.find('input[name=gramaje]').val(response.gramaje).trigger("change")
this.tablePlanningRot.find('input[name=papel_gramaje]').val(response.gramaje).trigger("change")
this.papelImpresionHeader.text(response.nombre)
}
getPapelImpresionError(response) { }
getPapelImpresionPlanaSuccess(response) {
this.papelImpresionFilterPlana.setOption(response.id, response.nombre)
this.tablePlanningPlana.find('input[name=gramaje]').val(response.gramaje).trigger("change")
this.tablePlanningPlana.find('input[name=papel_gramaje]').val(response.gramaje).trigger("change")
this.papelImpresionPlanaHeader.text(response.nombre)
}
getPapelImpresionPlanaError(response) { }
formatSeconds(s) {
return [parseInt(s / 60 / 60), parseInt(s / 60 % 60)].join(':').replace(/\b(\d)\b/g, '0$1');
const hours = Math.floor(s / 60 / 60)
const minutes = Math.floor(s / 60 % 60)
return [hours, minutes].join(':').replace(/\b(\d)\b/g, '0$1');
}
addTotalFooter() {
const seconds = this.papelGramajeDatatable.column(5).data().reduce((a, b) => {
return parseFloat(a) + parseFloat(b)
}, 0)
const metros = this.papelGramajeDatatable.column(4).data().map((e) => parseFloat(e))
$('#total-tiempo-papel').text(this.formatSeconds(seconds))
$('#total-tiempo-papel').text(this.formatSeconds(parseInt(seconds)))
this.totalMetros.set(metros.reduce((a, b) => a + b, 0))
@ -305,7 +325,14 @@ class PlanningRotativa {
const metros_sel = this.datatablePlanningPlana.rows((idx, data, node) => {
return $(node).find('input[type="checkbox"]').prop('checked');
}).data().toArray().map((e) => parseInt(e.pliegosPedido))
const tiempo_total_sel = this.datatablePlanningPlana.rows((idx, data, node) => {
return $(node).find('input[type="checkbox"]').prop('checked');
}).data().toArray().map((e) => parseFloat(e.tiempo_real_sum))
this.totalPliegosSel.set(metros_sel.reduce((a, b) => a + b, 0))
const totalSeconds = tiempo_total_sel.reduce((a,b) => a+b,0)
console.log("Total seconds",totalSeconds);
this.tiempoPlanaTotal.text(this.formatSeconds(totalSeconds))
}
renderCorteImage(data) {

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long