2022-11-08 06:41:36 +00:00
|
|
|
<script setup>
|
2023-01-24 13:46:30 +00:00
|
|
|
import { onMounted, useSlots, computed, ref, toRef, watch } from 'vue';
|
2022-11-08 06:41:36 +00:00
|
|
|
import { useI18n } from 'vue-i18n';
|
2023-01-24 13:46:30 +00:00
|
|
|
import axios from 'axios';
|
|
|
|
import SkeletonDescriptor from 'components/ui/SkeletonDescriptor.vue';
|
2022-11-08 06:41:36 +00:00
|
|
|
|
2023-01-24 13:46:30 +00:00
|
|
|
const props = defineProps({
|
|
|
|
id: {
|
|
|
|
type: Number,
|
2022-11-08 12:36:22 +00:00
|
|
|
required: true,
|
|
|
|
},
|
2023-01-24 13:46:30 +00:00
|
|
|
module: {
|
|
|
|
type: String,
|
2022-11-08 06:41:36 +00:00
|
|
|
required: true,
|
|
|
|
},
|
2022-11-08 12:36:22 +00:00
|
|
|
description: {
|
|
|
|
type: String,
|
2023-01-24 13:46:30 +00:00
|
|
|
required: false,
|
|
|
|
default: '',
|
2022-11-08 12:36:22 +00:00
|
|
|
},
|
2022-11-08 06:41:36 +00:00
|
|
|
});
|
2023-01-24 13:46:30 +00:00
|
|
|
|
2022-11-08 06:41:36 +00:00
|
|
|
const slots = useSlots();
|
|
|
|
const { t } = useI18n();
|
2023-01-24 13:46:30 +00:00
|
|
|
|
|
|
|
onMounted(async () => {
|
|
|
|
await fetch();
|
|
|
|
});
|
|
|
|
|
|
|
|
const entity = ref();
|
|
|
|
const entityId = toRef(props, 'id');
|
|
|
|
const description = computed(() => {
|
|
|
|
return props.description || entity.value.name;
|
|
|
|
});
|
|
|
|
|
|
|
|
async function fetch() {
|
|
|
|
const { data } = await axios.get(`Clients/${entityId.value}/getCard`);
|
|
|
|
entity.value = data;
|
|
|
|
}
|
|
|
|
|
|
|
|
watch(entityId, async () => {
|
|
|
|
entity.value = null;
|
|
|
|
await fetch();
|
|
|
|
});
|
2022-11-08 06:41:36 +00:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<div class="descriptor">
|
|
|
|
<div class="header bg-primary q-pa-sm">
|
2022-11-08 12:36:22 +00:00
|
|
|
<router-link :to="{ name: `${module}List` }">
|
2022-11-08 06:41:36 +00:00
|
|
|
<q-btn round flat dense size="md" icon="view_list" color="white">
|
2022-11-08 12:36:22 +00:00
|
|
|
<q-tooltip>{{ t('components.cardDescriptor.mainList') }}</q-tooltip>
|
2022-11-08 06:41:36 +00:00
|
|
|
</q-btn>
|
|
|
|
</router-link>
|
2023-01-24 13:46:30 +00:00
|
|
|
<router-link :to="{ name: `${module}Summary`, params: { id: entityId } }">
|
2022-11-08 06:41:36 +00:00
|
|
|
<q-btn round flat dense size="md" icon="launch" color="white">
|
2022-11-08 12:36:22 +00:00
|
|
|
<q-tooltip>{{ t('components.cardDescriptor.summary') }}</q-tooltip>
|
2022-11-08 06:41:36 +00:00
|
|
|
</q-btn>
|
|
|
|
</router-link>
|
|
|
|
|
|
|
|
<q-btn v-if="slots.menu" size="md" icon="more_vert" color="white" round flat dense>
|
2022-11-08 12:36:22 +00:00
|
|
|
<q-tooltip>{{ t('components.cardDescriptor.moreOptions') }}</q-tooltip>
|
2022-11-08 06:41:36 +00:00
|
|
|
<q-menu>
|
|
|
|
<q-list>
|
|
|
|
<slot name="menu" />
|
|
|
|
</q-list>
|
|
|
|
</q-menu>
|
|
|
|
</q-btn>
|
|
|
|
</div>
|
2023-01-24 13:46:30 +00:00
|
|
|
<div v-if="entity" class="body q-py-sm">
|
2022-11-08 12:36:22 +00:00
|
|
|
<q-list>
|
|
|
|
<q-item-label header class="ellipsis text-h5" :lines="1">
|
2023-01-24 13:46:30 +00:00
|
|
|
{{ description }}
|
|
|
|
<q-tooltip>{{ description }}</q-tooltip>
|
2022-11-08 12:36:22 +00:00
|
|
|
</q-item-label>
|
|
|
|
<q-item dense>
|
2023-01-24 13:46:30 +00:00
|
|
|
<q-item-label class="text-subtitle2" caption>#{{ entity.id }}</q-item-label>
|
2022-11-08 12:36:22 +00:00
|
|
|
</q-item>
|
|
|
|
</q-list>
|
2023-01-24 13:46:30 +00:00
|
|
|
<slot name="body" :entity="entity" />
|
2022-11-08 06:41:36 +00:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<!-- Skeleton -->
|
2023-01-24 13:46:30 +00:00
|
|
|
<skeleton-descriptor v-if="!entity" />
|
2022-11-08 06:41:36 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
2022-11-08 12:36:22 +00:00
|
|
|
<style lang="scss">
|
|
|
|
.body {
|
|
|
|
.q-card__actions {
|
|
|
|
justify-content: center;
|
|
|
|
}
|
|
|
|
.text-h5 {
|
|
|
|
padding-top: 5px;
|
|
|
|
padding-bottom: 5px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
|
2022-11-08 06:41:36 +00:00
|
|
|
<style lang="scss" scoped>
|
|
|
|
.descriptor {
|
2022-11-08 12:36:22 +00:00
|
|
|
width: 256px;
|
2022-11-08 06:41:36 +00:00
|
|
|
|
|
|
|
.header {
|
|
|
|
display: flex;
|
|
|
|
justify-content: space-between;
|
|
|
|
align-items: stretch;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|