0
0
Fork 0

feat: refs #7404 add travel m3 to reserves form

This commit is contained in:
Pablo Natek 2024-09-11 07:55:12 +02:00
parent e083d6a802
commit c7e717c611
6 changed files with 76 additions and 26 deletions

View File

@ -171,8 +171,6 @@ const components = computed(() => $props.components ?? defaultComponents);
:value="{ row, model }"
v-model="model"
/>
{{ console.log('model: ', col) }}
<VnComponent
v-if="col.component"
:prop="col"
@ -180,7 +178,6 @@ const components = computed(() => $props.components ?? defaultComponents);
:value="{ row, model }"
v-model="model"
/>
<span :title="value" v-else>{{ value }}</span>
<VnComponent
v-if="col.after"

View File

@ -24,7 +24,6 @@ const componentArray = computed(() => {
function mix(toComponent) {
const { component, attrs, event } = toComponent;
console.log('attrs: ', attrs);
const customComponent = $props.components[component];
return {
component: customComponent?.component ?? component,

View File

@ -58,6 +58,7 @@ const $props = defineProps({
});
defineExpose({ search, sanitizer });
const emit = defineEmits([
'update:modelValue',
'refresh',

View File

@ -1,10 +1,13 @@
<script setup>
import { ref } from 'vue';
import { onMounted, ref, watch } from 'vue';
import { useI18n } from 'vue-i18n';
import { useState } from 'src/composables/useState';
import { useQuasar } from 'quasar';
import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue';
import axios from 'axios';
import FetchData from 'components/FetchData.vue';
import VnRow from 'components/ui/VnRow.vue';
import RightMenu from 'src/components/common/RightMenu.vue';
import EntryStockBoughtFilter from './EntryStockBoughtFilter.vue';
import VnTable from 'components/VnTable/VnTable.vue';
@ -13,7 +16,6 @@ import EntryStockBoughtDetail from 'src/pages/Entry/EntryStockBoughtDetail.vue';
const { t } = useI18n();
const quasar = useQuasar();
const tableRef = ref();
const state = useState();
const user = state.getUser();
const columns = [
@ -88,7 +90,32 @@ const columns = [
},
];
const fetchDataRef = ref();
const tableRef = ref();
const travel = ref(null);
const userParams = ref({
dated: Date.vnNew(),
});
const filter = ref({
where: {
shipped: (userParams.value.dated
? new Date(userParams.value.dated)
: Date.vnNew()
).setHours(0, 0, 0, 0),
m3: { neq: null },
},
include: [
{
relation: 'warehouseIn',
scope: {
where: { code: 'vnh' },
},
},
],
});
function getFilter(dated) {
console.log('dated: ', dated);
const shipped = dated ? new Date(dated) : Date.vnNew();
shipped.setHours(0, 0, 0, 0);
return {
@ -99,48 +126,62 @@ function getFilter(dated) {
include: [
{
relation: 'warehouseIn',
scope: {
where: { code: 'vnh' },
},
},
],
};
}
const userParams = ref({
dated: Date.vnNew(),
});
const setUserParams = async ({ dated }) => {
const shipped = (dated ? new Date(dated) : Date.vnNew()).setHours(0, 0, 0, 0);
filter.value.where.shipped = shipped;
fetchDataRef.value?.fetch();
};
</script>
<template>
<VnSubToolbar>
<template #st-data="{ params }">
<template #st-data>
<FetchData
ref="fetchDataRef"
url="Travels"
limit="1"
auto-load
:filter="getFilter(params?.dated)"
:filter="filter"
@on-fetch="(data) => (travel = data)"
/>
<div>
<div>
<span style="color: var(--vn-label-color)">
{{ t('Booked trucks') + ': ' }}
</span>
</div>
<div v-if="travel">
<VnRow>
<div v-if="travel" class="q-pa-md">
<QIcon
name="local_airport"
class="fill-icon q-mr-sm"
size="md"
:title="t('Travel')"
color="primary"
/>
<span>
{{ travel[0]?.m3 }}
{{ t('Booked trucks') + ': ' + travel[0]?.m3 }}
</span>
<QBtn
style="max-width: 20%"
flat
icon="edit"
@click="navigate(travel[0]?.id)"
:title="t('Edit travel')"
/>
</div>
</div>
</VnRow>
</template>
</VnSubToolbar>
<RightMenu>
<template #right-panel>
<EntryStockBoughtFilter data-key="StockBoughts" />
<EntryStockBoughtFilter
data-key="StockBoughts"
@set-user-params="setUserParams"
/>
</template>
</RightMenu>
<QPage class="column items-center q-pa-md">
@ -155,7 +196,10 @@ const userParams = ref({
:create="{
urlCreate: 'StockBoughts',
title: t('Reserve some space'),
onDataSaved: () => tableRef.reload(),
onDataSaved: () => {
tableRef.reload();
fetchDataRef.reload();
},
formInitialData: {
workerFk: user.id,
dated: Date.vnNow(),
@ -163,8 +207,8 @@ const userParams = ref({
}"
:columns="columns"
:user-params="userParams"
auto-load
:footer="true"
auto-load
>
<template #column-workerFk="{ row }">
<span class="link" @click.stop>
@ -192,6 +236,8 @@ const userParams = ref({
Date: Date
This buyer has already made a reservation for this date: This buyer has already made a reservation for this date
es:
Edit travel: Editar envío
Travel: Envíos
Booked trucks: Camiones reservados
Buyer: Comprador
Reserve: Reservado

View File

@ -15,9 +15,12 @@ const props = defineProps({
required: true,
},
});
const companiesOptions = ref([]);
const stateStore = useStateStore();
const emit = defineEmits(['set-user-params']);
const setUserParams = (params) => {
emit('set-user-params', params);
};
onMounted(async () => {
stateStore.rightDrawer = true;
});
@ -35,7 +38,11 @@ onMounted(async () => {
@on-fetch="(data) => (companiesOptions = data)"
auto-load
/>
<VnFilterPanel :data-key="props.dataKey" :search-button="true">
<VnFilterPanel
:data-key="props.dataKey"
:search-button="true"
@set-user-params="setUserParams"
>
<template #tags="{ tag, formatFn }">
<div class="q-gutter-x-xs">
<strong>{{ t(`params.${tag.label}`) }}: </strong>

View File

@ -20,7 +20,7 @@ describe('EntryStockBought', () => {
cy.get('input[aria-label="Date"]').eq(1).type('01-01');
cy.get('input[aria-label="Buyer"]').type('buyerboss{downarrow}{enter}');
cy.get('.q-notification__message').should('have.text', 'Data created');
cy.get('tBody > tr').its('length').should('eq', 2);
cy.get('tBody > tr').its('length').should('eq', 3);
});
it('Should check detail for the buyer', () => {
cy.get(':nth-child(1) > .sticky > .q-btn > .q-btn__content > .q-icon').click();