0
0
Fork 0

feat: refs #6238 add percentage & summary btn

This commit is contained in:
Jorge Penadés 2024-06-12 12:17:52 +02:00
parent 11d1fdd80e
commit 51d497a1de
4 changed files with 58 additions and 17 deletions

View File

@ -115,13 +115,13 @@ const emit = defineEmits(['onFetch']);
</QBtn> </QBtn>
</RouterLink> </RouterLink>
<QBtn <QBtn
v-if="$slots.menu"
color="white" color="white"
dense dense
flat flat
icon="more_vert" icon="more_vert"
round round
size="md" size="md"
:class="{ invisible: !$slots.menu }"
> >
<QTooltip> <QTooltip>
{{ t('components.cardDescriptor.moreOptions') }} {{ t('components.cardDescriptor.moreOptions') }}

View File

@ -17,6 +17,10 @@ const $props = defineProps({
required: false, required: false,
default: null, default: null,
}, },
summary: {
type: Object,
default: null,
},
}); });
const route = useRoute(); const route = useRoute();
@ -106,6 +110,7 @@ const getEntryQueryParams = (supplier) => {
:filter="filter" :filter="filter"
@on-fetch="setData" @on-fetch="setData"
data-key="supplier" data-key="supplier"
:summary="$props.summary"
> >
<template #header-extra-action> <template #header-extra-action>
<QBtn <QBtn

View File

@ -1,5 +1,6 @@
<script setup> <script setup>
import SupplierDescriptor from './SupplierDescriptor.vue'; import SupplierDescriptor from './SupplierDescriptor.vue';
import SupplierSummary from './SupplierSummary.vue';
const $props = defineProps({ const $props = defineProps({
id: { id: {
@ -11,6 +12,6 @@ const $props = defineProps({
<template> <template>
<QPopupProxy> <QPopupProxy>
<SupplierDescriptor v-if="$props.id" :id="$props.id" /> <SupplierDescriptor v-if="$props.id" :id="$props.id" :summary="SupplierSummary" />
</QPopupProxy> </QPopupProxy>
</template> </template>

View File

@ -78,7 +78,7 @@ const tableColumnComponents = {
}, },
ref: { ref: {
component: VnInput, component: VnInput,
attrs: { dense: true }, attrs: { dense: true, class: 'bold' },
event: (val, field, rowIndex) => ({ event: (val, field, rowIndex) => ({
'keyup.enter': () => saveFieldValue(val, field, rowIndex), 'keyup.enter': () => saveFieldValue(val, field, rowIndex),
blur: () => saveFieldValue(val, field, rowIndex), blur: () => saveFieldValue(val, field, rowIndex),
@ -88,9 +88,13 @@ const tableColumnComponents = {
component: 'span', component: 'span',
attrs: {}, attrs: {},
}, },
percentage: {
component: 'span',
attrs: {},
},
kg: { kg: {
component: VnInput, component: VnInput,
attrs: { dense: true, type: 'number', min: 0, class: 'input-number' }, attrs: { dense: true, type: 'number', min: 0, class: 'input-number bold' },
event: (val, field, rowIndex) => ({ event: (val, field, rowIndex) => ({
'keyup.enter': () => saveFieldValue(val, field, rowIndex), 'keyup.enter': () => saveFieldValue(val, field, rowIndex),
blur: () => saveFieldValue(val, field, rowIndex), blur: () => saveFieldValue(val, field, rowIndex),
@ -179,6 +183,14 @@ const columns = computed(() => [
showValue: true, showValue: true,
sortable: true, sortable: true,
}, },
{
label: '%',
field: '',
name: 'percentage',
align: 'center',
showValue: false,
sortable: true,
},
{ {
label: t('kg'), label: t('kg'),
field: 'kg', field: 'kg',
@ -419,6 +431,10 @@ const handleDragScroll = (event) => {
stopScroll(); stopScroll();
} }
}; };
const getKgPercentage = ({ kg, loadedKg, volumeKg }) => {
return Math.round((Math.max(loadedKg || 0, volumeKg || 0) / kg) * 100);
};
</script> </script>
<template> <template>
@ -494,18 +510,28 @@ const handleDragScroll = (event) => {
: {} : {}
" "
> >
<template v-if="col.showValue"> <QChip
<span v-if="col.name === 'percentage'"
:class="[ :label="getKgPercentage(props.row) + '%'"
'text-left', class="text-left q-py-xs q-px-sm"
{ :class="{
'supplier-name': 'bg-red-10': getKgPercentage(props.row) >= 100,
col.name === 'cargoSupplierNickname', 'bg-deep-orange-10':
}, getKgPercentage(props.row) >= 80 &&
]" getKgPercentage(props.row) < 100,
>{{ col.value }}</span }"
> />
</template> <span
v-else-if="col.showValue"
:class="[
'text-left',
{
'supplier-name':
col.name === 'cargoSupplierNickname',
},
]"
v-text="col.value"
/>
<!-- Main Row Descriptors --> <!-- Main Row Descriptors -->
<TravelDescriptorProxy <TravelDescriptorProxy
v-if="col.name === 'id'" v-if="col.name === 'id'"
@ -556,6 +582,7 @@ const handleDragScroll = (event) => {
<QTd> <QTd>
<span>{{ entry.stickers }}</span> <span>{{ entry.stickers }}</span>
</QTd> </QTd>
<QTd />
<QTd></QTd> <QTd></QTd>
<QTd> <QTd>
<span>{{ entry.loadedkg }}</span> <span>{{ entry.loadedkg }}</span>
@ -572,8 +599,16 @@ const handleDragScroll = (event) => {
</QTable> </QTable>
</QPage> </QPage>
</template> </template>
<style lang="scss">
.bold input {
font-weight: bold;
}
</style>
<style scoped lang="scss"> <style scoped lang="scss">
.q-chip {
color: var(--vn-text-color);
}
:deep(.q-table) { :deep(.q-table) {
border-collapse: collapse; border-collapse: collapse;
} }