This commit is contained in:
mumana 2018-06-08 20:33:14 +00:00
parent 34ff497ffc
commit 3b50fea148
2 changed files with 161 additions and 144 deletions

View file

@ -1,7 +1,7 @@
//$("#formCatalogo").EnableValidationToolTip();
var DataCatalogo;
var id_column = 1;
var Item = {};
var model = {};
//#region READY
@ -47,74 +47,8 @@ this.getDataModel = function () {
this.obtenerItems = function () {
var uri = CatalogosWCF + '/api/ObtenerEmisoresPN';
var DTO = JSON.stringify(Item);
STARTREQUEST();
//$.getJSON(uri).done(function (data) {
$.ajax({
type: 'POST',
url: uri,
cache: false,
data: DTO,
contentType: 'application/json; charset=utf-8',
dataType: 'json',
success: function (data) {
$('#TableItems').TableInit(0, false, true, true, false, null, null);
var TableItems = $('#TableItems').DataTable();
var lista = data.d.ListaEmisores;
$.each(lista, function (key, item) {
var option = $("#ucItemsCatalogo").html();
option = replaceAll("[$CodItem]", item.id_emisor, option);
var stateIcon = $("#ucItemsIcon").html();
if (item.Estado == false) {
stateIcon = replaceAll("[$icon]", "fa-check-circle", stateIcon);
stateIcon = replaceAll("[$state_color]", "muted", stateIcon);
option = replaceAll("[$opcion]", "Habilitar", option);
option = replaceAll("[$icon]", "fa-check", option);
option = replaceAll("[$value]", "1", option);
}
else {
stateIcon = replaceAll("[$icon]", "fa-check-circle", stateIcon);
stateIcon = replaceAll("[$state_color]", "success", stateIcon);
option = replaceAll("[$opcion]", "Deshabilitar", option);
option = replaceAll("[$icon]", "fa-times", option);
option = replaceAll("[$value]", "0", option);
}
TableItems.row.add([stateIcon,
item.id_emisor,
item.titulo,
option]).draw();
});
ENDREQUEST();
}
}).fail(function (jqxhr, textStatus, error) {
toastr.error("Ha ocurrido un error inesperado. Vuela a intentarlo mas tarde");
console.log("Request Failed: " + textStatus + ', ' + error);
ENDREQUEST();
}).then(function (value) {
ENDREQUEST();
});
AjaxPostData(uri, model, true, true, CargarEmisores, null, null);
}
@ -163,14 +97,14 @@ this.toggleEnabledItem = function (id, value) {
TableItems = $('#TableItems').DataTable();
Item = {
model = {
IdEmisor: id,
Estado: value,
}
var uri = CatalogosWCF + '/api/ModificarEstadoEmisorPN';
var DTO = JSON.stringify(Item);
var DTO = JSON.stringify(model);
$.ajax({
type: 'POST',
@ -223,13 +157,13 @@ this.ActualizarItem = function () {
TableItems = $('#TableItems').DataTable();
Item = {
IdTipoEmisor: $('#hiddenId').val(),
Descripcion: $('#txtDescripcion').val(),
model = {
id_emisor: $('#hiddenId').val(),
titulo: $('#txtDescripcion').val(),
}
var uri = CatalogosWCF + '/api/ModificarEmisoresPN';
var DTO = JSON.stringify(Item);
var DTO = JSON.stringify(model);
$.ajax({
type: 'POST',
@ -337,4 +271,44 @@ this.limpiar = function () {
$('#lbTituloAccion').append('Ingresar Nuevo Emisor PN');
}
this.CargarEmisores = function(data){
$('#TableItems').TableInit(0, false, true, true, false, null, null);
var TableItems = $('#TableItems').DataTable();
var lista = data.d.ListaEmisores;
$.each(lista, function (key, item) {
var option = $("#ucItemsCatalogo").html();
option = replaceAll("[$CodItem]", item.id_emisor, option);
var stateIcon = $("#ucItemsIcon").html();
if (item.Estado == false) {
stateIcon = replaceAll("[$icon]", "fa-check-circle", stateIcon);
stateIcon = replaceAll("[$state_color]", "muted", stateIcon);
option = replaceAll("[$opcion]", "Habilitar", option);
option = replaceAll("[$icon]", "fa-check", option);
option = replaceAll("[$value]", "1", option);
}
else {
stateIcon = replaceAll("[$icon]", "fa-check-circle", stateIcon);
stateIcon = replaceAll("[$state_color]", "success", stateIcon);
option = replaceAll("[$opcion]", "Deshabilitar", option);
option = replaceAll("[$icon]", "fa-times", option);
option = replaceAll("[$value]", "0", option);
}
TableItems.row.add([stateIcon,
item.id_emisor,
item.titulo,
option]).draw();
});
}

View file

@ -1,74 +1,8 @@
var CatalogosWCF = $("#hiddenSinortCatalogosWCF").val();
var SinortWCF = $("#hiddenSinortWCF").val();
var server = "http://" + location.host + "/AYA.SlnSynor.WCF/";
var TipoRespuesta = { EXITOSO: "1", FALLIDO: "0" };
var LoadMessageThreadCounter = 0;
function Mensajes(mensaje) {
if (mensaje.CodigoRespuesta === "1") {
toastr.options = {
"closeButton": true,
"debug": false,
"newestOnTop": false,
"progressBar": false,
"positionClass": "toast-bottom-full-width",
"preventDuplicates": true,
"onclick": null,
"showDuration": "300",
"hideDuration": "1000",
"timeOut": "5000",
"extendedTimeOut": "1000",
"showEasing": "swing",
"hideEasing": "linear",
"showMethod": "fadeIn",
"hideMethod": "fadeOut"
};
toastr["success"]("Operación procesada exitosamente", "SINORT");
}
if (mensaje.CodigoRespuesta === "0") {
toastr.options = {
"closeButton": true,
"debug": false,
"newestOnTop": false,
"progressBar": false,
"positionClass": "toast-bottom-full-width",
"preventDuplicates": true,
"onclick": null,
"showDuration": "300",
"hideDuration": "1000",
"timeOut": "5000",
"extendedTimeOut": "1000",
"showEasing": "swing",
"hideEasing": "linear",
"showMethod": "fadeIn",
"hideMethod": "fadeOut"
};
toastr["warning"]("Error al procesar la operación", "SINORT");
}
toastr.options = {
"closeButton": true,
"debug": false,
"newestOnTop": false,
"progressBar": false,
"positionClass": "toast-bottom-full-width",
"preventDuplicates": true,
"onclick": null,
"showDuration": "300",
"hideDuration": "1000",
"timeOut": "5000",
"extendedTimeOut": "1000",
"showEasing": "swing",
"hideEasing": "linear",
"showMethod": "fadeIn",
"hideMethod": "fadeOut"
};
toastr["error"](mensaje.DescripcionRespuesta, "SINORT");
}
function STARTREQUEST(Message) {
if (IsNullOrEmpty(Message)) {
@ -252,13 +186,124 @@ $.fn.EnableValidationToolTip = function () {
};
IsNullOrEmpty = function (value) {
//FRAMEWORK
this.LoadToastContainer = function () {
if ($('#toast-container').length > 0) {
var n = $('<div />').appendTo('body');
n.attr('id', 'toast-container');
n.attr('class', 'toast-top-right')
}
};
this.LoadMessage = function (n) {
var r,
t,
i;
n == null && (n = 'Cargando Datos, Espere por favor!');
$('#toast-container').length > 0 && (r = $('<div />').appendTo('body'), r.attr('id', 'toast-container'), r.attr('class', 'toast-top-right'));
$('#toast-container').empty();
t = '';
t += '<div id="loadingGif" class="toast toast-default" style="font-size:14px;">';
t += '<table>';
t += '<tr>';
t += "<td><img src=\"/AYA.SlnSinort/dist/img/ajax-loader.gif\" alt=\"loading\" height=\"50\" width=\"50\"></td>";
t += '<td>&nbsp;&nbsp;</td>';
t += '<td>';
t += '<div class="toast-title">' + n + '</div>';
t += '</td>';
t += '</tr>';
t += '</table>';
t += '</div>';
$('#toast-container').append(t);
};
this.ENDREQUEST = function () {
LoadMessageThreadCounter > 0 || (LoadMessageThreadCounter = 0, $('#loadingGif').remove())
};
this.HideLoadingScreen = function () {
EnabledLoadingScreen = !1;
FirstEnabledLoadingScreen = !1;
$('#divloadingScreen').remove()
};
this.IsNullOrEmpty = function (n) {
return n === undefined || n === null || $.trim(n) == '' ? !0 : !1
};
this.lockViewContent = function () {
var n = $('#hiddenTaskStatus').val();
n != 1 && (FormReadOnly(), $('button').attr('disabled', !0), $('button').each(function () {
$(this).attr('id') != null && ($(this).attr('id').toLowerCase().indexOf('imprim') != -1 && $(this).attr('disabled', !1), ($(this).attr('id').toLowerCase().indexOf('envia') != -1 || $(this).attr('id').toLowerCase().indexOf('send') != -1) && $(this).hide())
}))
};
this.FormDisable = function () {
$('input,select').removeAttr('disabled');
$('input,select').addClass('is-disabled');
$('input,select').focus(function () {
this.blur()
});
$('select').dblclick(function () {
alert('No puede seleccionar esto.')
});
$('input').datepicker('destroy');
$('input:radio').attr('disabled', !0);
$('input:checkbox').attr('disabled', !0);
$('input,select').removeAttr('required', !0)
};
this.LettersNumbersOnly = function (n) {
n = n ? n : event;
var t = n.charCode ? n.charCode : n.keyCode ? n.keyCode : n.which ? n.which : 0;
return t >= 48 && t <= 57 || t >= 65 && t <= 90 || t >= 97 && t <= 122 || t >= 192 && t <= 255 || t == 8 || t == 32 || t == 180 || t == 46 || t == 44 || t == 45 || t == 59 ? !0 : !1
};
this.LettersNumbersAndGuionOnly = function (n) {
n = n ? n : event;
var t = n.charCode ? n.charCode : n.keyCode ? n.keyCode : n.which ? n.which : 0;
return t >= 48 && t <= 57 || t >= 65 && t <= 90 || t >= 97 && t <= 122 || t == 8 || t == 32 || t == 45 ? !0 : !1
};
this.LettersNumbersAndDotOnly = function (n) {
n = n ? n : event;
var t = n.charCode ? n.charCode : n.keyCode ? n.keyCode : n.which ? n.which : 0;
return t >= 48 && t <= 57 || t >= 65 && t <= 90 || t >= 97 && t <= 122 || t == 8 || t == 32 || t == 46 ? !0 : !1
};
this.LettersOnly = function (n) {
n = n ? n : event;
var t = n.charCode ? n.charCode : n.keyCode ? n.keyCode : n.which ? n.which : 0;
return t > 32 && (t < 65 || t > 90) && (t < 97 || t > 122) ? !1 : !0
};
this.VerifyPhoneNumber = function (n) {
var i,
t,
r;
$('#' + n).val() != '' && (i = $('#' + n).val().match(/\b\d{3}[-]\d{4}\b/) ? !0 : !1, i == !1 && (t = $('#' + n).val(), t.indexOf('-') != -1 && (t = t.replace('-', '')), $('#hiddenResidente').val() == 'false' ? t.length <= 11 || (toastr.warning('Verifique haya introducido hasta 11 números', 'Ingresar Datos Requeridos'), $('#' + n).val(''), $('#' + n).focus()) : t.length == 7 ? (r = $('#' + n).val().split(''), (r[0] == 0 || $('#' + n).val() == '1111111') && (toastr.warning('Ingresar un número valido', 'Ingresar Datos Requeridos'), $('#' + n).val(''), $('#' + n).focus())) : (toastr.warning('Verifique haya introducido 7 números', 'Ingresar Datos Requeridos'), $('#' + n).focus())))
};
this.VerifyMobileNumber = function (n) {
var i,
t,
r;
$('#' + n).val() != '' && (i = $('#' + n).val().match(/\b\d{4}[-]\d{4}\b/) ? !0 : !1, i == !1 && (t = $('#' + n).val(), t.indexOf('-') != -1 && (t = t.replace('-', '')), $('#hiddenResidente').val() == 'false' ? t.length <= 11 || (toastr.warning('Verifique haya introducido hasta 11 números', 'Ingresar Datos Requeridos'), $('#' + n).val(''), $('#' + n).focus()) : t.length == 8 ? (r = $('#' + n).val().split(''), r[0] != 6 && (toastr.warning('El número debe iniciar con 6', 'Ingresar Datos Requeridos'), $('#' + n).val(''), $('#' + n).focus())) : (toastr.warning('Verifique haya introducido 8 números', 'Ingresar Datos Requeridos'), $('#' + n).val(''), $('#' + n).focus())))
};
this.OnlyNumbers = function (n) {
var t = n.which ? n.which : n.keyCode;
return t > 31 && (t < 48 || t > 57) ? !1 : !0
};
this.OnlyNumerosyGuiones = function (n) {
var t = n.which ? n.which : n.keyCode;
return t == 45 ? !0 : t > 31 && (t < 48 || t > 57) ? !1 : !0
};
this.OnlyNumbersAndDot = function (n, t) {
var i = n.which ? n.which : n.keyCode,
r,
u;
return i == 46 ? (r = $('#' + t).val(), u = r.indexOf('.') != -1 ? !1 : !0, u) : i > 31 && (i < 48 || i > 57) ? !1 : !0
};
this.replaceAll = function (n, t, i) {
return i.replace(new RegExp(n.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'), 'g'), t)
};
this.IsNullOrEmpty = function (value) {
if (value == null || $.trim(value) == "") return true;
return false;
}
this.AjaxPostData = function (n, t, i, r, u, f, e) {
var o = null;
return LoadMessage(),
@ -281,7 +326,6 @@ this.AjaxPostData = function (n, t, i, r, u, f, e) {
}),
o
};
this.AjaxResponse = function (n, t, i, r, u) {
LoadMessageThreadCounter--;
u = IsNullOrEmpty(u) ? 'Acción completada con exito.' : u;
@ -293,7 +337,6 @@ this.AjaxResponse = function (n, t, i, r, u) {
return i != null && f ? i(n) : ENDREQUEST(),
n
};
this.AjaxGetData = function (n, t, i, r, u, f) {
var e = null;
return LoadMessage(),