0
0
Fork 0

fet: updates

This commit is contained in:
Javier Segarra 2024-09-02 11:28:13 +02:00
parent cfa5b84f4e
commit 970c8473a2
2 changed files with 52 additions and 24 deletions

View File

@ -278,6 +278,7 @@ function parseOrder(urlOrders) {
const emit = defineEmits(['onFetch', 'update:selected', 'saveChanges']); const emit = defineEmits(['onFetch', 'update:selected', 'saveChanges']);
defineExpose({ defineExpose({
create: createForm,
reload, reload,
redirect: redirectFn, redirect: redirectFn,
selected, selected,

View File

@ -68,7 +68,6 @@ const columns = computed(() => [
...defaultColumnAttrs, ...defaultColumnAttrs,
isId: true, isId: true,
cardVisible: true, cardVisible: true,
columnClass: 'shrink',
columnField: { columnField: {
component: 'input', component: 'input',
type: 'number', type: 'number',
@ -77,7 +76,6 @@ const columns = computed(() => [
{ {
label: t('globals.name'), label: t('globals.name'),
field: 'name', field: 'name',
columnClass: 'shrink',
name: 'description', name: 'description',
...defaultColumnAttrs, ...defaultColumnAttrs,
create: true, create: true,
@ -119,13 +117,14 @@ const columns = computed(() => [
cardVisible: true, cardVisible: true,
...defaultColumnAttrs, ...defaultColumnAttrs,
component: 'date', component: 'date',
columnClass: 'shrink',
}, },
{ {
label: t('item.fixedPrice.ended'), label: t('item.fixedPrice.ended'),
field: 'ended', field: 'ended',
name: 'ended', name: 'ended',
...defaultColumnAttrs, ...defaultColumnAttrs,
columnClass: 'expand', columnClass: 'shrink',
cardVisible: true, cardVisible: true,
component: 'date', component: 'date',
format: (row) => toDate(row.ended), format: (row) => toDate(row.ended),
@ -254,22 +253,49 @@ const addRow = (fixedPrice = null) => {
// fixedPrices.value.push({ ...newPrice }); // fixedPrices.value.push({ ...newPrice });
// return; // return;
// } // }
if (fixedPrice) { if (!fixedPrice) {
lastItem.value = fixedPrice; const today = Date.vnNew();
const millisecsInDay = 86400000;
const daysInWeek = 7;
const nextWeek = new Date(today.getTime() + daysInWeek * millisecsInDay);
// lastItem.value = {
lastItem.value = {
started: today,
ended: nextWeek,
hasMinPrice: 0,
};
return; return;
} }
const lastItemCopy = JSON.parse( const lastItemCopy = {
JSON.stringify(fixedPrices.value[fixedPrices.value.length - 1]) itemFk: fixedPrice.itemFk,
); name: fixedPrice.name,
lastItem.value = lastItemCopy; subName: fixedPrice.subName,
tableRef.value.create.formInitialData = lastItem; value5: fixedPrice.value5,
delete lastItemCopy.id; value6: fixedPrice.value6,
fixedPricesOriginalData.value.splice(lastvisible, 0, lastItemCopy); value7: fixedPrice.value7,
fixedPrices.value.unshift(lastItemCopy); value8: fixedPrice.value8,
nextTick(() => { value9: fixedPrice.value9,
highlightNewRow(lastvisible); value10: fixedPrice.value10,
}); warehouseFk: fixedPrice.warehouseFk,
rate2: fixedPrice.rate2,
rate3: fixedPrice.rate3,
hasMinPrice: fixedPrice.hasMinPrice,
minPrice: fixedPrice.minPrice,
started: fixedPrice.started,
ended: fixedPrice.ended,
};
// lastItem.value = lastItemCopy;
// tableRef.value.create.onDataSaved(lastItem);
return lastItemCopy;
// delete lastItemCopy.id;
// fixedPricesOriginalData.value.splice(lastvisible, 0, lastItemCopy);
// fixedPrices.value.unshift(lastItemCopy);
// nextTick(() => {
// highlightNewRow(lastvisible);
// });
}; };
const lastItem = ref(null); const lastItem = ref(null);
function highlightNewRow(index) { function highlightNewRow(index) {
@ -338,11 +364,9 @@ onMounted(async () => {
stateStore.rightDrawer = true; stateStore.rightDrawer = true;
params.warehouseFk = user.value.warehouseFk; params.warehouseFk = user.value.warehouseFk;
}); });
function handleOnDataSave(CrudModelRef) { function handleOnDataSave({ CrudModelRef }) {
addRow( const roww = addRow(CrudModelRef.formData[CrudModelRef.formData.length - 1]);
CrudModelRef.CrudModelRef.formData[CrudModelRef.CrudModelRef.formData.length - 1] CrudModelRef.formData.unshift(lastItem);
);
CrudModelRef.CrudModelRef.formData.unshift(lastItem);
nextTick(() => { nextTick(() => {
highlightNewRow(checkLastVisibleRow()); highlightNewRow(checkLastVisibleRow());
}); });
@ -426,7 +450,7 @@ onUnmounted(() => (stateStore.rightDrawer = false));
<template #column-itemId="props"> <template #column-itemId="props">
<QTd> <QTd>
<VnSelect <VnSelect
style="max-width: 125px" style="max-width: 100px"
url="Items/withName" url="Items/withName"
hide-selected hide-selected
option-label="id" option-label="id"
@ -504,7 +528,7 @@ onUnmounted(() => (stateStore.rightDrawer = false));
<template #column-started="props"> <template #column-started="props">
<QTd class="col"> <QTd class="col">
<VnInputDate <VnInputDate
style="min-width: 147px" class="vnInputDate"
:show-event="true" :show-event="true"
v-model="props.row.started" v-model="props.row.started"
v-on="getRowUpdateInputEvents(props, false, 'date')" v-on="getRowUpdateInputEvents(props, false, 'date')"
@ -522,7 +546,7 @@ onUnmounted(() => (stateStore.rightDrawer = false));
<template #column-ended="props"> <template #column-ended="props">
<QTd class="col"> <QTd class="col">
<VnInputDate <VnInputDate
style="min-width: 147px" class="vnInputDate"
:show-event="true" :show-event="true"
v-model="props.row.ended" v-model="props.row.ended"
v-on="getRowUpdateInputEvents(props, false, 'date')" v-on="getRowUpdateInputEvents(props, false, 'date')"
@ -591,6 +615,9 @@ onUnmounted(() => (stateStore.rightDrawer = false));
max-width: none; max-width: none;
.q-td.col { .q-td.col {
& .vnInputDate {
min-width: 130px;
}
& div.row { & div.row {
& .q-checkbox { & .q-checkbox {
& .q-checkbox__inner { & .q-checkbox__inner {