0
0
Fork 0

CardSummary changes

This commit is contained in:
William Buezas 2024-02-28 08:54:53 -03:00
parent 98c92abba2
commit f1961f07d1
2 changed files with 24 additions and 12 deletions

View File

@ -1,11 +1,10 @@
<script setup> <script setup>
import { onMounted, ref, watch } from 'vue'; import { onMounted, ref, watch } from 'vue';
import { useRoute } from 'vue-router';
import axios from 'axios'; import axios from 'axios';
import SkeletonSummary from 'components/ui/SkeletonSummary.vue'; import SkeletonSummary from 'components/ui/SkeletonSummary.vue';
import VnLv from 'src/components/ui/VnLv.vue'; import VnLv from 'src/components/ui/VnLv.vue';
onMounted(() => fetch());
const entity = ref(); const entity = ref();
const props = defineProps({ const props = defineProps({
url: { url: {
@ -16,14 +15,25 @@ const props = defineProps({
type: Object, type: Object,
default: null, default: null,
}, },
summaryRouteName: {
type: String,
default: null,
},
}); });
const emit = defineEmits(['onFetch']); const emit = defineEmits(['onFetch']);
const route = useRoute();
const isSummary = ref();
defineExpose({ defineExpose({
entity, entity,
fetch, fetch,
}); });
onMounted(() => {
isSummary.value = String(route.path).endsWith('/summary');
fetch();
});
async function fetch() { async function fetch() {
const params = {}; const params = {};
@ -48,7 +58,17 @@ watch(props, async () => {
<template v-if="entity"> <template v-if="entity">
<div class="summaryHeader bg-primary q-pa-md text-weight-bolder"> <div class="summaryHeader bg-primary q-pa-md text-weight-bolder">
<slot name="header-left"> <slot name="header-left">
<span></span> <router-link
v-if="!isSummary"
class="header link"
:to="{
name: summaryRouteName,
params: { id: entity.id },
}"
>
<QIcon name="open_in_new" color="white" size="sm" />
</router-link>
<span v-else></span>
</slot> </slot>
<slot name="header" :entity="entity"> <slot name="header" :entity="entity">
<VnLv :label="`${entity.id} -`" :value="entity.name" /> <VnLv :label="`${entity.id} -`" :value="entity.name" />

View File

@ -49,17 +49,9 @@ const isAdministrative = computed(() => {
<CardSummary <CardSummary
ref="summaryRef" ref="summaryRef"
:url="`Suppliers/${entityId}/getSummary`" :url="`Suppliers/${entityId}/getSummary`"
summary-route-name="SupplierSummary"
@on-fetch="(data) => setData(data)" @on-fetch="(data) => setData(data)"
> >
<template #header-left>
<router-link
v-if="isAdministrative && route.name !== 'SupplierSummary'"
class="header link"
:to="{ name: 'SupplierSummary', params: { id: entityId } }"
>
<QIcon name="open_in_new" color="white" size="sm" />
</router-link>
</template>
<template #header> <template #header>
<span>{{ supplier.name }} - {{ supplier.id }}</span> <span>{{ supplier.name }} - {{ supplier.id }}</span>
</template> </template>