feat: add departmentFk to user data and filter clients by department
gitea/salix-front/pipeline/head There was a failure building this commit Details

This commit is contained in:
Javier Segarra 2025-03-28 01:25:38 +01:00
parent 69da78b655
commit 2a3e072b1b
2 changed files with 6 additions and 1 deletions

View File

@ -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);

View File

@ -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) {