add block ui and file zone

This commit is contained in:
amazuecos
2025-04-06 05:59:23 +02:00
parent 4fb6533926
commit ccfc78ed0d

View File

@ -4,11 +4,11 @@ import DatePicker from "../../components/datepicker.js";
import { alertConfirmationDelete, alertSuccess } from "../../components/alerts/sweetAlert.js"; import { alertConfirmationDelete, alertSuccess } from "../../components/alerts/sweetAlert.js";
import Modal from "../../components/modal.js" import Modal from "../../components/modal.js"
import FileUploadDropzone from '../../components/forms/fileUploadDropzone.js'; import FileUploadDropzone from '../../components/forms/fileUploadDropzone.js';
class OrdenTrabajo { class OrdenTrabajo {
constructor(domItem) { constructor(domItem) {
this.item = domItem this.item = domItem
this.otForm = this.item.find("#ot-edit-form") this.otForm = this.item.find("#ot-edit-form")
this.block = document.querySelector('.section-block');
this.modelId = this.item.data("id"); this.modelId = this.item.data("id");
this.tareasTableItem = this.item.find("#ot-task-table"); this.tareasTableItem = this.item.find("#ot-task-table");
this.tareasId = [] this.tareasId = []
@ -17,6 +17,10 @@ class OrdenTrabajo {
this.alertOrdenTrabajo = this.item.find("#alert-orden-trabajo"); this.alertOrdenTrabajo = this.item.find("#alert-orden-trabajo");
this.btnFinalizarPedido = this.item.find("#btn-finalizar-orden-pedido") this.btnFinalizarPedido = this.item.find("#btn-finalizar-orden-pedido")
this.btnResetTareas = this.item.find("#btn-reset-tareas") 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 = [ this.datatableColumns = [
{ data: 'orden', searchable: true, sortable: true, render: this._renderOrdenTarea.bind(this), width: "10%" }, { data: 'orden', searchable: true, sortable: true, render: this._renderOrdenTarea.bind(this), width: "10%" },
{ data: 'nombre', searchable: true, sortable: true, width: "20%" }, { data: 'nombre', searchable: true, sortable: true, width: "20%" },
@ -153,6 +157,7 @@ class OrdenTrabajo {
return data return data
} }
_handleGetData() { _handleGetData() {
Notiflix.Block.circle('.section-block');
const ajax = new Ajax(`/produccion/ordentrabajo/summary/${this.modelId}`, const ajax = new Ajax(`/produccion/ordentrabajo/summary/${this.modelId}`,
null, null,
null, null,
@ -282,11 +287,14 @@ class OrdenTrabajo {
} finally { } finally {
this.otForm.on("change", ".ot-date", this.handleDateChange.bind(this)) this.otForm.on("change", ".ot-date", this.handleDateChange.bind(this))
this.otForm.on("change", ".ot-preview", this.handlePreimpresionReviewChange.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() { fillPreimpresionReview() {
this.otForm.find("[name=fecha_entrega_warning]").prop("checked", this.summaryData.ot.fecha_entrega_warning) 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) this.otForm.find("[name=fecha_entrega_warning_revised]").prop("checked", this.summaryData.ot.fecha_entrega_warning_revised)
@ -298,6 +306,7 @@ class OrdenTrabajo {
this.otForm.find("[name=realizar_imposicion]").prop("checked", this.summaryData.ot.realizar_imposicion) 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) this.otForm.find("[name=enviar_impresion]").prop("checked", this.summaryData.ot.enviar_impresion)
} }
fillOtDetails() { fillOtDetails() {
const progreso = this.summaryData.ot.progreso const progreso = this.summaryData.ot.progreso
@ -324,6 +333,14 @@ class OrdenTrabajo {
this.espiral.setDate(this.summaryData.dates.fecha_impresion_at) this.espiral.setDate(this.summaryData.dates.fecha_impresion_at)
this.embalaje.setDate(this.summaryData.dates.embalaje_at) this.embalaje.setDate(this.summaryData.dates.embalaje_at)
this.envio.setDate(this.summaryData.dates.envio_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)
} }
@ -372,12 +389,15 @@ class OrdenTrabajo {
}, },
null, null,
(response) => { (response) => {
this._handleGetData();
alertSuccess(response.message).fire() alertSuccess(response.message).fire()
}, },
null null
) )
ajax.post(); ajax.post();
} }
handleDateChange(event) { handleDateChange(event) {
const key = $(event.currentTarget).attr("name") const key = $(event.currentTarget).attr("name")
const data = {} const data = {}
@ -399,6 +419,7 @@ class OrdenTrabajo {
handleDateChangeSuccess(formItem, response) { handleDateChangeSuccess(formItem, response) {
formItem.addClass("is-valid") formItem.addClass("is-valid")
alertSuccess(response.message).fire() alertSuccess(response.message).fire()
this._handleGetData();
if (response.user) { if (response.user) {
formItem.parent().find(".form-text").remove() formItem.parent().find(".form-text").remove()
formItem.parent().append(`<div class="form-text">${[response.user.first_name, response.user.last_name].join(" ")}</div>`) formItem.parent().append(`<div class="form-text">${[response.user.first_name, response.user.last_name].join(" ")}</div>`)
@ -421,6 +442,7 @@ class OrdenTrabajo {
} }
handlePreimpresionReviewChangeSuccess(response) { handlePreimpresionReviewChangeSuccess(response) {
this._handleGetData();
alertSuccess(response.message).fire() alertSuccess(response.message).fire()
} }