forked from verdnatura/salix-front
feat: refs #7404 travel m3 form
This commit is contained in:
parent
e2dbe0fd38
commit
deb30ee955
|
@ -4,7 +4,7 @@ import { useArrayData } from 'composables/useArrayData';
|
|||
const model = defineModel({ type: Object });
|
||||
const $props = defineProps({
|
||||
name: {
|
||||
type: String,
|
||||
type: [String, Boolean],
|
||||
default: '',
|
||||
},
|
||||
label: {
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
<script setup>
|
||||
import { onMounted, ref, watch } from 'vue';
|
||||
import { ref } 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 FormModelPopup from 'components/FormModelPopup.vue';
|
||||
import VnInput from 'src/components/common/VnInput.vue';
|
||||
import VnRow from 'components/ui/VnRow.vue';
|
||||
import RightMenu from 'src/components/common/RightMenu.vue';
|
||||
import EntryStockBoughtFilter from './EntryStockBoughtFilter.vue';
|
||||
|
@ -31,7 +32,9 @@ const columns = [
|
|||
align: 'left',
|
||||
name: 'workerFk',
|
||||
label: t('Buyer'),
|
||||
isTitle: true,
|
||||
component: 'select',
|
||||
cardVisible: true,
|
||||
create: true,
|
||||
attrs: {
|
||||
url: 'Workers/activeWithInheritedRole',
|
||||
|
@ -82,6 +85,7 @@ const columns = [
|
|||
component: EntryStockBoughtDetail,
|
||||
componentProps: {
|
||||
workerFk: row.workerFk,
|
||||
dated: userParams.value.dated,
|
||||
},
|
||||
});
|
||||
},
|
||||
|
@ -91,6 +95,7 @@ const columns = [
|
|||
];
|
||||
|
||||
const fetchDataRef = ref();
|
||||
const travelDialogRef = ref(false);
|
||||
const tableRef = ref();
|
||||
const travel = ref(null);
|
||||
const userParams = ref({
|
||||
|
@ -108,38 +113,21 @@ const filter = ref({
|
|||
{
|
||||
relation: 'warehouseIn',
|
||||
scope: {
|
||||
where: { code: 'vnh' },
|
||||
fields: ['code'],
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
function getFilter(dated) {
|
||||
console.log('dated: ', dated);
|
||||
const shipped = dated ? new Date(dated) : Date.vnNew();
|
||||
shipped.setHours(0, 0, 0, 0);
|
||||
return {
|
||||
where: {
|
||||
shipped,
|
||||
m3: { neq: null },
|
||||
},
|
||||
include: [
|
||||
{
|
||||
relation: 'warehouseIn',
|
||||
scope: {
|
||||
where: { code: 'vnh' },
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
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();
|
||||
};
|
||||
|
||||
function openDialog() {
|
||||
travelDialogRef.value = true;
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<VnSubToolbar>
|
||||
|
@ -147,35 +135,55 @@ const setUserParams = async ({ dated }) => {
|
|||
<FetchData
|
||||
ref="fetchDataRef"
|
||||
url="Travels"
|
||||
limit="1"
|
||||
auto-load
|
||||
:filter="filter"
|
||||
@on-fetch="(data) => (travel = data)"
|
||||
@on-fetch="
|
||||
(data) => {
|
||||
travel = data.filter((data) => data.warehouseIn.code === 'VNH');
|
||||
}
|
||||
"
|
||||
/>
|
||||
|
||||
<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"
|
||||
/>
|
||||
<VnRow class="travel">
|
||||
<div v-if="travel">
|
||||
<span style="color: var(--vn-label-color)">
|
||||
{{ t('Booked trucks') }}:
|
||||
</span>
|
||||
<span>
|
||||
{{ t('Booked trucks') + ': ' + travel[0]?.m3 }}
|
||||
{{ travel[0]?.m3 }}
|
||||
</span>
|
||||
<QBtn
|
||||
v-if="travel[0]?.m3"
|
||||
style="max-width: 20%"
|
||||
flat
|
||||
icon="edit"
|
||||
@click="navigate(travel[0]?.id)"
|
||||
@click="openDialog()"
|
||||
:title="t('Edit travel')"
|
||||
color="primary"
|
||||
/>
|
||||
</div>
|
||||
</VnRow>
|
||||
</template>
|
||||
</VnSubToolbar>
|
||||
<QDialog v-model="travelDialogRef" :maximized="true" :class="['vn-row', 'wrap']">
|
||||
<FormModelPopup
|
||||
:url-update="`Travels/${travel[0].id}`"
|
||||
model="travel"
|
||||
:title="t('Travel m3')"
|
||||
:form-initial-data="{ id: travel[0].id, m3: travel[0].m3 }"
|
||||
@on-data-saved="fetchDataRef.fetch()"
|
||||
>
|
||||
<template #form-inputs="{ data }">
|
||||
<VnInput
|
||||
v-model="data.id"
|
||||
:label="t('id')"
|
||||
type="number"
|
||||
disable
|
||||
readonly
|
||||
/>
|
||||
<VnInput v-model="data.m3" :label="t('m3')" type="number" />
|
||||
</template>
|
||||
</FormModelPopup>
|
||||
</QDialog>
|
||||
<RightMenu>
|
||||
<template #right-panel>
|
||||
<EntryStockBoughtFilter
|
||||
|
@ -196,10 +204,7 @@ const setUserParams = async ({ dated }) => {
|
|||
:create="{
|
||||
urlCreate: 'StockBoughts',
|
||||
title: t('Reserve some space'),
|
||||
onDataSaved: () => {
|
||||
tableRef.reload();
|
||||
fetchDataRef.reload();
|
||||
},
|
||||
onDataSaved: () => tableRef.reload(),
|
||||
formInitialData: {
|
||||
workerFk: user.id,
|
||||
dated: Date.vnNow(),
|
||||
|
@ -214,17 +219,14 @@ const setUserParams = async ({ dated }) => {
|
|||
<span class="link" @click.stop>
|
||||
{{ row?.worker?.user?.name }}
|
||||
<WorkerDescriptorProxy :id="row?.workerFk" />
|
||||
</span>
|
||||
</template>
|
||||
</span> </template
|
||||
>0
|
||||
</VnTable>
|
||||
</QPage>
|
||||
</template>
|
||||
<style lang="scss">
|
||||
.trucks {
|
||||
text-align: center;
|
||||
margin: 3%;
|
||||
border: 3px solid var(--vn-header-color);
|
||||
padding: 1%;
|
||||
<style lang="css" scoped>
|
||||
.travel {
|
||||
margin-bottom: 0px;
|
||||
}
|
||||
</style>
|
||||
<i18n>
|
||||
|
|
|
@ -14,7 +14,7 @@ const $props = defineProps({
|
|||
required: true,
|
||||
},
|
||||
dated: {
|
||||
type: String,
|
||||
type: Date,
|
||||
required: true,
|
||||
},
|
||||
});
|
||||
|
@ -63,34 +63,46 @@ const columns = [
|
|||
];
|
||||
</script>
|
||||
<template>
|
||||
<QDialog>
|
||||
<VnTable
|
||||
ref="tableRef"
|
||||
data-key="StockBoughtsDetail"
|
||||
:url="customUrl"
|
||||
order="itemName DESC"
|
||||
:columns="columns"
|
||||
:right-search="false"
|
||||
:disable-infinite-scroll="true"
|
||||
:disable-option="{ card: true }"
|
||||
:limit="0"
|
||||
auto-load
|
||||
>
|
||||
<template #column-entryFk="{ row }">
|
||||
<span class="link" @click.stop>
|
||||
{{ row?.entryFk }}
|
||||
<EntryDescriptorProxy :id="row.entryFk" />
|
||||
</span>
|
||||
</template>
|
||||
<template #column-itemName="{ row }">
|
||||
<span class="link" @click.stop>
|
||||
{{ row?.itemName }}
|
||||
<ItemDescriptorProxy :id="row.itemFk" />
|
||||
</span>
|
||||
</template>
|
||||
</VnTable>
|
||||
<QDialog position="bottom" :maximized="true">
|
||||
<div class="container">
|
||||
<VnTable
|
||||
ref="tableRef"
|
||||
data-key="StockBoughtsDetail"
|
||||
:url="customUrl"
|
||||
order="itemName DESC"
|
||||
:columns="columns"
|
||||
:right-search="false"
|
||||
:disable-infinite-scroll="true"
|
||||
:disable-option="{ card: true }"
|
||||
:limit="0"
|
||||
auto-load
|
||||
>
|
||||
<template #column-entryFk="{ row }">
|
||||
<span class="link" @click.stop>
|
||||
{{ row?.entryFk }}
|
||||
<EntryDescriptorProxy :id="row.entryFk" />
|
||||
</span>
|
||||
</template>
|
||||
<template #column-itemName="{ row }">
|
||||
<span class="link" @click.stop>
|
||||
{{ row?.itemName }}
|
||||
<ItemDescriptorProxy :id="row.itemFk" />
|
||||
</span>
|
||||
</template>
|
||||
</VnTable>
|
||||
</div>
|
||||
</QDialog>
|
||||
</template>
|
||||
<style lang="css">
|
||||
.q-dialog__inner {
|
||||
max-width: 50vw;
|
||||
overflow: auto;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
margin: auto;
|
||||
}
|
||||
</style>
|
||||
<i18n>
|
||||
es:
|
||||
Buyer: Comprador
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
<script setup>
|
||||
import { ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { onMounted } from 'vue';
|
||||
import { useStateStore } from 'stores/useStateStore';
|
||||
|
||||
import VnFilterPanel from 'src/components/ui/VnFilterPanel.vue';
|
||||
import FetchData from 'components/FetchData.vue';
|
||||
import VnInputDate from 'src/components/common/VnInputDate.vue';
|
||||
|
||||
const { t } = useI18n();
|
||||
|
@ -15,7 +13,6 @@ const props = defineProps({
|
|||
required: true,
|
||||
},
|
||||
});
|
||||
const companiesOptions = ref([]);
|
||||
const stateStore = useStateStore();
|
||||
const emit = defineEmits(['set-user-params']);
|
||||
const setUserParams = (params) => {
|
||||
|
@ -27,20 +24,10 @@ onMounted(async () => {
|
|||
</script>
|
||||
|
||||
<template>
|
||||
<FetchData
|
||||
ref="buyer"
|
||||
url="Workers/activeWithInheritedRole"
|
||||
:filter="{
|
||||
fields: ['id', 'name'],
|
||||
where: { role: 'buyer' },
|
||||
}"
|
||||
order="name"
|
||||
@on-fetch="(data) => (companiesOptions = data)"
|
||||
auto-load
|
||||
/>
|
||||
<VnFilterPanel
|
||||
:data-key="props.dataKey"
|
||||
:search-button="true"
|
||||
search-url="table"
|
||||
@set-user-params="setUserParams"
|
||||
>
|
||||
<template #tags="{ tag, formatFn }">
|
||||
|
@ -52,13 +39,25 @@ onMounted(async () => {
|
|||
<template #body="{ params }">
|
||||
<QItem class="q-my-sm">
|
||||
<QItemSection>
|
||||
<VnInputDate v-model="params.dated" :label="t('Date')" is-outlined />
|
||||
<VnInputDate
|
||||
id="date"
|
||||
v-model="params.dated"
|
||||
:label="t('Date')"
|
||||
is-outlined
|
||||
/>
|
||||
</QItemSection>
|
||||
</QItem>
|
||||
</template>
|
||||
</VnFilterPanel>
|
||||
</template>
|
||||
<i18n>
|
||||
en:
|
||||
params:
|
||||
dated: Date
|
||||
workerFk: Worker
|
||||
es:
|
||||
Date: Fecha
|
||||
params:
|
||||
dated: Date
|
||||
workerFk: Trabajador
|
||||
</i18n>
|
||||
|
|
|
@ -1,15 +1,13 @@
|
|||
describe('EntryStockBought', () => {
|
||||
const reserveField = 'input[name="reserve"]';
|
||||
beforeEach(() => {
|
||||
cy.viewport(1920, 1080);
|
||||
cy.login('buyer');
|
||||
cy.visit(
|
||||
`/#/entry/stock-Bought?table={"filter":"{}","dated":"2000-12-31T23:00:00.000Z"}`
|
||||
);
|
||||
cy.visit(`/#/entry/stock-Bought`);
|
||||
});
|
||||
it('Should edit the reserved space', () => {
|
||||
cy.get('.q-field__native.q-placeholder').should('have.value', '01/01/2001');
|
||||
cy.get('tBody > tr').its('length').should('eq', 2);
|
||||
cy.get(reserveField).type('10{enter}');
|
||||
cy.get('input[name="reserve"]').type('10{enter}');
|
||||
cy.get('button[title="Save"]').click();
|
||||
cy.get('.q-notification__message').should('have.text', 'Data saved');
|
||||
});
|
||||
|
@ -33,4 +31,11 @@ describe('EntryStockBought', () => {
|
|||
'warningNo data available'
|
||||
);
|
||||
});
|
||||
it('Should edit travel m3 and refresh', () => {
|
||||
cy.get('.vn-row > div > .q-btn > .q-btn__content > .q-icon').click();
|
||||
cy.get('input[aria-label="m3"]').clear();
|
||||
cy.get('input[aria-label="m3"]').type('60');
|
||||
cy.get('.q-mt-lg > .q-btn--standard > .q-btn__content > .block').click();
|
||||
cy.get('.vn-row > div > :nth-child(2)').should('have.text', '60');
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue