0
0
Fork 0

Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix-front into 7600-fix-vnLocation

This commit is contained in:
Jorge Penadés 2024-06-18 10:44:58 +02:00
commit 4ff0901950
4 changed files with 76 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

@ -53,6 +53,7 @@ const draggedRowIndex = ref(null);
const targetRowIndex = ref(null); const targetRowIndex = ref(null);
const entryRowIndex = ref(null); const entryRowIndex = ref(null);
const draggedEntry = ref(null); const draggedEntry = ref(null);
const travelKgPercentages = ref([]);
const tableColumnComponents = { const tableColumnComponents = {
id: { id: {
@ -88,6 +89,10 @@ 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' },
@ -179,6 +184,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',
@ -278,6 +291,8 @@ const saveFieldValue = async (val, field, index) => {
await axios.patch(`Travels/${id}`, params); await axios.patch(`Travels/${id}`, params);
// Actualizar la copia de los datos originales con el nuevo valor // Actualizar la copia de los datos originales con el nuevo valor
originalRowDataCopy.value[index][field] = val; originalRowDataCopy.value[index][field] = val;
await arrayData.fetch({ append: false });
} catch (err) { } catch (err) {
console.error('Error updating travel'); console.error('Error updating travel');
} }
@ -302,6 +317,11 @@ onMounted(async () => {
landedTo.value.setDate(landedTo.value.getDate() + 7); landedTo.value.setDate(landedTo.value.getDate() + 7);
landedTo.value.setHours(23, 59, 59, 59); landedTo.value.setHours(23, 59, 59, 59);
const { data } = await axios.get('TravelKgPercentages', {
params: { filter: JSON.stringify({ order: 'value DESC' }) },
});
travelKgPercentages.value = data;
await getData(); await getData();
}); });
@ -419,6 +439,11 @@ const handleDragScroll = (event) => {
stopScroll(); stopScroll();
} }
}; };
const getColor = (percentage) => {
for (const { value, className } of travelKgPercentages.value)
if (percentage > value) return className;
};
</script> </script>
<template> <template>
@ -460,7 +485,7 @@ const handleDragScroll = (event) => {
<template #body="props"> <template #body="props">
<QTr <QTr
:props="props" :props="props"
class="cursor-pointer bg-vn-primary-row" class="cursor-pointer bg-travel"
@click="navigateToTravelId(props.row.id)" @click="navigateToTravelId(props.row.id)"
@dragenter="handleDragEnter($event, props.rowIndex)" @dragenter="handleDragEnter($event, props.rowIndex)"
@dragover.prevent @dragover.prevent
@ -494,18 +519,32 @@ const handleDragScroll = (event) => {
: {} : {}
" "
> >
<template v-if="col.showValue"> <QChip
<span v-if="col.name === 'percentage'"
:class="[ :label="
'text-left', props.row.percentageKg
{ ? `${props.row.percentageKg}%`
'supplier-name': : '-'
col.name === 'cargoSupplierNickname', "
}, class="text-left q-py-xs q-px-sm"
]" :color="getColor(props.row.percentageKg)"
>{{ col.value }}</span />
> <span
</template> v-else-if="col.showValue"
:class="[
'text-left',
{
'supplier-name':
col.name === 'cargoSupplierNickname',
},
{
link: ['id', 'cargoSupplierNickname'].includes(
col.name
),
},
]"
v-text="col.value"
/>
<!-- Main Row Descriptors --> <!-- Main Row Descriptors -->
<TravelDescriptorProxy <TravelDescriptorProxy
v-if="col.name === 'id'" v-if="col.name === 'id'"
@ -539,11 +578,11 @@ const handleDragScroll = (event) => {
}" }"
> >
<QTd> <QTd>
<QBtn flat color="primary">{{ entry.id }} </QBtn> <QBtn flat class="link">{{ entry.id }} </QBtn>
<EntryDescriptorProxy :id="entry.id" /> <EntryDescriptorProxy :id="entry.id" />
</QTd> </QTd>
<QTd> <QTd>
<QBtn flat color="primary" dense>{{ entry.supplierName }}</QBtn> <QBtn flat class="link" dense>{{ entry.supplierName }}</QBtn>
<SupplierDescriptorProxy :id="entry.supplierFk" /> <SupplierDescriptorProxy :id="entry.supplierFk" />
</QTd> </QTd>
<QTd /> <QTd />
@ -556,6 +595,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>
@ -574,10 +614,23 @@ const handleDragScroll = (event) => {
</template> </template>
<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;
} }
.q-td :deep(input) {
font-weight: bold;
}
.bg-travel {
background-color: var(--vn-page-color);
border-bottom: 2px solid $primary;
}
.dashed-border { .dashed-border {
&.--left { &.--left {
border-left: 1px dashed #ccc; border-left: 1px dashed #ccc;