0
0
Fork 0

feat: refs #7404 add m3 and fix detail

This commit is contained in:
Pablo Natek 2024-09-04 14:40:36 +02:00
parent 74b47361c4
commit 3dc720e2d0
5 changed files with 118 additions and 61 deletions

View File

@ -90,6 +90,10 @@ const $props = defineProps({
type: String, type: String,
default: '90vh', default: '90vh',
}, },
footer: {
type: Boolean,
default: false,
},
}); });
const { t } = useI18n(); const { t } = useI18n();
const stateStore = useStateStore(); const stateStore = useStateStore();
@ -108,7 +112,7 @@ const orders = ref(parseOrder(routeQuery.filter?.order));
const CrudModelRef = ref({}); const CrudModelRef = ref({});
const showForm = ref(false); const showForm = ref(false);
const splittedColumns = ref({ columns: [] }); const splittedColumns = ref({ columns: [] });
const columnsVisibilitySkippped = ref(); const columnsVisibilitySkipped = ref();
const createForm = ref(); const createForm = ref();
const tableModes = [ const tableModes = [
@ -347,11 +351,11 @@ defineExpose({
<CrudModel <CrudModel
v-bind="$attrs" v-bind="$attrs"
:class="$attrs['class'] ?? 'q-px-md'" :class="$attrs['class'] ?? 'q-px-md'"
:limit="20" :limit="$attrs.limit ?? 20"
ref="CrudModelRef" ref="CrudModelRef"
@on-fetch="(...args) => emit('onFetch', ...args)" @on-fetch="(...args) => emit('onFetch', ...args)"
:search-url="searchUrl" :search-url="searchUrl"
:disable-infinite-scroll="isTableMode" :disable-infinite-scroll="$attrs['disable-infinite-scroll'] ?? isTableMode"
@save-changes="reload" @save-changes="reload"
:has-sub-toolbar="$attrs['hasSubToolbar'] ?? isEditable" :has-sub-toolbar="$attrs['hasSubToolbar'] ?? isEditable"
:auto-load="hasParams || $attrs['auto-load']" :auto-load="hasParams || $attrs['auto-load']"
@ -371,7 +375,7 @@ defineExpose({
card-container-class="grid-three" card-container-class="grid-three"
flat flat
:style="isTableMode && `max-height: ${tableHeight}`" :style="isTableMode && `max-height: ${tableHeight}`"
virtual-scroll :virtual-scroll="!isTableMode"
@virtual-scroll=" @virtual-scroll="
(event) => (event) =>
event.index > rows.length - 2 && event.index > rows.length - 2 &&
@ -614,6 +618,28 @@ defineExpose({
</QCard> </QCard>
</component> </component>
</template> </template>
<template #bottom-row="{ cols }" v-if="footer">
<QTr v-if="rows.length" class="bg-header" style="height: 30px">
<QTh
v-for="col of cols.filter((cols) => cols.visible ?? true)"
:key="col?.id"
class="text-center"
>
<div
v-if="col?.summation"
:class="`text-${col?.align ?? 'left'}`"
class="text-bold q-pa-sm"
>
{{
rows.reduce(
(sum, currentRow) => sum + currentRow[col.name],
0
)
}}
</div>
</QTh>
</QTr>
</template>
</QTable> </QTable>
</template> </template>
</CrudModel> </CrudModel>
@ -672,7 +698,7 @@ es:
} }
.bg-header { .bg-header {
background-color: var(--vn-header-color); background-color: var(--vn-accent-color);
color: var(--vn-text-color); color: var(--vn-text-color);
} }

View File

@ -9,9 +9,6 @@ import RightMenu from 'src/components/common/RightMenu.vue';
import { toDate } from 'src/filters'; import { toDate } from 'src/filters';
import { useSummaryDialog } from 'src/composables/useSummaryDialog'; import { useSummaryDialog } from 'src/composables/useSummaryDialog';
import EntrySummary from './Card/EntrySummary.vue'; import EntrySummary from './Card/EntrySummary.vue';
import VnUserLink from 'components/ui/VnUserLink.vue';
import WorkerDescriptorProxy from 'src/pages/Worker/Card/WorkerDescriptorProxy.vue';
import CustomerDescriptorProxy from '../Customer/Card/CustomerDescriptorProxy.vue';
import SupplierDescriptorProxy from 'src/pages/Supplier/Card/SupplierDescriptorProxy.vue'; import SupplierDescriptorProxy from 'src/pages/Supplier/Card/SupplierDescriptorProxy.vue';
import TravelDescriptorProxy from 'src/pages/Travel/Card/TravelDescriptorProxy.vue'; import TravelDescriptorProxy from 'src/pages/Travel/Card/TravelDescriptorProxy.vue';

View File

@ -6,24 +6,23 @@ import { useQuasar } from 'quasar';
import VnTable from 'components/VnTable/VnTable.vue'; import VnTable from 'components/VnTable/VnTable.vue';
import VnRow from 'src/components/ui/VnRow.vue'; import VnRow from 'src/components/ui/VnRow.vue';
import VnInput from 'src/components/common/VnInput.vue';
import VnLv from 'src/components/ui/VnLv.vue';
import FetchData from 'src/components/FetchData.vue'; import FetchData from 'src/components/FetchData.vue';
import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue'; import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue';
import WorkerDescriptorProxy from 'src/pages/Worker/Card/WorkerDescriptorProxy.vue'; import WorkerDescriptorProxy from 'src/pages/Worker/Card/WorkerDescriptorProxy.vue';
import EntryStockBoughtDetail from 'src/pages/Entry/EntryStockBoughtDetail.vue'; import EntryStockBoughtDetail from 'src/pages/Entry/EntryStockBoughtDetail.vue';
import { useRouter } from 'vue-router';
const { t } = useI18n(); const { t } = useI18n();
const quasar = useQuasar(); const quasar = useQuasar();
const tableRef = ref(); const tableRef = ref();
const state = useState(); const state = useState();
const user = state.getUser(); const user = state.getUser();
const router = useRouter();
const columns = [ const columns = [
{ {
align: 'left', align: 'left',
label: 'Id', label: 'Id',
name: 'id', name: 'id',
isTitle: true,
isId: true, isId: true,
columnFilter: false, columnFilter: false,
visible: false, visible: false,
@ -32,6 +31,7 @@ const columns = [
align: 'left', align: 'left',
name: 'workerFk', name: 'workerFk',
label: t('Buyer'), label: t('Buyer'),
isTitle: true,
columnFilter: false, columnFilter: false,
}, },
{ {
@ -42,6 +42,7 @@ const columns = [
create: true, create: true,
component: 'number', component: 'number',
summation: true, summation: true,
cardVisible: true,
}, },
{ {
align: 'left', align: 'left',
@ -67,6 +68,7 @@ const columns = [
name: 'bought', name: 'bought',
columnFilter: false, columnFilter: false,
summation: true, summation: true,
cardVisible: true,
}, },
{ {
align: 'left', align: 'left',
@ -89,7 +91,6 @@ const columns = [
component: EntryStockBoughtDetail, component: EntryStockBoughtDetail,
componentProps: { componentProps: {
workerFk: row.workerFk, workerFk: row.workerFk,
dated: row.dated,
}, },
maximized: true, maximized: true,
}); });
@ -98,15 +99,22 @@ const columns = [
], ],
}, },
]; ];
function getFilter(dated = Date.vnNow()) {
console.log('dated: ', new Date(dated * 1000)); function navigate(id) {
router.push({ path: `/travel/${id}/basic-data` });
}
function getFilter(dated) {
const shipped = dated ? new Date(dated) : Date.vnNew();
shipped.setHours(0, 0, 0, 0);
return { return {
fields: ['id', 'm3'], where: {
where: { dated }, shipped,
m3: { neq: null },
},
include: [ include: [
{ {
relation: 'warehouseIn', relation: 'warehouseIn',
where: { code: 'vnh' },
}, },
], ],
}; };
@ -116,49 +124,74 @@ const fetchDataRef = ref();
</script> </script>
<template> <template>
<VnSubToolbar /> <VnSubToolbar />
<VnTable <QPage class="column items-center q-pa-md">
ref="tableRef" <VnTable
data-key="StockBoughts" ref="tableRef"
url="StockBoughts/getStockBought" data-key="StockBoughts"
save-url="StockBoughts/crud" url="StockBoughts/getStockBought"
order="reserve DESC" save-url="StockBoughts/crud"
:is-editable="true" order="reserve DESC"
:disable-option="{ card: true }" :is-editable="true"
:create="{ :create="{
urlCreate: 'StockBoughts', urlCreate: 'StockBoughts',
title: t('Reserve some space'), title: t('Reserve some space'),
onDataSaved: () => tableRef.reload(), onDataSaved: () => tableRef.reload(),
formInitialData: { formInitialData: {
workerFk: user.id, workerFk: user.id,
dated: Date.vnNow(), dated: Date.vnNow(),
}, },
}" }"
:columns="columns" :columns="columns"
auto-load auto-load
@on-fetch="() => fetchDataRef.fetch()" @on-fetch="() => console.log('fetching...', fetchDataRef.fetch())"
> style="max-width: 40%"
<template #moreFilterPanel="{ params }"> :footer="true"
<FetchData >
ref="fetchDataRef" <template #moreFilterPanel="{ params }">
url="Travels" <FetchData
limit="1" ref="fetchDataRef"
auto-load url="Travels"
:filter="getFilter(params?.date)" limit="1"
@on-fetch="(data) => (travel = data)" auto-load
/> :filter="getFilter(params?.dated)"
<VnRow class="q-pa-md" style="align-items: center" v-if="travel?.length"> @on-fetch="(data) => (travel = data)"
<span>{{ t('Booked trucks: ') + travel[0]?.m3 }}</span> />
<QBtn style="max-width: 20%" flat icon="edit" /> <div class="trucks">
</VnRow> <div>
</template> <span style="color: var(--vn-label-color)">
<template #column-workerFk="{ row }"> {{ t('Booked trucks') + ': ' }}
<span class="link" @click.stop> </span>
{{ row?.worker?.user?.name }} </div>
<WorkerDescriptorProxy :id="row?.workerFk" /> <div v-if="travel">
</span> <span>
</template> {{ travel[0]?.m3 }}
</VnTable> </span>
<QBtn
style="max-width: 20%"
flat
icon="edit"
@click="navigate(travel[0]?.id)"
/>
</div>
</div>
</template>
<template #column-workerFk="{ row }">
<span class="link" @click.stop>
{{ row?.worker?.user?.name }}
<WorkerDescriptorProxy :id="row?.workerFk" />
</span>
</template>
</VnTable>
</QPage>
</template> </template>
<style lang="scss">
.trucks {
text-align: center;
margin: 3%;
border: 3px solid var(--vn-header-color);
padding: 1%;
}
</style>
<i18n> <i18n>
en: en:
Buyer: Buyer Buyer: Buyer
@ -168,6 +201,7 @@ const fetchDataRef = ref();
Date: Date Date: Date
This buyer has already made a reservation for this date: This buyer has already made a reservation for this date This buyer has already made a reservation for this date: This buyer has already made a reservation for this date
es: es:
Booked trucks: Camiones reservados
Buyer: Comprador Buyer: Comprador
Reserve: Reservado Reserve: Reservado
Bought: Comprado Bought: Comprado

View File

@ -18,7 +18,7 @@ const $props = defineProps({
required: true, required: true,
}, },
}); });
const customUrl = `StockBoughts/getStockBoughtDetail?workerFk=${$props.workerFk}`; const customUrl = `StockBoughts/getStockBoughtDetail?workerFk=${$props.workerFk}&date=${$props.dated}`;
const columns = [ const columns = [
{ {
align: 'left', align: 'left',

View File

@ -8,7 +8,7 @@ describe('EntryStockBought', () => {
); );
}); });
it('Should edit the reserved space', () => { it('Should edit the reserved space', () => {
cy.get('tBody > tr').its('length').should('eq', 1); cy.get('tBody > tr').its('length').should('eq', 2);
cy.get(reserveField).type('10{enter}'); cy.get(reserveField).type('10{enter}');
cy.get('button[title="Save"]').click(); cy.get('button[title="Save"]').click();
cy.get('.q-notification__message').should('have.text', 'Data saved'); cy.get('.q-notification__message').should('have.text', 'Data saved');