Merge branch 'dev' into 7136_vnselectFilter_paginate
gitea/salix-front/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Javier Segarra 2024-06-18 11:22:19 +00:00
commit 9718f6f7b0
6 changed files with 79 additions and 27 deletions

View File

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

View File

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

View File

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

View File

@ -1,5 +1,5 @@
<script setup>
import { ref, computed } from 'vue';
import { computed } from 'vue';
import { useRoute } from 'vue-router';
import { useI18n } from 'vue-i18n';
@ -7,7 +7,6 @@ import CardDescriptor from 'components/ui/CardDescriptor.vue';
import VnLv from 'src/components/ui/VnLv.vue';
import TravelDescriptorMenuItems from './TravelDescriptorMenuItems.vue';
import useCardDescription from 'src/composables/useCardDescription';
import { toDate } from 'src/filters';
const $props = defineProps({

View File

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

View File

@ -2,8 +2,7 @@ const locationOptions = '[role="listbox"] > div.q-virtual-scroll__content > .q-i
describe('VnLocation', () => {
const dialogInputs = '.q-dialog label input';
describe('Worker Create', () => {
const inputLocation =
'.q-form .q-card > :nth-child(3) > .q-field > .q-field__inner > .q-field__control > .q-field__control-container';
const inputLocation = '.q-form input[aria-label="Location"]';
beforeEach(() => {
cy.viewport(1280, 720);
cy.login('developer');
@ -25,9 +24,6 @@ describe('VnLocation', () => {
cy.get(inputLocation).clear();
cy.get(inputLocation).type('ecuador');
cy.get(locationOptions).should('have.length.at.least', 1);
cy.get(
'.q-form .q-card > :nth-child(3) > .q-field > .q-field__inner > .q-field__control > :nth-child(3) > .q-icon'
).click();
});
});
describe('Fiscal-data', () => {
@ -38,9 +34,7 @@ describe('VnLocation', () => {
cy.waitForElement('.q-form');
});
it('Create postCode', function () {
cy.get(
':nth-child(6) > .q-field > .q-field__inner > .q-field__control > :nth-child(2) > .q-icon'
).click();
cy.get('.q-form > .q-card > .vn-row:nth-child(6) .--add-icon').click();
cy.get('.q-card > h1').should('have.text', 'New postcode');
cy.get(dialogInputs).eq(0).clear('12');
cy.get(dialogInputs).eq(0).type('1234453');