forked from verdnatura/salix-front
feat: refreshInterval
This commit is contained in:
parent
a6ec40beb4
commit
104ea5b8e5
|
@ -1,5 +1,5 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, computed, onMounted, reactive } from 'vue';
|
import { ref, computed, onMounted, reactive, watch } from 'vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import { useRouter } from 'vue-router';
|
import { useRouter } from 'vue-router';
|
||||||
|
|
||||||
|
@ -19,9 +19,9 @@ import VnInputDate from 'src/components/common/VnInputDate.vue';
|
||||||
import { useSummaryDialog } from 'src/composables/useSummaryDialog';
|
import { useSummaryDialog } from 'src/composables/useSummaryDialog';
|
||||||
import { toDateFormat, toTimeFormat } from 'src/filters/date.js';
|
import { toDateFormat, toTimeFormat } from 'src/filters/date.js';
|
||||||
import { toCurrency } from 'src/filters';
|
import { toCurrency } from 'src/filters';
|
||||||
|
const DEFAULT_AUTO_REFRESH = 1000;
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
|
const autoRefresh = ref(false);
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const paginateRef = ref(null);
|
const paginateRef = ref(null);
|
||||||
const workersActiveOptions = ref([]);
|
const workersActiveOptions = ref([]);
|
||||||
|
@ -328,7 +328,15 @@ const getBadgeAttrs = (date) => {
|
||||||
if (comparation < 0) return { color: 'success', 'text-color': 'black' };
|
if (comparation < 0) return { color: 'success', 'text-color': 'black' };
|
||||||
return { color: 'transparent', 'text-color': 'white' };
|
return { color: 'transparent', 'text-color': 'white' };
|
||||||
};
|
};
|
||||||
|
let refreshTimer = null;
|
||||||
|
const autoRefreshHandler = (value) => {
|
||||||
|
if (value)
|
||||||
|
refreshTimer = setInterval(() => paginateRef.value.fetch(), DEFAULT_AUTO_REFRESH);
|
||||||
|
else {
|
||||||
|
clearInterval(refreshTimer);
|
||||||
|
refreshTimer = null;
|
||||||
|
}
|
||||||
|
};
|
||||||
const redirectToTicketSummary = (id) => {
|
const redirectToTicketSummary = (id) => {
|
||||||
router.push({ name: 'TicketSummary', params: { id } });
|
router.push({ name: 'TicketSummary', params: { id } });
|
||||||
};
|
};
|
||||||
|
@ -426,6 +434,11 @@ onMounted(async () => {
|
||||||
labels-traductions-path="salesTicketsTable"
|
labels-traductions-path="salesTicketsTable"
|
||||||
@on-config-saved="visibleColumns = [...$event, 'rowActions']"
|
@on-config-saved="visibleColumns = [...$event, 'rowActions']"
|
||||||
/>
|
/>
|
||||||
|
<QCheckbox
|
||||||
|
v-model="autoRefresh"
|
||||||
|
:label="t('salesTicketsTable.autoRefresh')"
|
||||||
|
@update:model-value="autoRefreshHandler"
|
||||||
|
/>
|
||||||
</template>
|
</template>
|
||||||
<template #top-row="{ cols }">
|
<template #top-row="{ cols }">
|
||||||
<QTr>
|
<QTr>
|
||||||
|
|
|
@ -17,6 +17,7 @@ salesOrdersTable:
|
||||||
deleteConfirmTitle: Delete selected elements
|
deleteConfirmTitle: Delete selected elements
|
||||||
deleteConfirmMessage: All the selected elements will be deleted. Are you sure you want to continue?
|
deleteConfirmMessage: All the selected elements will be deleted. Are you sure you want to continue?
|
||||||
salesTicketsTable:
|
salesTicketsTable:
|
||||||
|
autoRefresh: Auto-refresh
|
||||||
problems: Problems
|
problems: Problems
|
||||||
noVerifiedData: No verified data
|
noVerifiedData: No verified data
|
||||||
notVisible: Not visible
|
notVisible: Not visible
|
||||||
|
|
|
@ -17,6 +17,7 @@ salesOrdersTable:
|
||||||
deleteConfirmTitle: Eliminar los elementos seleccionados
|
deleteConfirmTitle: Eliminar los elementos seleccionados
|
||||||
deleteConfirmMessage: Todos los elementos seleccionados serán eliminados. ¿Seguro que quieres continuar?
|
deleteConfirmMessage: Todos los elementos seleccionados serán eliminados. ¿Seguro que quieres continuar?
|
||||||
salesTicketsTable:
|
salesTicketsTable:
|
||||||
|
autoRefresh: Auto-refresco
|
||||||
problems: Problemas
|
problems: Problemas
|
||||||
noVerifiedData: Sin datos comprobados
|
noVerifiedData: Sin datos comprobados
|
||||||
notVisible: No visible
|
notVisible: No visible
|
||||||
|
|
Loading…
Reference in New Issue