Commit b64d2556 by Billy Larru

cambiar estado de registro en crear rol de policias

parent ed6ef304
...@@ -48,19 +48,22 @@ function listarRolesPolicias(objParams = {}) { ...@@ -48,19 +48,22 @@ function listarRolesPolicias(objParams = {}) {
data: `estado`, data: `estado`,
className: 'text-center', className: 'text-center',
render: (data) => { render: (data) => {
let editar = "";
let eliminar = "";
let acciones = "";
console.log(data); console.log(data);
if (Object.is(data, 1)) { if (data === 1) {
return ` <span data-placement="left" title="Ver detalle" data-toggle="tooltip" style="cursor: pointer"> <i class='ver-detalle icon-calendar2 text-primary-700'></i>&nbsp;&nbsp; </span> editar = `<span data-placement="left" title="Ver detalle" data-toggle="tooltip" style="cursor: pointer"> <i class='ver-detalle icon-calendar2 text-primary-700'></i>&nbsp;&nbsp; </span>`;
<span data-toggle="tooltip" data-placement="left" title="Desactivar Rol" style="cursor: pointer"> <i class='eliminar icon-cancel-circle2 text-danger-700'></i>&nbsp;&nbsp; </span> eliminar = `<span data-placement="left" title="Desactivar Rol" style="cursor: pointer"> <i class="eliminar fa fa-power-off text-danger-700"></i>&nbsp;&nbsp; </span>`;
`;
} else { } else {
return null; eliminar = `<span data-placement="left" title="Eliminar" style="cursor: pointer"> <i class="eliminar fa fa-power-off text-success-700"></i>&nbsp;&nbsp; </span>`;
} }
acciones = editar + eliminar;
return acciones;
} }
} }
]; ];
let columnDefs = [ let columnDefs = [
{orderable: false, width: '1%', targets: 0, className: "text-center"}, {orderable: false, width: '1%', targets: 0, className: "text-center"},
{orderable: false, width: '8%', targets: 1}, {orderable: false, width: '8%', targets: 1},
...@@ -71,10 +74,8 @@ function listarRolesPolicias(objParams = {}) { ...@@ -71,10 +74,8 @@ function listarRolesPolicias(objParams = {}) {
{orderable: false, width: '8%', targets: 6, className: "text-center"}, {orderable: false, width: '8%', targets: 6, className: "text-center"},
{orderable: false, width: '8%', targets: 7, className: "text-center"} {orderable: false, width: '8%', targets: 7, className: "text-center"}
]; ];
let wrapsNameDatatable = `divRoles`; let wrapsNameDatatable = `divRoles`;
let classNameForDatatable = `display table table-bordered`; let classNameForDatatable = `display table table-bordered`;
makeDatatable(wrapsNameDatatable, makeDatatable(wrapsNameDatatable,
{ {
data: response.data, data: response.data,
...@@ -86,7 +87,6 @@ function listarRolesPolicias(objParams = {}) { ...@@ -86,7 +87,6 @@ function listarRolesPolicias(objParams = {}) {
nodes.container.on("click", ".ver-detalle", function () { nodes.container.on("click", ".ver-detalle", function () {
let data = nodes.datatable.DataTable().row($(this).parents("tr")).data(); let data = nodes.datatable.DataTable().row($(this).parents("tr")).data();
console.log(data); console.log(data);
ajaxModal.get("policias/mantenimientoRol/detalleRol.jspf").then((response) => { ajaxModal.get("policias/mantenimientoRol/detalleRol.jspf").then((response) => {
debugger debugger
swal({ swal({
...@@ -110,40 +110,51 @@ function listarRolesPolicias(objParams = {}) { ...@@ -110,40 +110,51 @@ function listarRolesPolicias(objParams = {}) {
$("#listaDias").html(htmlList); $("#listaDias").html(htmlList);
} }
}); });
}); });
}); });
nodes.container.on("click", ".eliminar", function () { nodes.container.on("click", ".eliminar", function () {
let data = nodes.datatable.DataTable().row($(this).parents("tr")).data(); let data = nodes.datatable.DataTable().row($(this).parents("tr")).data();
mostrarModalEliminacion(data); mostrarModalEliminacion(data);
}); });
}); });
}); });
} }
const mostrarModalEliminacion = (data) => { const mostrarModalEliminacion = (data) => {
let {id, estado} = data; let {id, estado} = data;
estado = 0; let titulo = "";
let textoConfirmacion = ""
let tituloOperacion = "";
if (estado) {
titulo = 'Está seguro de eliminar el rol?';
textoConfirmacion = 'Sí, eliminar!';
tituloOperacion = '¡Eliminado exitosamente!';
estado = 0;
} else {
titulo = 'Está seguro de activar?';
textoConfirmacion = 'Sí, activar!';
tituloOperacion = '¡Activado exitosamente!';
estado = 1;
}
swal({ swal({
title: 'Está seguro de eliminar el rol?', title: titulo,
text: "", text: "",
type: 'warning', type: 'warning',
showCancelButton: true, showCancelButton: true,
confirmButtonColor: '#3085d6', confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33', cancelButtonColor: '#d33',
confirmButtonText: 'Sí, eliminar!' confirmButtonText: textoConfirmacion
}).then((result) => { }).then((result) => {
if (result.value) { if (result.value) {
ajaxWebService.patch(`${URI_ROL_POLICIA}/${id}`, {estado}).then((response) => { ajaxWebService.patch(`${URI_ROL_POLICIA}/${id}`, {estado}).then((response) => {
if (response.status) { if (response.status) {
swal({ swal({
type: 'success', type: 'success',
title: '¡Eliminado correctamente!', title: tituloOperacion,
showConfirmButton: false, showConfirmButton: false,
timer: 1500 timer: 1500
}); });
...@@ -152,14 +163,7 @@ const mostrarModalEliminacion = (data) => { ...@@ -152,14 +163,7 @@ const mostrarModalEliminacion = (data) => {
}); });
} }
}); });
}; };
const listarTipoRoles = () => { const listarTipoRoles = () => {
ajaxWebService.get(URI_TIPOROL_POLICIA).then((response) => { ajaxWebService.get(URI_TIPOROL_POLICIA).then((response) => {
let tipoRoles = response.data; let tipoRoles = response.data;
...@@ -210,7 +214,6 @@ function modificarServicio() { ...@@ -210,7 +214,6 @@ function modificarServicio() {
$("#modal-header").addClass('bg-jade'); $("#modal-header").addClass('bg-jade');
$("#botones-editar").removeClass('hidden'); $("#botones-editar").removeClass('hidden');
$("#btnCerrar").addClass("hidden"); $("#btnCerrar").addClass("hidden");
animar(); animar();
// e.preventDefault(); // e.preventDefault();
} }
...@@ -232,13 +235,10 @@ function registrarRolPolicia() { ...@@ -232,13 +235,10 @@ function registrarRolPolicia() {
let policia_dni = $("#cboPolicias option:selected").attr("documento_identidad"); let policia_dni = $("#cboPolicias option:selected").attr("documento_identidad");
let hora_entrada = $("#cboTipoRol option:selected").data('hora-entrada'); let hora_entrada = $("#cboTipoRol option:selected").data('hora-entrada');
let hora_salida = $("#cboTipoRol option:selected").data('hora-salida'); let hora_salida = $("#cboTipoRol option:selected").data('hora-salida');
debugger debugger
let fechas = generarFechas(fecha_inicio, fecha_fin); let fechas = generarFechas(fecha_inicio, fecha_fin);
let detalles_rol = []; let detalles_rol = [];
let numero = 1; let numero = 1;
fechas fechas
.map((f) => { .map((f) => {
let obj = { let obj = {
...@@ -258,7 +258,6 @@ function registrarRolPolicia() { ...@@ -258,7 +258,6 @@ function registrarRolPolicia() {
}; };
detalles_rol.push(detalle_rol); detalles_rol.push(detalle_rol);
}); });
let params = { let params = {
numeroFila: policia_id, numeroFila: policia_id,
policia_id, policia_id,
...@@ -275,7 +274,6 @@ function registrarRolPolicia() { ...@@ -275,7 +274,6 @@ function registrarRolPolicia() {
detalles_rol, detalles_rol,
estado estado
}; };
ajaxWebService.post(URI_ROL_POLICIA, params) ajaxWebService.post(URI_ROL_POLICIA, params)
.then((response) => { .then((response) => {
debugger; debugger;
...@@ -312,7 +310,6 @@ function cancelar() { ...@@ -312,7 +310,6 @@ function cancelar() {
function animar() { function animar() {
let animation = `fadeIn`; let animation = `fadeIn`;
$("#modal_body_tombo2").addClass(`animated ${animation}`).one("webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend", function () { $("#modal_body_tombo2").addClass(`animated ${animation}`).one("webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend", function () {
$(this).removeClass(`animated ${animation}`); $(this).removeClass(`animated ${animation}`);
}); });
...@@ -345,23 +342,16 @@ function mostrarModalNuevoRol() { ...@@ -345,23 +342,16 @@ function mostrarModalNuevoRol() {
listarFrecuenciaRol(); listarFrecuenciaRol();
listarSedes("#cboSedesModal"); listarSedes("#cboSedesModal");
listarPolicias("#cboPolicias"); listarPolicias("#cboPolicias");
$('.selectpicker').selectpicker({ $('.selectpicker').selectpicker({
style: 'btn-info', style: 'btn-info',
size: 4 size: 4
}); });
$('.select-search').select2(); $('.select-search').select2();
$(".btn.dropdown-toggle.bs-placeholder").removeClass("btn-info"); $(".btn.dropdown-toggle.bs-placeholder").removeClass("btn-info");
$(".btn.dropdown-toggle.bs-placeholder").css({ $(".btn.dropdown-toggle.bs-placeholder").css({
border: "1px solid #ddd", border: "1px solid #ddd",
backgroundColor: "#fff" backgroundColor: "#fff"
}); });
$("#dpRangoFechas").daterangepicker({ $("#dpRangoFechas").daterangepicker({
"autoApply": true, "autoApply": true,
"locale": { "locale": {
...@@ -404,8 +394,6 @@ function mostrarModalNuevoRol() { ...@@ -404,8 +394,6 @@ function mostrarModalNuevoRol() {
// console.log('New date range selected: ' + start.format('YYYY-MM-DD') + ' to ' + end.format('YYYY-MM-DD') + ' (predefined range: ' + label + ')'); // console.log('New date range selected: ' + start.format('YYYY-MM-DD') + ' to ' + end.format('YYYY-MM-DD') + ' (predefined range: ' + label + ')');
}); });
$("#dpRangoFechas").datepicker('setDate', 'now'); $("#dpRangoFechas").datepicker('setDate', 'now');
defaultConfigDatePicker(); defaultConfigDatePicker();
} }
}).then((result) => { }).then((result) => {
...@@ -422,17 +410,13 @@ function buscarRoles() { ...@@ -422,17 +410,13 @@ function buscarRoles() {
let sede_id = $("#cboSedesFiltro").val(); let sede_id = $("#cboSedesFiltro").val();
let fecha_inicio = $("#dpFechaInicio").val(); let fecha_inicio = $("#dpFechaInicio").val();
let fecha_fin = $("#dpFechaFin").val(); let fecha_fin = $("#dpFechaFin").val();
let rangoFechas = generarFechas(fecha_inicio, fecha_fin); let rangoFechas = generarFechas(fecha_inicio, fecha_fin);
let params = cleanQueryParams({ let params = cleanQueryParams({
policia_id, policia_id,
sede_id, sede_id,
fecha_inicio: rangoFechas fecha_inicio: rangoFechas
}); });
console.log(params); console.log(params);
listarRolesPolicias({params}); listarRolesPolicias({params});
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment