492 lines
No EOL
17 KiB
JavaScript
492 lines
No EOL
17 KiB
JavaScript
|
|
$("#FormControlAprobaciones").EnableValidationToolTip();
|
|
var model = {};
|
|
var Etapas = {
|
|
AN_Rev_Doc_Clasificar: ($("#hiddenStep").val() == "AN_Rev_Doc_Clasificar" ? true : false),
|
|
AN_Preanalisis: ($("#hiddenStep").val() == "AN_Preanalisis" ? true : false),
|
|
AN_Informe_Analisis: ($("#hiddenStep").val() == "AN_Informe_Analisis" ? true : false),
|
|
AN_Visita_Seguimiento: ($("#hiddenStep").val() == "AN_Visita_Seguimiento" ? true : false),
|
|
FR_Rev_Info_Caso: ($("#hiddenStep").val() == "FR_Rev_Info_Caso" ? true : false),
|
|
DE_Inclu_Sol_Desembolso: ($("#hiddenStep").val() == "DE_Inclu_Sol_Desembolso" ? true : false),
|
|
DE_Rev_Info_Caso: ($("#hiddenStep").val() == "DE_Rev_Info_Caso" ? true : false),
|
|
AP_Corre_Caratula_Adjuntar_Doc: ($("#hiddenStep").val() == "AP_Corre_Caratula_Adjuntar_Doc" ? true : false),
|
|
DE_AP_Corre_Caratula_Adjuntar_Doc: ($("#hiddenStep").val() == "DE_AP_Corre_Caratula_Adjuntar_Doc" ? true : false),
|
|
AP_Enviar_AProbacion: ($("#hiddenStep").val() == "AP_Enviar_AProbacion" ? true : false),
|
|
FR_Rev_Info_Caso_Gara_Real: ($("#hiddenStep").val() == "FR_Rev_Info_Caso_Gara_Real" ? true : false)
|
|
};
|
|
var temporizador_analisis = {}
|
|
var IdEtapa = null;
|
|
|
|
|
|
var RegistroAutomaticoComentarioDevolucion = false;
|
|
var DocumentosAdicionalesEntregados = true;
|
|
|
|
|
|
jQuery(document).ready(function () {
|
|
|
|
if (Etapas.AN_Preanalisis) {
|
|
if ($("#hiddenTaskStatus").val() == 3)
|
|
GetControlsSettings("Cathay_AN_Informe_AnalisisReadOnly", "Cathay_ControlAprobaciones", "FormControlAprobaciones", true);
|
|
else
|
|
GetControlsSettings("Cathay_AN_Informe_Analisis", "Cathay_ControlAprobaciones", "FormControlAprobaciones", true);
|
|
|
|
}
|
|
else if (Etapas.FR_Rev_Info_Caso || Etapas.FR_Rev_Info_Caso_Gara_Real) {
|
|
GetControlsSettings("Cathay_FR_Rev_Info_Caso", "Cathay_ControlAprobaciones", "FormControlAprobaciones", true);
|
|
$("#titulo_Lista").attr("style", "display:none");
|
|
$("#fafa").attr("style", "display:none");
|
|
$("#divListaClientes").attr("style", "display:none");
|
|
}
|
|
else if (Etapas.AN_Rev_Doc_Clasificar) {
|
|
if ($("#hiddenTaskStatus").val() == 3)
|
|
GetControlsSettings("Cathay_AN_Rev_Doc_ClasificarReadOnly", "Cathay_ControlAprobaciones", "FormControlAprobaciones", true);
|
|
else
|
|
GetControlsSettings("Cathay_AN_Rev_Doc_Clasificar", "Cathay_ControlAprobaciones", "FormControlAprobaciones", true);
|
|
$("#titulo_Lista").attr("style", "display:none");
|
|
$("#fafa").attr("style", "display:none");
|
|
$("#titulo_pantallaHistorial").attr("style", "display:none");
|
|
$("#fafiletext").attr("style", "display:none");
|
|
}
|
|
else if (Etapas.AP_Corre_Caratula_Adjuntar_Doc || Etapas.DE_AP_Corre_Caratula_Adjuntar_Doc || Etapas.AP_Enviar_AProbacion) {
|
|
GetControlsSettings("Cathay_AP_Corre_Caratula_Adjuntar_Doc", "Cathay_ControlAprobaciones", "FormControlAprobaciones", true);
|
|
$("#titulo_pantalla").attr("style", "display:none");
|
|
$("#titulo_pantallaHistorial").attr("style", "display:none");
|
|
|
|
$("#fafiletext").attr("style", "display:none");
|
|
$("#i_titulo_pantalla").attr("style", "display:none");
|
|
}
|
|
else if (Etapas.DE_Inclu_Sol_Desembolso || Etapas.DE_Rev_Info_Caso) {
|
|
GetControlsSettings("Cathay_InclusionDesembolso", "Cathay_ControlAprobaciones", "FormControlAprobaciones", true);
|
|
$("#titulo_Lista").attr("style", "display:none");
|
|
$("#fafa").attr("style", "display:none");
|
|
}
|
|
else {
|
|
GetControlsSettings("Cathay_Disable_Form", "Cathay_ControlAprobaciones", "FormControlAprobaciones", true);
|
|
$("#titulo_Lista").attr("style", "display:none");
|
|
$("#fafa").attr("style", "display:none");
|
|
}
|
|
});
|
|
|
|
this.getDataModel = function () {
|
|
|
|
if (Etapas.AN_Preanalisis)
|
|
temporizador_analisis = CargarConfiguracionContadorAnalisis();
|
|
|
|
$("#btnCompletarTarea").unbind('click');
|
|
$("#btnCompletarTarea").click(function () {
|
|
|
|
if (!confirm("¿Desea completar la tarea?")) {
|
|
ENDREQUEST();
|
|
return;
|
|
}
|
|
|
|
if (Etapas.AN_Preanalisis) {
|
|
ConsultaDocumentosAdiconales();
|
|
if (DocumentosAdicionalesEntregados == false) {
|
|
toastr.warning("No se puede completar la etapa. Hay documentos adicionales pendientes de entregar");
|
|
ENDREQUEST();
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
if (Etapas.AN_Preanalisis)
|
|
GuardarFormularioAnalisis(false, true, true);
|
|
|
|
GridExpediente_Guardar(function () { GuardarFormulario(true); }, null, null, null, null, true);
|
|
});
|
|
|
|
$("#HistorialAprobaciones").Grid('Set', {
|
|
setCustomSettings: function (Settings) {
|
|
|
|
if (Settings.data.length > 0)
|
|
$.each(Settings.data, function (id, item) {
|
|
item.UserID = item.UserID.split('/').length > 1 ? item.UserID.split('/')[1] : item.UserID;
|
|
item.cFecha = Ultimus.GetDateFormatNoTime(item.Fecha);
|
|
});
|
|
|
|
return Settings;
|
|
}
|
|
});
|
|
|
|
$("#btnBitacoraComentarioDevolucion").unbind();
|
|
$("#btnBitacoraComentarioDevolucion").click(function () {
|
|
//******************************************************************
|
|
//Inicializa y abre los comentarios de tipo finalizacion de trámite
|
|
//******************************************************************
|
|
InicializarBitacoraComentariosInternos("", EnumTipoComentario.ComentarioDevolucionTramite, false, BitacoraComentariosInternos_Show);
|
|
});
|
|
|
|
$("#ddlDecision").change(function () {
|
|
ToggleComentarios();
|
|
ToggleRechazo();
|
|
toggleAnalista();
|
|
habilitaAnalistaPreanlisis();
|
|
});
|
|
|
|
$("#ddlListaClientes").change(function () { CargarDocumentosSolicitante(); });
|
|
|
|
|
|
CargarDecisiones();
|
|
//ToggleComentarios();
|
|
//ToggleRechazo();
|
|
habilitaAnalistaPreanlisis();
|
|
if (Etapas.DE_Inclu_Sol_Desembolso)
|
|
$("#btnFinalizarTarea").hide();
|
|
|
|
|
|
}
|
|
|
|
this.CargarDecisiones = function () {
|
|
|
|
//Ultimus.AjaxGetData((server + "api/GlobalAPI/ObtenerDecision?filtro=&Etapa=" + encodeURIComponent($("#hiddenStep").val()) + "&NombreProceso=" + encodeURIComponent($("#hiddenProcess").val())), false, false, function (data) {
|
|
|
|
//
|
|
|
|
//
|
|
//});
|
|
|
|
var uri = "api/GlobalAPI/ObtenerDecision?filtro=&Etapa=" + encodeURIComponent($("#hiddenStep").val()) + "&NombreProceso=" + encodeURIComponent($("#hiddenProcess").val());
|
|
$.ajax({
|
|
type: 'GET',
|
|
url: server + uri,
|
|
cache: false,
|
|
contentType: 'application/json; charset=utf-8',
|
|
dataType: 'json',
|
|
async: false,
|
|
success: function (data) {
|
|
$("#ddlDecision").empty();
|
|
|
|
$('#ddlDecision').append($("<option></option>")
|
|
.attr("value", "")
|
|
.text(""));
|
|
|
|
$.each(data, function (id, item) {
|
|
|
|
$('#ddlDecision').append($("<option></option>")
|
|
.attr("value", item.codigo)
|
|
.text(item.descripcion));
|
|
});
|
|
|
|
}
|
|
}).fail(function (jqxhr, textStatus, error) {
|
|
if (typeof AjaxFailEvent !== 'undefined' && $.isFunction(AjaxFailEvent) && !AjaxFailEvent(jqxhr, textStatus, error))
|
|
return;
|
|
toastr.error("Ha ocurrido un error inesperado. Vuelva a intentarlo mas tarde", Message_Error);
|
|
HabilitarMenu();
|
|
ENDREQUEST();
|
|
|
|
}).then(function (value) {
|
|
CargarFormulario();
|
|
});
|
|
|
|
}
|
|
|
|
this.CargarFormulario = function () {
|
|
|
|
model = LeerControlesUltimus(model);
|
|
model.DatosGeneralesAnalisis = { IdSolicitud: $("#hidden_co_solicitud").val() };
|
|
|
|
Ultimus.AjaxPostData(server + 'api/AnalisisAPI/CargarAprobacion', model, false, false, function (data) {
|
|
model = data;
|
|
|
|
IdEtapa = model.Aprobacion.Etapas.IdEtapa;
|
|
|
|
|
|
|
|
|
|
$("#ddlAccionRechazo").empty();
|
|
|
|
$('#ddlAccionRechazo').append($("<option></option>")
|
|
.attr("value", "")
|
|
.text(""));
|
|
|
|
if (model.ListaDecicionesAccionRechazo != null)
|
|
$.each(model.ListaDecicionesAccionRechazo, function (id, item) {
|
|
|
|
$('#ddlAccionRechazo').append($("<option></option>")
|
|
.attr("value", item.IdDecision)
|
|
.text(item.Descripcion));
|
|
});
|
|
|
|
ToggleRechazo();
|
|
ToggleComentarios();
|
|
|
|
GridExpediente_Inicializar({
|
|
WithAnalisis: false,
|
|
WithCumplimiento: false,
|
|
WithPorProducto: false,
|
|
WithFormalizacion: false,
|
|
WithAnalisisExpSalida: true,
|
|
WithDocumentosAdicionales: false,
|
|
DefaultTipoExpediente: TipoExpediente.AnalisisDeCreditoExpSalida
|
|
});
|
|
|
|
|
|
$("#HistorialAprobaciones").Grid('BuildGrid', LeerControlesUltimus({}));
|
|
});
|
|
|
|
}
|
|
|
|
this.GuardarFormulario = function (End) {
|
|
|
|
if (!$("#FormControlAprobaciones").valid()) {
|
|
toastr.warning("Debe completar los campos requeridos", Message_Warning)
|
|
ENDREQUEST();
|
|
return;
|
|
}
|
|
|
|
|
|
var Aprobacion = {
|
|
IdSolicitud: $("#hidden_co_solicitud").val(),
|
|
IdEtapa: IdEtapa,
|
|
IdDecision: $("#ddlDecision option:selected").val(),
|
|
UserID: $("#hiddenUserID").val(),
|
|
Fecha: null,
|
|
Comentario: (Etapas.AN_Preanalisis && $("#ddlDecision option:selected").val() == "17" ? $("#ddlAccionRechazo option:selected").text() + ". " : "") + $("#txtComentariosAdicionales").val(),
|
|
UsuarioAsignado: Etapas.AN_Preanalisis || Etapas.FR_Rev_Info_Caso || Etapas.FR_Rev_Info_Caso_Gara_Real || Etapas.DE_Inclu_Sol_Desembolso || model.Analista == null ? null : model.Analista.UserId,
|
|
AccionRechazo: $("#ddlAccionRechazo option:selected").val(),
|
|
Process: $("#hiddenProcess").val(),
|
|
Step: $("#hiddenStep").val(),
|
|
Incident: $("#hiddenIncident").val()
|
|
};
|
|
|
|
|
|
|
|
switch (true) {
|
|
//Si es Preanalisis AND => (La Decision = 13 OR (La Decision es = 17 AND La Accion = 19))
|
|
case (Etapas.AN_Preanalisis &&
|
|
($.inArray($("#ddlDecision option:selected").val(), ["13"]) != -1 ||
|
|
($.inArray($("#ddlDecision option:selected").val(), ["17"]) != -1 && $.inArray($("#ddlAccionRechazo option:selected").val(), ["19"]) != -1))):
|
|
RegistroAutomaticoComentarioDevolucion = true;
|
|
break;
|
|
case (Etapas.AN_Rev_Doc_Clasificar && $.inArray($("#ddlDecision option:selected").val(), ["13", "14", "15"]) != -1):
|
|
RegistroAutomaticoComentarioDevolucion = true;
|
|
break;
|
|
case (Etapas.FR_Rev_Info_Caso && $.inArray($("#ddlDecision option:selected").val(), ["21", "24"]) != -1):
|
|
RegistroAutomaticoComentarioDevolucion = true;
|
|
break;
|
|
}
|
|
|
|
model = LeerControlesUltimus(model);
|
|
model.Aprobacion = Aprobacion;
|
|
|
|
|
|
|
|
if (Etapas.DE_Inclu_Sol_Desembolso) {
|
|
if (!ValidateReglasDecisionInclusionCaratulaUnica(model, true)) {
|
|
ENDREQUEST();
|
|
return false;
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
Ultimus.AjaxPostData(server + 'api/AnalisisAPI/GuardarAprobacion', model, true, true, function (data) {
|
|
|
|
if (RegistroAutomaticoComentarioDevolucion) {
|
|
|
|
//***********************************************************************************
|
|
//Inicializa y Guarda los comentarios de tipo devolucion de trámite Automaticamente
|
|
//***********************************************************************************
|
|
InicializarBitacoraComentariosInternos("", EnumTipoComentario.ComentarioDevolucionTramite, false, function () { InsertarBitacoraComentariosInternoAutomatico(false, $("#txtComentariosAdicionales").val()) });
|
|
}
|
|
|
|
EnviarIncidente(false, true);
|
|
|
|
if (End == undefined || End == null || End == false)
|
|
ENDREQUEST();
|
|
|
|
|
|
if (Etapas.FR_Rev_Info_Caso && $.inArray($("#ddlDecision option:selected").val(), ["24", "21"]) != -1) {
|
|
GuardarBitacoraComentariosGeneral($("#txtComentariosAdicionales").val(), true);
|
|
}
|
|
});
|
|
|
|
}
|
|
|
|
this.ToggleComentarios = function () {
|
|
|
|
if ($.inArray($("#ddlDecision option:selected").val(), ["13", "14", "15", "24", "21", "45","49"]) != -1)
|
|
$("#txtComentariosAdicionales").required();
|
|
else
|
|
$("#txtComentariosAdicionales").noRequired();
|
|
|
|
$("#FormControlAprobaciones").validateElement("#txtComentariosAdicionales");
|
|
}
|
|
|
|
this.DataCatalogo = function (catalogo, data) {
|
|
model.Analista = data;
|
|
}
|
|
|
|
this.ToggleRechazo = function () {
|
|
|
|
if (Etapas.AN_Preanalisis && $.inArray($("#ddlDecision option:selected").val(), ["17"]) != -1) {
|
|
$("#ddlAccionRechazo").required();
|
|
$("#ddlAccionRechazo").enable();
|
|
}
|
|
else {
|
|
$("#ddlAccionRechazo").noRequired();
|
|
$("#ddlAccionRechazo").disable();
|
|
$("#ddlAccionRechazo option[value='']").attr("selected", "selected");
|
|
}
|
|
|
|
$("#FormControlAprobaciones").validateElement("#ddlAccionRechazo");
|
|
}
|
|
|
|
this.toggleAnalista = function () {
|
|
|
|
$("#btnListaEjecutivos").unbind('click');
|
|
$("#btnListaEjecutivos").click(function () {
|
|
SelectedCatalog = "ListaEjecutivos";
|
|
|
|
var CodDecision = $("#ddlDecision option:selected").val();
|
|
|
|
if ($.inArray(CodDecision, ["12", "11"]) != -1) {
|
|
$("#btnListaEjecutivos").attr("direccion_api", "api/AnalisisAPI/ObtenerAnalista");
|
|
Ultimus.CargarDataCatalogo(null, null, CodDecision);
|
|
}
|
|
else {
|
|
$("#btnListaEjecutivos").attr("direccion_api", "api/GlobalAPI/ObtenerEjecutivo");
|
|
Ultimus.CargarDataCatalogo(null, null);
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
this.habilitaAnalistaPreanlisis = function () {
|
|
var CodDecision = $("#ddlDecision option:selected").val();
|
|
if (Etapas.AN_Rev_Doc_Clasificar) {
|
|
if (CodDecision == "11") {
|
|
$("#divListaEjecutivos").Catalogo('disable', false);
|
|
$("#divListaEjecutivos").Catalogo('required', true);
|
|
}
|
|
else {
|
|
$("#divListaEjecutivos").Catalogo('disable');
|
|
$("#divListaEjecutivos").Catalogo('required', false);
|
|
}
|
|
}
|
|
$("#FormControlAprobaciones").valid();
|
|
}
|
|
|
|
this.CargaListaDocumentos = function () {
|
|
var lista = null;
|
|
lista = model.ListaDocumentosInforme;
|
|
$("#ListaDocumentosInforme").Grid("RenderGrid", $.extend(true, new Array(), lista));
|
|
}
|
|
|
|
this.AdjuntarDocumento = function (IdTipoDocumento) {
|
|
|
|
var DatosDoc = $.grep(model.ListaDocumentosInforme, function (item, id) {
|
|
return item.IdTipoDocumento == IdTipoDocumento;
|
|
})[0];
|
|
|
|
CargarAdjuntos(DatosDoc.CodDocumentoAdjunto, "DocsInformeAnalisis", function (resp) {
|
|
|
|
$.each(model.ListaDocumentosInforme, function (id, item) {
|
|
|
|
if (item.IdTipoDocumento == IdTipoDocumento)
|
|
item.CodDocumentoAdjunto = resp.CodDocumento;
|
|
|
|
model.ListaDocumentosInforme[id] = item;
|
|
});
|
|
|
|
CargaListaDocumentos();
|
|
|
|
}, null, null, DatosDoc.TipoDocumento.IdCategoriaTipoDocumento);
|
|
|
|
$("#ParametroExtraAdjunto").val(JSON.stringify(DatosDoc));
|
|
|
|
}
|
|
|
|
this.CambioPantallaMenuCallBack = function () {
|
|
|
|
var FunctionCallBack = null;
|
|
|
|
if (Etapas.AN_Preanalisis) {
|
|
FunctionCallBack = function () { GuardarFormularioAnalisis(false, true); };
|
|
}
|
|
|
|
GridExpediente_Guardar(FunctionCallBack, null, null, null, false);
|
|
|
|
|
|
return true;
|
|
}
|
|
|
|
this.ValidateReglasDecisionInclusionCaratulaUnica = function (model, End) {
|
|
|
|
var resp = false;
|
|
|
|
try {
|
|
|
|
var DTO = JSON.stringify(model);
|
|
|
|
$.ajax({
|
|
type: 'POST',
|
|
url: server + 'api/DesembolsoAPI/ValidarReglasDecisionInclusionCaratulaUnica',
|
|
cache: false,
|
|
data: DTO,
|
|
contentType: 'application/json; charset=utf-8',
|
|
dataType: 'json',
|
|
async: false,
|
|
success: function (data) {
|
|
|
|
|
|
if (data != null) {
|
|
switch (data.CodigoRespuesta) {
|
|
case "EXITOSO":
|
|
resp = true;
|
|
break;
|
|
case "ADVERTENCIA":
|
|
resp = false;
|
|
toastr.warning(data.DescripcionRespuesta);
|
|
break;
|
|
case "ERROR":
|
|
resp = false;
|
|
toastr.error(data.DescripcionRespuesta);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}).fail(function (jqxhr, textStatus, error) {
|
|
if (typeof AjaxFailEvent !== 'undefined' && $.isFunction(AjaxFailEvent) && !AjaxFailEvent(jqxhr, textStatus, error))
|
|
return;
|
|
toastr.error("Ha ocurrido un error inesperado. Vuelva a intentarlo mas tarde");
|
|
|
|
ENDREQUEST();
|
|
}).then(function (value) {
|
|
if (End == undefined || End == null || End == false)
|
|
ENDREQUEST();
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
|
catch (e) {
|
|
resp = false;
|
|
}
|
|
|
|
return resp;
|
|
}
|
|
|
|
this.ConsultaDocumentosAdiconales = function () {
|
|
|
|
var datos = {
|
|
Solicitud: { IdSolicitud: $("#hidden_co_solicitud").val() }
|
|
}
|
|
|
|
datos = LeerControlesUltimus(datos);
|
|
|
|
Ultimus.AjaxPostData(server + "api/AnalisisAPI/ObtenerInfoDocumentosAdicionales", datos, false, false, function (data) {
|
|
|
|
if (data != null) {
|
|
DocumentosAdicionalesEntregados = data.DocumentosAdicionalesEntregados == null ? true : data.DocumentosAdicionalesEntregados;
|
|
|
|
} else {
|
|
toastr.error("Ha ocurrido un error inesperado. Vuelva a intentarlo mas tarde");
|
|
}
|
|
});
|
|
} |