forked from verdnatura/salix-front
CardSummary changes
This commit is contained in:
parent
98c92abba2
commit
f1961f07d1
|
@ -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" />
|
||||||
|
|
|
@ -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>
|
||||||
|
|
Loading…
Reference in New Issue