feat: refs #7984 add currency in userPanel
gitea/salix-front/pipeline/pr-dev There was a failure building this commit Details

This commit is contained in:
Alex Moreno 2025-01-23 15:09:38 +01:00
parent 552d05098c
commit 65bbd0768c
6 changed files with 29 additions and 4 deletions

View File

@ -47,6 +47,8 @@ const darkMode = computed({
}, },
}); });
const foreignCurrency = ref();
const user = state.getUser(); const user = state.getUser();
const warehousesData = ref(); const warehousesData = ref();
const companiesData = ref(); const companiesData = ref();
@ -58,6 +60,8 @@ onMounted(async () => {
}); });
function updatePreferences() { function updatePreferences() {
foreignCurrency.value = user.value.foreignCurrency;
if (user.value.darkMode !== null) { if (user.value.darkMode !== null) {
darkMode.value = user.value.darkMode; darkMode.value = user.value.darkMode;
} }
@ -116,6 +120,11 @@ async function saveUserData(param, value) {
} }
} }
async function saveCurrency(value) {
user.value.foreignCurrency = value;
useState().setUser(user.value);
}
const onDataSaved = () => { const onDataSaved = () => {
notify('globals.dataSaved', 'positive'); notify('globals.dataSaved', 'positive');
}; };
@ -169,6 +178,14 @@ const onDataError = () => {
color="primary" color="primary"
unchecked-icon="light_mode" unchecked-icon="light_mode"
/> />
<QToggle
v-model="foreignCurrency"
:label="t(`globals.foreignCurrency`)"
@update:model-value="saveCurrency"
color="primary"
unchecked-icon="euro_symbol"
checked-icon="currency_exchange"
/>
</div> </div>
<QSeparator vertical inset class="q-mx-lg" /> <QSeparator vertical inset class="q-mx-lg" />

View File

@ -2,6 +2,7 @@
import { toCurrency } from 'src/filters'; import { toCurrency } from 'src/filters';
import { computed, onMounted, ref } from 'vue'; import { computed, onMounted, ref } from 'vue';
import { useArrayData } from 'src/composables/useArrayData'; import { useArrayData } from 'src/composables/useArrayData';
import { useState } from 'src/composables/useState';
const $props = defineProps({ const $props = defineProps({
model: { model: {
@ -28,6 +29,9 @@ const $props = defineProps({
}, },
}); });
const state = useState();
const user = state.getUser();
const foreignFieldComputed = ref(); const foreignFieldComputed = ref();
const arrayData = $props.arrayDataModel && useArrayData($props.arrayDataModel); const arrayData = $props.arrayDataModel && useArrayData($props.arrayDataModel);
const foreignValue = ref(); const foreignValue = ref();
@ -61,8 +65,8 @@ function getLabel() {
<template> <template>
<span :title="toCurrencyLabel" v-if="currency && localValue"> <span :title="toCurrencyLabel" v-if="currency && localValue">
<span v-if="foreignValue">{{ toCurrencyLabel }} /</span> <span v-if="foreignValue && user.foreignCurrency">{{ toCurrencyLabel }}</span>
{{ toCurrency(localValue) }} <span v-else>{{ toCurrency(localValue) }}</span>
</span> </span>
<span v-else>-</span> <!-- <span v-else>-</span> -->
</template> </template>

View File

@ -60,7 +60,7 @@ export function useSession() {
const { data: isValidToken } = await axios.get('VnUsers/validateToken'); const { data: isValidToken } = await axios.get('VnUsers/validateToken');
if (isValidToken) if (isValidToken)
destroyTokenPromises = Object.entries(tokens).map(([key, url]) => destroyTokenPromises = Object.entries(tokens).map(([key, url]) =>
destroyToken(url, storage, key) destroyToken(url, storage, key),
); );
} }
} finally { } finally {
@ -75,6 +75,7 @@ export function useSession() {
nickname: '', nickname: '',
lang: '', lang: '',
darkMode: null, darkMode: null,
foreignCurrency: true,
}); });
stopRenewer(); stopRenewer();

View File

@ -10,6 +10,7 @@ const user = ref({
darkMode: null, darkMode: null,
companyFk: null, companyFk: null,
warehouseFk: null, warehouseFk: null,
foreignCurrency: true,
}); });
if (sessionStorage.getItem('user')) if (sessionStorage.getItem('user'))
user.value = JSON.parse(sessionStorage.getItem('user')); user.value = JSON.parse(sessionStorage.getItem('user'));

View File

@ -2,6 +2,7 @@ globals:
lang: lang:
es: Spanish es: Spanish
en: English en: English
foreignCurrency: Foreign currency
quantity: Quantity quantity: Quantity
language: Language language: Language
entity: Entity entity: Entity

View File

@ -2,6 +2,7 @@ globals:
lang: lang:
es: Español es: Español
en: Inglés en: Inglés
foreignCurrency: Moneda extranjera
language: Idioma language: Idioma
quantity: Cantidad quantity: Cantidad
entity: Entidad entity: Entidad