forked from verdnatura/salix-front
feat: refs #7404 add m3 and fix detail
This commit is contained in:
parent
74b47361c4
commit
3dc720e2d0
|
@ -90,6 +90,10 @@ const $props = defineProps({
|
|||
type: String,
|
||||
default: '90vh',
|
||||
},
|
||||
footer: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
});
|
||||
const { t } = useI18n();
|
||||
const stateStore = useStateStore();
|
||||
|
@ -108,7 +112,7 @@ const orders = ref(parseOrder(routeQuery.filter?.order));
|
|||
const CrudModelRef = ref({});
|
||||
const showForm = ref(false);
|
||||
const splittedColumns = ref({ columns: [] });
|
||||
const columnsVisibilitySkippped = ref();
|
||||
const columnsVisibilitySkipped = ref();
|
||||
const createForm = ref();
|
||||
|
||||
const tableModes = [
|
||||
|
@ -347,11 +351,11 @@ defineExpose({
|
|||
<CrudModel
|
||||
v-bind="$attrs"
|
||||
:class="$attrs['class'] ?? 'q-px-md'"
|
||||
:limit="20"
|
||||
:limit="$attrs.limit ?? 20"
|
||||
ref="CrudModelRef"
|
||||
@on-fetch="(...args) => emit('onFetch', ...args)"
|
||||
:search-url="searchUrl"
|
||||
:disable-infinite-scroll="isTableMode"
|
||||
:disable-infinite-scroll="$attrs['disable-infinite-scroll'] ?? isTableMode"
|
||||
@save-changes="reload"
|
||||
:has-sub-toolbar="$attrs['hasSubToolbar'] ?? isEditable"
|
||||
:auto-load="hasParams || $attrs['auto-load']"
|
||||
|
@ -371,7 +375,7 @@ defineExpose({
|
|||
card-container-class="grid-three"
|
||||
flat
|
||||
:style="isTableMode && `max-height: ${tableHeight}`"
|
||||
virtual-scroll
|
||||
:virtual-scroll="!isTableMode"
|
||||
@virtual-scroll="
|
||||
(event) =>
|
||||
event.index > rows.length - 2 &&
|
||||
|
@ -614,6 +618,28 @@ defineExpose({
|
|||
</QCard>
|
||||
</component>
|
||||
</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>
|
||||
</template>
|
||||
</CrudModel>
|
||||
|
@ -672,7 +698,7 @@ es:
|
|||
}
|
||||
|
||||
.bg-header {
|
||||
background-color: var(--vn-header-color);
|
||||
background-color: var(--vn-accent-color);
|
||||
color: var(--vn-text-color);
|
||||
}
|
||||
|
||||
|
|
|
@ -9,9 +9,6 @@ import RightMenu from 'src/components/common/RightMenu.vue';
|
|||
import { toDate } from 'src/filters';
|
||||
import { useSummaryDialog } from 'src/composables/useSummaryDialog';
|
||||
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 TravelDescriptorProxy from 'src/pages/Travel/Card/TravelDescriptorProxy.vue';
|
||||
|
||||
|
|
|
@ -6,24 +6,23 @@ import { useQuasar } from 'quasar';
|
|||
|
||||
import VnTable from 'components/VnTable/VnTable.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 VnSubToolbar from 'src/components/ui/VnSubToolbar.vue';
|
||||
import WorkerDescriptorProxy from 'src/pages/Worker/Card/WorkerDescriptorProxy.vue';
|
||||
import EntryStockBoughtDetail from 'src/pages/Entry/EntryStockBoughtDetail.vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
|
||||
const { t } = useI18n();
|
||||
const quasar = useQuasar();
|
||||
const tableRef = ref();
|
||||
const state = useState();
|
||||
const user = state.getUser();
|
||||
const router = useRouter();
|
||||
const columns = [
|
||||
{
|
||||
align: 'left',
|
||||
label: 'Id',
|
||||
name: 'id',
|
||||
isTitle: true,
|
||||
isId: true,
|
||||
columnFilter: false,
|
||||
visible: false,
|
||||
|
@ -32,6 +31,7 @@ const columns = [
|
|||
align: 'left',
|
||||
name: 'workerFk',
|
||||
label: t('Buyer'),
|
||||
isTitle: true,
|
||||
columnFilter: false,
|
||||
},
|
||||
{
|
||||
|
@ -42,6 +42,7 @@ const columns = [
|
|||
create: true,
|
||||
component: 'number',
|
||||
summation: true,
|
||||
cardVisible: true,
|
||||
},
|
||||
{
|
||||
align: 'left',
|
||||
|
@ -67,6 +68,7 @@ const columns = [
|
|||
name: 'bought',
|
||||
columnFilter: false,
|
||||
summation: true,
|
||||
cardVisible: true,
|
||||
},
|
||||
{
|
||||
align: 'left',
|
||||
|
@ -89,7 +91,6 @@ const columns = [
|
|||
component: EntryStockBoughtDetail,
|
||||
componentProps: {
|
||||
workerFk: row.workerFk,
|
||||
dated: row.dated,
|
||||
},
|
||||
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 {
|
||||
fields: ['id', 'm3'],
|
||||
where: { dated },
|
||||
where: {
|
||||
shipped,
|
||||
m3: { neq: null },
|
||||
},
|
||||
include: [
|
||||
{
|
||||
relation: 'warehouseIn',
|
||||
where: { code: 'vnh' },
|
||||
},
|
||||
],
|
||||
};
|
||||
|
@ -116,6 +124,7 @@ const fetchDataRef = ref();
|
|||
</script>
|
||||
<template>
|
||||
<VnSubToolbar />
|
||||
<QPage class="column items-center q-pa-md">
|
||||
<VnTable
|
||||
ref="tableRef"
|
||||
data-key="StockBoughts"
|
||||
|
@ -123,7 +132,6 @@ const fetchDataRef = ref();
|
|||
save-url="StockBoughts/crud"
|
||||
order="reserve DESC"
|
||||
:is-editable="true"
|
||||
:disable-option="{ card: true }"
|
||||
:create="{
|
||||
urlCreate: 'StockBoughts',
|
||||
title: t('Reserve some space'),
|
||||
|
@ -135,7 +143,9 @@ const fetchDataRef = ref();
|
|||
}"
|
||||
:columns="columns"
|
||||
auto-load
|
||||
@on-fetch="() => fetchDataRef.fetch()"
|
||||
@on-fetch="() => console.log('fetching...', fetchDataRef.fetch())"
|
||||
style="max-width: 40%"
|
||||
:footer="true"
|
||||
>
|
||||
<template #moreFilterPanel="{ params }">
|
||||
<FetchData
|
||||
|
@ -143,13 +153,27 @@ const fetchDataRef = ref();
|
|||
url="Travels"
|
||||
limit="1"
|
||||
auto-load
|
||||
:filter="getFilter(params?.date)"
|
||||
:filter="getFilter(params?.dated)"
|
||||
@on-fetch="(data) => (travel = data)"
|
||||
/>
|
||||
<VnRow class="q-pa-md" style="align-items: center" v-if="travel?.length">
|
||||
<span>{{ t('Booked trucks: ') + travel[0]?.m3 }}</span>
|
||||
<QBtn style="max-width: 20%" flat icon="edit" />
|
||||
</VnRow>
|
||||
<div class="trucks">
|
||||
<div>
|
||||
<span style="color: var(--vn-label-color)">
|
||||
{{ t('Booked trucks') + ': ' }}
|
||||
</span>
|
||||
</div>
|
||||
<div v-if="travel">
|
||||
<span>
|
||||
{{ travel[0]?.m3 }}
|
||||
</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>
|
||||
|
@ -158,7 +182,16 @@ const fetchDataRef = ref();
|
|||
</span>
|
||||
</template>
|
||||
</VnTable>
|
||||
</QPage>
|
||||
</template>
|
||||
<style lang="scss">
|
||||
.trucks {
|
||||
text-align: center;
|
||||
margin: 3%;
|
||||
border: 3px solid var(--vn-header-color);
|
||||
padding: 1%;
|
||||
}
|
||||
</style>
|
||||
<i18n>
|
||||
en:
|
||||
Buyer: Buyer
|
||||
|
@ -168,6 +201,7 @@ const fetchDataRef = ref();
|
|||
Date: Date
|
||||
This buyer has already made a reservation for this date: This buyer has already made a reservation for this date
|
||||
es:
|
||||
Booked trucks: Camiones reservados
|
||||
Buyer: Comprador
|
||||
Reserve: Reservado
|
||||
Bought: Comprado
|
||||
|
|
|
@ -18,7 +18,7 @@ const $props = defineProps({
|
|||
required: true,
|
||||
},
|
||||
});
|
||||
const customUrl = `StockBoughts/getStockBoughtDetail?workerFk=${$props.workerFk}`;
|
||||
const customUrl = `StockBoughts/getStockBoughtDetail?workerFk=${$props.workerFk}&date=${$props.dated}`;
|
||||
const columns = [
|
||||
{
|
||||
align: 'left',
|
||||
|
|
|
@ -8,7 +8,7 @@ describe('EntryStockBought', () => {
|
|||
);
|
||||
});
|
||||
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('button[title="Save"]').click();
|
||||
cy.get('.q-notification__message').should('have.text', 'Data saved');
|
||||
|
|
Loading…
Reference in New Issue