Stable without período in autidoría
This commit is contained in:
103
ts/auditoría.ts
103
ts/auditoría.ts
@@ -70,6 +70,10 @@ const store = reactive({
|
||||
comentario: '',
|
||||
clase_vista: null,
|
||||
empty: '',
|
||||
page: 1,
|
||||
maxPages: 10,
|
||||
perPage: 10,
|
||||
modal_state: "Cargando datos...",
|
||||
},
|
||||
facultades: {
|
||||
data: [] as Facultad[],
|
||||
@@ -85,6 +89,7 @@ const store = reactive({
|
||||
fecha_inicio: null,
|
||||
fecha_fin: null,
|
||||
profesor: null,
|
||||
periodo_id: null,
|
||||
bloque_horario: null,
|
||||
estados: [],
|
||||
|
||||
@@ -94,7 +99,7 @@ const store = reactive({
|
||||
store.filters.fecha_inicio = store.filters.fecha_fin = store.filters.fecha = null
|
||||
|
||||
$("#fecha, #fecha_inicio, #fecha_fin").datepicker({
|
||||
minDate: -3,
|
||||
minDate: -15,
|
||||
maxDate: new Date(),
|
||||
dateFormat: "yy-mm-dd",
|
||||
showAnim: "slide",
|
||||
@@ -150,7 +155,12 @@ const store = reactive({
|
||||
toggle(arr: any, element: any) {
|
||||
const newArray = arr.includes(element) ? arr.filter((item: any) => item !== element) : [...arr, element]
|
||||
// if all are selected, then unselect all
|
||||
if (newArray.length === this.estados.data.length) return []
|
||||
if (newArray.length === this.estados.data.length) {
|
||||
setTimeout(() => {
|
||||
document.querySelectorAll('#dlAsistencia>ul>li.selected')!.forEach(element => element.classList.remove('selected'));
|
||||
}, 100)
|
||||
return []
|
||||
}
|
||||
return newArray
|
||||
},
|
||||
})
|
||||
@@ -166,7 +176,11 @@ type Profesor = {
|
||||
profesor_clave: string;
|
||||
profesor_grado: string;
|
||||
}
|
||||
|
||||
$('div.modal#cargando').modal({
|
||||
backdrop: 'static',
|
||||
keyboard: false,
|
||||
show: false,
|
||||
})
|
||||
createApp({
|
||||
store,
|
||||
get clase_vista() {
|
||||
@@ -175,9 +189,17 @@ createApp({
|
||||
registros: {
|
||||
data: [] as Registro[],
|
||||
async fetch() {
|
||||
// if (!store.filters.facultad_id || !store.filters.periodo_id) return
|
||||
this.loading = true
|
||||
this.data = [] as Registro[]
|
||||
const res = await fetch('action/action_auditoria.php')
|
||||
const params = {
|
||||
facultad_id: 19,
|
||||
periodo_id: 2,
|
||||
}
|
||||
const paramsUrl = new URLSearchParams(params as any).toString()
|
||||
const res = await fetch(`action/action_auditoria.php?${paramsUrl}`, {
|
||||
method: 'GET',
|
||||
})
|
||||
this.data = await res.json()
|
||||
this.loading = false
|
||||
},
|
||||
@@ -203,9 +225,15 @@ createApp({
|
||||
|
||||
*/
|
||||
const filters = Object.keys(store.filters).filter((filtro) => store.filters[filtro] || store.filters[filtro]?.length > 0)
|
||||
/*
|
||||
store.current
|
||||
page: 1,
|
||||
maxPages: 10,
|
||||
perPage: 10,
|
||||
*/
|
||||
return this.data.filter((registro: Registro) => {
|
||||
return filters.every((filtro) => {
|
||||
|
||||
|
||||
switch (filtro) {
|
||||
case 'fecha':
|
||||
return registro.registro_fecha_ideal === store.filters[filtro];
|
||||
@@ -218,7 +246,7 @@ createApp({
|
||||
if (/^\([^)]+\)\s[\s\S]+$/.test(textoFiltro)) {
|
||||
const clave = registro.profesor_clave.toLowerCase();
|
||||
const filtroClave = textoFiltro.match(/\((.*?)\)/)?.[1];
|
||||
console.log(clave, filtroClave);
|
||||
// console.log(clave, filtroClave);
|
||||
return clave.includes(filtroClave);
|
||||
} else {
|
||||
const nombre = registro.profesor_nombre.toLowerCase();
|
||||
@@ -238,40 +266,67 @@ createApp({
|
||||
})
|
||||
})
|
||||
},
|
||||
|
||||
async descargar() {
|
||||
store.current.modal_state = 'Generando reporte en Excel...'
|
||||
$('div.modal#cargando').modal('show');
|
||||
this.loading = true;
|
||||
if (this.relevant.length === 0) return;
|
||||
const res = await fetch('export/supervisor_excel.php', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify(this.relevant)
|
||||
});
|
||||
const blob = await res.blob();
|
||||
(window as any).saveAs(blob, `auditoria_${new Date().toISOString().slice(0, 10)}.xlsx`);
|
||||
try {
|
||||
const res = await fetch('export/supervisor_excel.php', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify(this.relevant)
|
||||
});
|
||||
const blob = await res.blob();
|
||||
(window as any).saveAs(blob, `auditoria_${new Date().toISOString().slice(0, 10)}.xlsx`);
|
||||
|
||||
} catch (error) {
|
||||
if (error.response && error.response.status === 413) {
|
||||
alert('Your request is too large! Please reduce the data size and try again.');
|
||||
} else {
|
||||
alert('An error occurred: ' + error.message);
|
||||
}
|
||||
}
|
||||
finally {
|
||||
$('#cargando').modal('hide');
|
||||
this.loading = false;
|
||||
}
|
||||
},
|
||||
loading: false,
|
||||
get pages() {
|
||||
return Math.ceil(this.relevant.length / store.current.perPage)
|
||||
}
|
||||
},
|
||||
get profesores() {
|
||||
return this.registros.data.map((registro: Registro) => (
|
||||
{
|
||||
return this.registros.data
|
||||
.map((registro: Registro) => ({
|
||||
profesor_id: registro.profesor_id,
|
||||
profesor_nombre: registro.profesor_nombre,
|
||||
profesor_correo: registro.profesor_correo,
|
||||
profesor_clave: registro.profesor_clave,
|
||||
profesor_grado: registro.profesor_grado,
|
||||
}
|
||||
)).sort((a: Profesor, b: Profesor) =>
|
||||
a.profesor_nombre.localeCompare(b.profesor_nombre)
|
||||
)
|
||||
}))
|
||||
.reduce((acc: Profesor[], current: Profesor) => {
|
||||
if (!acc.some(item => item.profesor_id === current.profesor_id)) {
|
||||
acc.push(current);
|
||||
}
|
||||
return acc;
|
||||
}, [])
|
||||
.sort((a: Profesor, b: Profesor) =>
|
||||
a.profesor_nombre.localeCompare(b.profesor_nombre)
|
||||
);
|
||||
|
||||
},
|
||||
async mounted() {
|
||||
$('div.modal#cargando').modal('show');
|
||||
|
||||
await this.registros.fetch()
|
||||
await store.facultades.fetch()
|
||||
await store.estados.fetch()
|
||||
await store.bloques_horario.fetch()
|
||||
|
||||
store.filters.bloque_horario = store.bloques_horario.data.find((bloque: Bloque_Horario) => bloque.selected)?.id
|
||||
store.filters.switchFechas()
|
||||
$('div.modal#cargando').modal('hide');
|
||||
}
|
||||
}).mount('#app')
|
||||
|
||||
Reference in New Issue
Block a user