0
0
Fork 0
This commit is contained in:
Alex Moreno 2024-04-17 16:34:06 +02:00
commit ebd02987b9
1 changed files with 21 additions and 44 deletions

View File

@ -1,10 +1,9 @@
<script setup> <script setup>
import { onMounted, ref, computed, onUpdated } from 'vue'; import { ref, computed, onUpdated } from 'vue';
import { useRoute } from 'vue-router'; import { useRoute } from 'vue-router';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import CardSummary from 'components/ui/CardSummary.vue'; import CardSummary from 'components/ui/CardSummary.vue';
import VnLv from 'src/components/ui/VnLv.vue'; import VnLv from 'src/components/ui/VnLv.vue';
import { getUrl } from 'src/composables/getUrl';
import { useRole } from 'src/composables/useRole'; import { useRole } from 'src/composables/useRole';
import { dashIfEmpty } from 'src/filters'; import { dashIfEmpty } from 'src/filters';
import VnUserLink from 'src/components/ui/VnUserLink.vue'; import VnUserLink from 'src/components/ui/VnUserLink.vue';
@ -28,12 +27,6 @@ const entityId = computed(() => $props.id || route.params.id);
const summaryRef = ref(); const summaryRef = ref();
const supplier = ref(); const supplier = ref();
const supplierUrl = ref();
onMounted(async () => {
await roleState.fetch();
supplierUrl.value = (await getUrl('supplier/')) + entityId.value;
});
async function setData(data) { async function setData(data) {
if (data) { if (data) {
@ -44,6 +37,10 @@ async function setData(data) {
const isAdministrative = computed(() => { const isAdministrative = computed(() => {
return roleState.hasAny(['administrative']); return roleState.hasAny(['administrative']);
}); });
function getUrl(section) {
return isAdministrative.value && `#/supplier/${entityId.value}/${section}`;
}
</script> </script>
<template> <template>
@ -58,15 +55,10 @@ const isAdministrative = computed(() => {
<template #body> <template #body>
<QCard class="vn-one"> <QCard class="vn-one">
<router-link <VnTitle
v-if="isAdministrative" :url="getUrl('basic-data')"
class="header link" :text="t('globals.summary.basicData')"
:to="{ name: 'SupplierBasicData', params: { id: entityId } }" />
>
{{ t('globals.summary.basicData') }}
<QIcon name="open_in_new" />
</router-link>
<span v-else> {{ t('globals.summary.basicData') }}</span>
<VnLv label="Id" :value="supplier.id" /> <VnLv label="Id" :value="supplier.id" />
<VnLv label="Alias" :value="supplier.nickname" /> <VnLv label="Alias" :value="supplier.nickname" />
<VnLv :label="t('supplier.summary.responsible')"> <VnLv :label="t('supplier.summary.responsible')">
@ -94,15 +86,10 @@ const isAdministrative = computed(() => {
/> />
</QCard> </QCard>
<QCard class="vn-one"> <QCard class="vn-one">
<router-link <VnTitle
v-if="isAdministrative" :url="getUrl('billing-data')"
class="header link" :text="t('supplier.summary.billingData')"
:to="{ name: 'SupplierBillingData', params: { id: entityId } }" />
>
{{ t('supplier.summary.billingData') }}
<QIcon name="open_in_new" />
</router-link>
<span v-else> {{ t('supplier.summary.billingData') }}</span>
<VnLv <VnLv
:label="t('supplier.summary.payMethod')" :label="t('supplier.summary.payMethod')"
:value="supplier.payMethod?.name" :value="supplier.payMethod?.name"
@ -117,15 +104,10 @@ const isAdministrative = computed(() => {
<VnLv :label="t('supplier.summary.account')" :value="supplier.account" /> <VnLv :label="t('supplier.summary.account')" :value="supplier.account" />
</QCard> </QCard>
<QCard class="vn-one"> <QCard class="vn-one">
<router-link <VnTitle
v-if="isAdministrative" :url="getUrl('fiscal-data')"
class="header link" :text="t('supplier.summary.fiscalData')"
:to="{ name: 'SupplierFiscalData', params: { id: entityId } }" />
>
{{ t('supplier.summary.fiscalData') }}
<QIcon name="open_in_new" />
</router-link>
<span v-else> {{ t('supplier.summary.fiscalData') }}</span>
<VnLv <VnLv
:label="t('supplier.summary.sageTaxType')" :label="t('supplier.summary.sageTaxType')"
:value="supplier.sageTaxType?.vat" :value="supplier.sageTaxType?.vat"
@ -152,15 +134,10 @@ const isAdministrative = computed(() => {
/> />
</QCard> </QCard>
<QCard class="vn-one"> <QCard class="vn-one">
<router-link <VnTitle
v-if="isAdministrative" :url="getUrl('fiscal-data')"
class="header link" :text="t('supplier.summary.fiscalAddress')"
:to="{ name: 'SupplierFiscalData', params: { id: entityId } }" />
>
{{ t('supplier.summary.fiscalAddress') }}
<QIcon name="open_in_new" />
</router-link>
<span v-else> {{ t('supplier.summary.fiscalAddress') }}</span>
<VnLv :label="t('supplier.summary.socialName')" :value="supplier.name" /> <VnLv :label="t('supplier.summary.socialName')" :value="supplier.name" />
<VnLv :label="t('supplier.summary.taxNumber')" :value="supplier.nif" /> <VnLv :label="t('supplier.summary.taxNumber')" :value="supplier.nif" />
<VnLv :label="t('supplier.summary.street')" :value="supplier.street" /> <VnLv :label="t('supplier.summary.street')" :value="supplier.street" />