From 2a3e072b1bd95c2484099b04e7e7c24b0bb6d9ab Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Fri, 28 Mar 2025 01:25:38 +0100 Subject: [PATCH] feat: add departmentFk to user data and filter clients by department --- src/composables/useRole.js | 1 + src/pages/Monitor/MonitorClients.vue | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/composables/useRole.js b/src/composables/useRole.js index ff54b409c..e700b1f2e 100644 --- a/src/composables/useRole.js +++ b/src/composables/useRole.js @@ -13,6 +13,7 @@ export function useRole() { name: data.user.name, nickname: data.user.nickname, lang: data.user.lang || 'es', + departmentFk: data.user.worker.department.departmentFk, }; state.setUser(userData); state.setRoles(roles); diff --git a/src/pages/Monitor/MonitorClients.vue b/src/pages/Monitor/MonitorClients.vue index c814d623e..99110df16 100644 --- a/src/pages/Monitor/MonitorClients.vue +++ b/src/pages/Monitor/MonitorClients.vue @@ -9,12 +9,14 @@ import VnInputDate from 'src/components/common/VnInputDate.vue'; import VnRow from 'src/components/ui/VnRow.vue'; import { dateRange } from 'src/filters'; import useOpenURL from 'src/composables/useOpenURL'; +import { useState } from 'src/composables/useState'; const { t } = useI18n(); const dates = dateRange(Date.vnNew()); const from = ref(dates[0]); const to = ref(dates[1]); +const state = useState(); const filter = computed(() => { const obj = {}; const formatFrom = setHours(from.value, 'from'); @@ -25,7 +27,9 @@ const filter = computed(() => { else if (formatFrom && !formatTo) stamp = { gte: formatFrom }; else if (formatFrom && formatTo) stamp = { between: [formatFrom, formatTo] }; - return Object.assign(obj, { where: { 'v.stamp': stamp } }); + return Object.assign(obj, { + where: { 'v.stamp': stamp, departmentFk: state.getUser().departmentFk }, + }); }); function exprBuilder(param, value) {