|
@@ -7,6 +7,13 @@
|
|
|
class="hidden"
|
|
class="hidden"
|
|
|
@change="onFileSelected"
|
|
@change="onFileSelected"
|
|
|
/>
|
|
/>
|
|
|
|
|
+ <input
|
|
|
|
|
+ ref="importAfastamentosFileInput"
|
|
|
|
|
+ type="file"
|
|
|
|
|
+ accept=".xlsx"
|
|
|
|
|
+ class="hidden"
|
|
|
|
|
+ @change="onAfastamentosFileSelected"
|
|
|
|
|
+ />
|
|
|
|
|
|
|
|
<DefaultHeaderPage>
|
|
<DefaultHeaderPage>
|
|
|
<template #after>
|
|
<template #after>
|
|
@@ -19,6 +26,8 @@
|
|
|
:label="$t('associado.import_afastamentos')"
|
|
:label="$t('associado.import_afastamentos')"
|
|
|
icon="mdi-upload"
|
|
icon="mdi-upload"
|
|
|
padding="6px 10px"
|
|
padding="6px 10px"
|
|
|
|
|
+ :loading="importingAfastamentos"
|
|
|
|
|
+ @click="onImportAfastamentosClick"
|
|
|
/>
|
|
/>
|
|
|
<q-btn
|
|
<q-btn
|
|
|
unelevated
|
|
unelevated
|
|
@@ -38,8 +47,18 @@
|
|
|
icon="mdi-clock-outline"
|
|
icon="mdi-clock-outline"
|
|
|
padding="6px 10px"
|
|
padding="6px 10px"
|
|
|
:title="$t('import_log.history_title')"
|
|
:title="$t('import_log.history_title')"
|
|
|
- @click="onOpenImportHistory"
|
|
|
|
|
- />
|
|
|
|
|
|
|
+ >
|
|
|
|
|
+ <q-menu>
|
|
|
|
|
+ <q-list dense>
|
|
|
|
|
+ <q-item v-close-popup clickable @click="onOpenImportHistory('associado')">
|
|
|
|
|
+ <q-item-section>{{ $t('associado.import_associados') }}</q-item-section>
|
|
|
|
|
+ </q-item>
|
|
|
|
|
+ <q-item v-close-popup clickable @click="onOpenImportHistory('afastamento')">
|
|
|
|
|
+ <q-item-section>{{ $t('associado.import_afastamentos') }}</q-item-section>
|
|
|
|
|
+ </q-item>
|
|
|
|
|
+ </q-list>
|
|
|
|
|
+ </q-menu>
|
|
|
|
|
+ </q-btn>
|
|
|
<q-btn
|
|
<q-btn
|
|
|
unelevated
|
|
unelevated
|
|
|
dense
|
|
dense
|
|
@@ -143,7 +162,7 @@ import { ref, computed, defineAsyncComponent, useTemplateRef } from "vue";
|
|
|
import { useQuasar } from "quasar";
|
|
import { useQuasar } from "quasar";
|
|
|
import { useI18n } from "vue-i18n";
|
|
import { useI18n } from "vue-i18n";
|
|
|
import { permissionStore } from "src/stores/permission";
|
|
import { permissionStore } from "src/stores/permission";
|
|
|
-import { getAssociadosPaginated, importAssociados, setUserOnLeave, approveUser } from "src/api/user";
|
|
|
|
|
|
|
+import { getAssociadosPaginated, importAssociados, importAfastamentos, setUserOnLeave, approveUser } from "src/api/user";
|
|
|
import { getStatusColor, getStatusI18nKey } from "src/helpers/utils";
|
|
import { getStatusColor, getStatusI18nKey } from "src/helpers/utils";
|
|
|
import { useImportPoller } from "src/composables/useImportPoller";
|
|
import { useImportPoller } from "src/composables/useImportPoller";
|
|
|
import DefaultHeaderPage from "src/components/layout/DefaultHeaderPage.vue";
|
|
import DefaultHeaderPage from "src/components/layout/DefaultHeaderPage.vue";
|
|
@@ -169,6 +188,9 @@ const tableRef = ref(null);
|
|
|
const importFileInput = useTemplateRef("importFileInput");
|
|
const importFileInput = useTemplateRef("importFileInput");
|
|
|
const { polling: importing, start: startPolling } = useImportPoller();
|
|
const { polling: importing, start: startPolling } = useImportPoller();
|
|
|
|
|
|
|
|
|
|
+const importAfastamentosFileInput = useTemplateRef("importAfastamentosFileInput");
|
|
|
|
|
+const { polling: importingAfastamentos, start: startAfastamentosPolling } = useImportPoller();
|
|
|
|
|
+
|
|
|
const selectedPosition = ref(null);
|
|
const selectedPosition = ref(null);
|
|
|
const selectedSector = ref(null);
|
|
const selectedSector = ref(null);
|
|
|
const extraFilters = computed(() => ({
|
|
const extraFilters = computed(() => ({
|
|
@@ -322,8 +344,8 @@ const onOpenAppointments = (row) => {
|
|
|
});
|
|
});
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-const onOpenImportHistory = () => {
|
|
|
|
|
- $q.dialog({ component: ImportHistoryDialog, componentProps: { type: 'associado' } });
|
|
|
|
|
|
|
+const onOpenImportHistory = (type) => {
|
|
|
|
|
+ $q.dialog({ component: ImportHistoryDialog, componentProps: { type } });
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
const onImportClick = () => {
|
|
const onImportClick = () => {
|
|
@@ -362,6 +384,42 @@ const onFileSelected = async (event) => {
|
|
|
$q.notify({ type: "negative", message: t("http.errors.failed") });
|
|
$q.notify({ type: "negative", message: t("http.errors.failed") });
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
|
|
+
|
|
|
|
|
+const onImportAfastamentosClick = () => {
|
|
|
|
|
+ if (!permission_store.getAccess("associado", "add")) {
|
|
|
|
|
+ $q.notify({ type: "negative", message: t("validation.permissions.add") });
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ importAfastamentosFileInput.value.value = null;
|
|
|
|
|
+ importAfastamentosFileInput.value.click();
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
|
|
+const onAfastamentosFileSelected = async (event) => {
|
|
|
|
|
+ const file = event.target.files?.[0];
|
|
|
|
|
+ if (!file) return;
|
|
|
|
|
+
|
|
|
|
|
+ try {
|
|
|
|
|
+ const { import_id } = await importAfastamentos(file);
|
|
|
|
|
+
|
|
|
|
|
+ startAfastamentosPolling(import_id, {
|
|
|
|
|
+ onComplete: (stats) => {
|
|
|
|
|
+ $q.notify({
|
|
|
|
|
+ type: "positive",
|
|
|
|
|
+ message: t("associado.import_afastamentos_result", {
|
|
|
|
|
+ created: stats.created,
|
|
|
|
|
+ on_leave: stats.on_leave,
|
|
|
|
|
+ }),
|
|
|
|
|
+ timeout: 6000,
|
|
|
|
|
+ });
|
|
|
|
|
+ tableRef.value?.refresh();
|
|
|
|
|
+ },
|
|
|
|
|
+ onError: () => $q.notify({ type: "negative", message: t("http.errors.failed") }),
|
|
|
|
|
+ onTimeout: () => $q.notify({ type: "warning", message: t("associado.import_processing") }),
|
|
|
|
|
+ });
|
|
|
|
|
+ } catch {
|
|
|
|
|
+ $q.notify({ type: "negative", message: t("http.errors.failed") });
|
|
|
|
|
+ }
|
|
|
|
|
+};
|
|
|
</script>
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped>
|
|
<style scoped>
|