Diferenciar naming en base a donde se invoca la descarga, OT vs PRESUPUESTO

This commit is contained in:
imnavajas
2025-07-17 14:17:42 +02:00
parent f73472c729
commit e804aa3768
9 changed files with 33 additions and 116 deletions

View File

@ -1,6 +1,6 @@
import Ajax from '../ajax.js';
import { alertSuccessMessage } from '../alerts/sweetAlert.js'
import { alertSuccessMessage, alertWarningMessage } from '../alerts/sweetAlert.js'
const PREVIEW_TEMPLATE = `
<div class="dz-preview dz-file-preview">
@ -25,7 +25,7 @@ const PREVIEW_TEMPLATE = `
class FileUploadDropzone {
constructor({ domElement, nameId = "presupuesto_id", getUri = null, postUri = null, resourcePath = "presupuestos" }) {
constructor({ domElement, nameId = "presupuesto_id", getUri = null, postUri = null, resourcePath = "presupuestos", otId = null }) {
Dropzone.autoDiscover = false;
this.domElement = domElement
this.jqElement = $(domElement)
@ -35,6 +35,7 @@ class FileUploadDropzone {
this.btnDownloadFiles = $(`#${domElement.replace('#', '')}_btnDownloadFiles`);
this.dataPost = {}
this.nameId = nameId;
this.otId = otId;
this.getUri = getUri
this.postUri = postUri
this.dataPost[nameId] = this.modelId;
@ -160,7 +161,8 @@ class FileUploadDropzone {
url: `/presupuestoadmin/download_zip`,
type: 'POST',
data: {
[this.nameId]: this.modelId
[this.nameId]: this.modelId,
'ot_id': this.otId
},
xhrFields: {
responseType: 'blob'
@ -185,7 +187,7 @@ class FileUploadDropzone {
window.URL.revokeObjectURL(url);
},
error: () => {
alertWarningMessage("Error al descargar el archivo ZIP.");
alertWarningMessage("Error", "Error al descargar el archivo ZIP.");
},
complete: () => {
$("#loader").modal('hide');

View File

@ -10,6 +10,7 @@ class OrdenTrabajo {
this.otForm = this.item.find("#ot-edit-form")
this.block = document.querySelector('.section-block');
this.modelId = this.item.data("id");
this.otId = parseInt($("#dropzone-ot-files").data("ot-id")) || null;
this.tareasTableItem = this.item.find("#ot-task-table");
this.tareasId = []
this.summaryData = {}
@ -70,6 +71,7 @@ class OrdenTrabajo {
this.configUploadDropzone = {
domElement: '#dropzone-ot-files',
nameId: "presupuesto_id",
otId: this.otId,
getUri: '/presupuestos/presupuestocliente/get_files',
postUri: '/presupuestos/presupuestocliente/upload_files'
}