|
@@ -35,12 +35,15 @@
|
|
|
|
|
|
|
|
<q-card v-if="activeCard" flat class="bg-white" style="border-radius: 12px">
|
|
<q-card v-if="activeCard" flat class="bg-white" style="border-radius: 12px">
|
|
|
<DefaultTableServerSide
|
|
<DefaultTableServerSide
|
|
|
|
|
+ ref="tableRef"
|
|
|
:key="activeCard"
|
|
:key="activeCard"
|
|
|
:columns="tableColumns"
|
|
:columns="tableColumns"
|
|
|
:api-call="activeApiCall"
|
|
:api-call="activeApiCall"
|
|
|
:add-item="false"
|
|
:add-item="false"
|
|
|
sem-table-top
|
|
sem-table-top
|
|
|
|
|
+ :open-item="activeCard === 'dependentes_pendentes'"
|
|
|
:show-search-field="!['ultimos_acessos', 'associados_com_acesso_app'].includes(activeCard)"
|
|
:show-search-field="!['ultimos_acessos', 'associados_com_acesso_app'].includes(activeCard)"
|
|
|
|
|
+ @on-row-click="onDependentRowClick"
|
|
|
>
|
|
>
|
|
|
<template #body-cell-status="{ row }">
|
|
<template #body-cell-status="{ row }">
|
|
|
<q-td>
|
|
<q-td>
|
|
@@ -76,17 +79,24 @@
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<script setup>
|
|
<script setup>
|
|
|
-import { ref, computed, onMounted } from "vue";
|
|
|
|
|
|
|
+import { ref, computed, onMounted, useTemplateRef } from "vue";
|
|
|
import { useI18n } from "vue-i18n";
|
|
import { useI18n } from "vue-i18n";
|
|
|
|
|
+import { useQuasar } from "quasar";
|
|
|
import DefaultHeaderPage from "src/components/layout/DefaultHeaderPage.vue";
|
|
import DefaultHeaderPage from "src/components/layout/DefaultHeaderPage.vue";
|
|
|
import DefaultTableServerSide from "src/components/defaults/DefaultTableServerSide.vue";
|
|
import DefaultTableServerSide from "src/components/defaults/DefaultTableServerSide.vue";
|
|
|
import { getDashboardStats } from "src/api/dashboard";
|
|
import { getDashboardStats } from "src/api/dashboard";
|
|
|
import { getUsersPaginated } from "src/api/user";
|
|
import { getUsersPaginated } from "src/api/user";
|
|
|
|
|
+import { getDependentsPaginated } from "src/api/profile";
|
|
|
import { getPartnerAgreementsPaginated, getExpiringPartnerAgreementsPaginated } from "src/api/partnerAgreement";
|
|
import { getPartnerAgreementsPaginated, getExpiringPartnerAgreementsPaginated } from "src/api/partnerAgreement";
|
|
|
import { getAccessLogsPaginated } from "src/api/userAccessLog";
|
|
import { getAccessLogsPaginated } from "src/api/userAccessLog";
|
|
|
import { formatDateYMDtoDMY, getStatusColor, getStatusI18nKey } from "src/helpers/utils";
|
|
import { formatDateYMDtoDMY, getStatusColor, getStatusI18nKey } from "src/helpers/utils";
|
|
|
|
|
+import { permissionStore } from "src/stores/permission";
|
|
|
|
|
+import DependentApprovalDialog from "./components/DependentApprovalDialog.vue";
|
|
|
|
|
|
|
|
const { t } = useI18n();
|
|
const { t } = useI18n();
|
|
|
|
|
+const $q = useQuasar();
|
|
|
|
|
+const permission_store = permissionStore();
|
|
|
|
|
+const tableRef = useTemplateRef("tableRef");
|
|
|
|
|
|
|
|
const statsLoading = ref(true);
|
|
const statsLoading = ref(true);
|
|
|
const stats = ref({});
|
|
const stats = ref({});
|
|
@@ -99,6 +109,7 @@ const statCards = [
|
|
|
{ key: "contratos_a_vencer", icon: "mdi-file-clock", labelKey: "dashboard.stats.contratos_a_vencer" },
|
|
{ key: "contratos_a_vencer", icon: "mdi-file-clock", labelKey: "dashboard.stats.contratos_a_vencer" },
|
|
|
{ key: "novos_mes", icon: "mdi-account-plus", labelKey: "dashboard.stats.novos_mes" },
|
|
{ key: "novos_mes", icon: "mdi-account-plus", labelKey: "dashboard.stats.novos_mes" },
|
|
|
{ key: "associados_pendentes", icon: "mdi-account-alert", labelKey: "dashboard.stats.associados_pendentes" },
|
|
{ key: "associados_pendentes", icon: "mdi-account-alert", labelKey: "dashboard.stats.associados_pendentes" },
|
|
|
|
|
+ { key: "dependentes_pendentes", icon: "mdi-account-child-circle", labelKey: "dashboard.stats.dependentes_pendentes" },
|
|
|
{ key: "ultimos_acessos", icon: "mdi-login-variant", labelKey: "dashboard.stats.ultimos_acessos" },
|
|
{ key: "ultimos_acessos", icon: "mdi-login-variant", labelKey: "dashboard.stats.ultimos_acessos" },
|
|
|
{ key: "associados_com_acesso_app", icon: "mdi-cellphone-check", labelKey: "dashboard.stats.total_acessos_app" },
|
|
{ key: "associados_com_acesso_app", icon: "mdi-cellphone-check", labelKey: "dashboard.stats.total_acessos_app" },
|
|
|
];
|
|
];
|
|
@@ -125,6 +136,12 @@ const columnsContratosAVencer = computed(() => [
|
|
|
{ name: "status", label: t("common.terms.status"), field: "status", align: "left" },
|
|
{ name: "status", label: t("common.terms.status"), field: "status", align: "left" },
|
|
|
]);
|
|
]);
|
|
|
|
|
|
|
|
|
|
+const columnsDependentes = computed(() => [
|
|
|
|
|
+ { name: "responsible_user_name", label: t("associado.associado"), field: (row) => row.responsible_user?.name ?? "—", align: "left", sortable: false },
|
|
|
|
|
+ { name: "name", label: t("associado.dependent"), field: "name", align: "left", sortable: false },
|
|
|
|
|
+ { name: "created_at", label: t("associado.dependent_registered_at"), field: (row) => formatDateTime(row.created_at), align: "left", sortable: false },
|
|
|
|
|
+]);
|
|
|
|
|
+
|
|
|
const columnsAccessLogs = computed(() => [
|
|
const columnsAccessLogs = computed(() => [
|
|
|
{ name: "user_name", label: t("access_log.user"), field: "user_name", align: "left", sortable: false },
|
|
{ name: "user_name", label: t("access_log.user"), field: "user_name", align: "left", sortable: false },
|
|
|
{ name: "user_type", label: t("access_log.user_type"), field: "user_type", align: "center", sortable: false },
|
|
{ name: "user_type", label: t("access_log.user_type"), field: "user_type", align: "center", sortable: false },
|
|
@@ -136,6 +153,7 @@ const tableColumns = computed(() => {
|
|
|
if (activeCard.value === "contratos_a_vencer") return columnsContratosAVencer.value;
|
|
if (activeCard.value === "contratos_a_vencer") return columnsContratosAVencer.value;
|
|
|
if (activeCard.value === "parceiros" || activeCard.value === "novos_mes") return columnsParceiros.value;
|
|
if (activeCard.value === "parceiros" || activeCard.value === "novos_mes") return columnsParceiros.value;
|
|
|
if (activeCard.value === "ultimos_acessos" || activeCard.value === "associados_com_acesso_app") return columnsAccessLogs.value;
|
|
if (activeCard.value === "ultimos_acessos" || activeCard.value === "associados_com_acesso_app") return columnsAccessLogs.value;
|
|
|
|
|
+ if (activeCard.value === "dependentes_pendentes") return columnsDependentes.value;
|
|
|
return columnsAssociados.value;
|
|
return columnsAssociados.value;
|
|
|
});
|
|
});
|
|
|
|
|
|
|
@@ -148,6 +166,8 @@ const activeApiCall = computed(() => {
|
|
|
return (p) => getUsersPaginated({ ...p, type: "associado", status: "active" });
|
|
return (p) => getUsersPaginated({ ...p, type: "associado", status: "active" });
|
|
|
case "associados_pendentes":
|
|
case "associados_pendentes":
|
|
|
return (p) => getUsersPaginated({ ...p, type: "associado", status: "pending" });
|
|
return (p) => getUsersPaginated({ ...p, type: "associado", status: "pending" });
|
|
|
|
|
+ case "dependentes_pendentes":
|
|
|
|
|
+ return (p) => getDependentsPaginated({ ...p, status: "pending" });
|
|
|
case "parceiros":
|
|
case "parceiros":
|
|
|
return (p) => getPartnerAgreementsPaginated({ ...p });
|
|
return (p) => getPartnerAgreementsPaginated({ ...p });
|
|
|
case "contratos_a_vencer":
|
|
case "contratos_a_vencer":
|
|
@@ -165,7 +185,8 @@ const activeApiCall = computed(() => {
|
|
|
|
|
|
|
|
const formatDateTime = (isoString) => {
|
|
const formatDateTime = (isoString) => {
|
|
|
if (!isoString) return "—";
|
|
if (!isoString) return "—";
|
|
|
- const d = new Date(isoString);
|
|
|
|
|
|
|
+ const d = new Date(isoString.includes("T") ? isoString : isoString.replace(" ", "T"));
|
|
|
|
|
+ if (Number.isNaN(d.getTime())) return isoString;
|
|
|
return d.toLocaleString("pt-BR", {
|
|
return d.toLocaleString("pt-BR", {
|
|
|
day: "2-digit", month: "2-digit", year: "numeric",
|
|
day: "2-digit", month: "2-digit", year: "numeric",
|
|
|
hour: "2-digit", minute: "2-digit", second: "2-digit",
|
|
hour: "2-digit", minute: "2-digit", second: "2-digit",
|
|
@@ -176,6 +197,20 @@ const onCardClick = (card) => {
|
|
|
activeCard.value = activeCard.value === card.key ? null : card.key;
|
|
activeCard.value = activeCard.value === card.key ? null : card.key;
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
+const onDependentRowClick = ({ row }) => {
|
|
|
|
|
+ if (!permission_store.getAccess("associado.dependente_aprovacao", "edit")) {
|
|
|
|
|
+ $q.notify({ type: "negative", message: t("validation.permissions.edit") });
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ $q.dialog({
|
|
|
|
|
+ component: DependentApprovalDialog,
|
|
|
|
|
+ componentProps: { dependent: row },
|
|
|
|
|
+ }).onOk(async () => {
|
|
|
|
|
+ tableRef.value?.refresh();
|
|
|
|
|
+ stats.value = await getDashboardStats();
|
|
|
|
|
+ });
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
onMounted(async () => {
|
|
onMounted(async () => {
|
|
|
try {
|
|
try {
|
|
|
stats.value = await getDashboardStats();
|
|
stats.value = await getDashboardStats();
|