You are on page 1of 2

var dat = {};

dat["id_tipo"] = data.idForm
dat["id_form"] = data.idForm;
dat["sap_id_tipo"] = data.sap_id_tipo;
//eliminar el attachment y colocarlo en el menu
if (typeof data.detalledelasolicitudColumnsStock !== 'undefined' &&
data.detalledelasolicitudColumnsStock.detalledelasolicitudColumnsStockAdjuntarcotiz
acin.length > 0) {
data.cotizacion =
data.detalledelasolicitudColumnsStock.detalledelasolicitudColumnsStockAdjuntarcotiz
acin[0].url.toString().replace('data:image/jpeg;base64,',
'').replace('data:application/pdf;base64,', '').replace('data:image/png;base64,',
'');
delete data.detalledelasolicitudColumnsStockAdjuntarcotizacin;
} else {
delete data.detalledelasolicitudColumnsStockAdjuntarcotizacin;
delete data.cotizacion;

}
Swal.fire({
text: 'Cargando',
allowOutsideClick: false
});

Swal.showLoading();

var successM = {
title: "Datos Guardados!",
label: "Los Datos han sido guardados",
type: "success"
};

var errorM = {
title: "Error Al Guardar Solicitud!",
label: "Favor intentarlo nuevamente. Si el problema persiste favor comunicarse
con el equipo Técnico",
type: "error"
};

/*$.ajax({
url: data.urlBase + "api/campos/" + data.idForm,
dataType: "json",
method: "GET"

}).done(function(response) {
/*if (response) {
var propertyName = "campo";
for (var i = 1; i < 9; i++) {
propertyName = "campo" + i;

if (response.hasOwnProperty(propertyName)) {

dat[propertyName] = response[propertyName];
}
}
}*/

dat["campos_json"] = JSON.stringify(submission);
dat["estado"] = "1";
$.ajax({
url: data.urlBase + "api/form/",
dataType: "json",
method: "POST",
data: dat
}).done(function(response) {

if (response.status) {
Swal.close();
Swal.fire({
title: successM.title,
text: successM.label,
icon: successM.type,
allowOutsideClick: false,
onClose: function(){
window.location.reload();
}
});
} else {
Swal.close();
var errorMessage = errorM.label;
if(response.message){
if(response.message.trim().length > 0){
errorMessage = response.message;
}
}
Swal.fire({
title: errorM.title,
text: errorMessage,
icon: errorM.type,
allowOutsideClick: false
});
}

}).fail(function(response) {
Swal.close();
Swal.fire({
title: errorM.title,
text: errorM.label,
icon: errorM.type,
allowOutsideClick: false
});
});

/*});*/

You might also like