7983-testToMaster_2438 #718

Merged
alexm merged 353 commits from 7983-testToMaster_2438 into master 2024-09-17 05:39:39 +00:00
2 changed files with 101 additions and 114 deletions
Showing only changes of commit f4f8e83fea - Show all commits

View File

@ -296,6 +296,7 @@ defineExpose({
reload,
redirect: redirectFn,
selected,
CrudModelRef,
});
function handleOnDataSaved(_, res) {

View File

@ -212,15 +212,6 @@ const editTableFieldsOptions = [
type: 'number',
},
},
{
field: 'hasMinPrice',
label: t('item.fixedPrice.hasMinPrice'),
component: 'checkbox',
attrs: {
'false-value': 0,
'true-value': 1,
},
},
{
field: 'started',
label: t('item.fixedPrice.started'),
@ -262,10 +253,13 @@ const updateMinPrice = async (value, props) => {
});
};
const upsertPrice = async ({ row }, resetMinPrice = false) => {
const upsertPrice = async (props, resetMinPrice = false) => {
try {
const { row } = props;
if (tableRef.value.CrudModelRef.getChanges().updates.length > 0) {
if (resetMinPrice) row.hasMinPrice = 0;
row = await upsertFixedPrice(row);
await upsertFixedPrice(row);
}
} catch (err) {
console.error('Error editing price', err);
}
@ -283,8 +277,7 @@ async function upsertFixedPrice(row) {
async function saveOnRowChange(row) {
if (rowsSelected.value.length > 1) return;
if (rowsSelected.value[0]?.id === row.id) return;
else if (rowsSelected.value.length === 1)
await upsertFixedPrice(rowsSelected.value[0]);
else if (rowsSelected.value.length === 1) await upsertPrice(rowsSelected.value[0]);
rowsSelected.value = [row];
}
@ -454,12 +447,18 @@ function handleOnDataSave({ CrudModelRef }) {
</VnSubToolbar>
<QPage>
<VnTable
@on-fetch="
(data) =>
data.forEach((item) => {
item.hasMinPrice = `${item.hasMinPrice !== 0}`;
})
"
:default-remove="false"
:default-reset="false"
:default-save="false"
data-key="ItemFixedPrices"
url="FixedPrices/filter"
:order="['name ASC', 'itemFk DESC']"
:order="['itemFk ASC']"
save-url="FixedPrices/crud"
:user-params="{ warehouseFk: user.warehouseFk }"
ref="tableRef"
@ -494,7 +493,6 @@ function handleOnDataSave({ CrudModelRef }) {
</template>
<template #column-itemId="props">
<QTd>
<VnSelect
style="max-width: 100px"
url="Items/withName"
@ -513,22 +511,16 @@ function handleOnDataSave({ CrudModelRef }) {
</QItem>
</template>
</VnSelect>
</QTd>
</template>
<template #column-description="{ row }">
<QTd class="col">
<span class="link">
{{ row.name }}
</span>
<span class="subName">{{ row.subName }}</span>
<ItemDescriptorProxy :id="row.itemFk" />
<FetchedTags
style="width: max-content; max-width: 220px"
:item="row"
/>
</QTd>
<FetchedTags style="width: max-content; max-width: 220px" :item="row" />
</template>
<template #column-rate2="props">
<QTd class="col">
<VnInput
mask="###.##"
v-model.number="props.row.rate2"
@ -536,10 +528,8 @@ function handleOnDataSave({ CrudModelRef }) {
>
<template #append></template>
</VnInput>
</QTd>
</template>
<template #column-rate3="props">
<QTd class="col">
<VnInput
mask="###.##"
v-model.number="props.row.rate3"
@ -547,7 +537,6 @@ function handleOnDataSave({ CrudModelRef }) {
>
<template #append></template>
</VnInput>
</QTd>
</template>
<template #column-minPrice="props">
<QTd class="col">
@ -555,12 +544,11 @@ function handleOnDataSave({ CrudModelRef }) {
<QCheckbox
:model-value="props.row.hasMinPrice"
@update:model-value="updateMinPrice($event, props)"
:false-value="0"
:true-value="1"
:false-value="'false'"
:true-value="'true'"
/>
<VnInput
class="col"
mask="###.##"
:disable="props.row.hasMinPrice === 1"
v-model.number="props.row.minPrice"
v-on="getRowUpdateInputEvents(props)"
@ -571,7 +559,6 @@ function handleOnDataSave({ CrudModelRef }) {
</QTd>
</template>
<template #column-started="props">
<QTd class="col">
<VnInputDate
class="vnInputDate"
:show-event="true"
@ -579,21 +566,17 @@ function handleOnDataSave({ CrudModelRef }) {
v-on="getRowUpdateInputEvents(props, false, 'date')"
v-bind="dateStyle(isBigger(props.row.started))"
/>
</QTd>
</template>
<template #column-ended="props">
<QTd class="col">
<VnInputDate
class="vnInputDate"
:show-event="true"
v-model="props.row.ended"
v-on="getRowUpdateInputEvents(props, false, 'date')"
v-bind="dateStyle(isLower(props.row.started))"
v-bind="dateStyle(isLower(props.row.ended))"
/>
</QTd>
</template>
<template #column-warehouseFk="props">
<QTd class="col">
<VnSelect
style="max-width: 150px"
:options="warehousesOptions"
@ -603,10 +586,8 @@ function handleOnDataSave({ CrudModelRef }) {
v-model="props.row.warehouseFk"
v-on="getRowUpdateInputEvents(props, false, 'select')"
/>
</QTd>
</template>
<template #column-deleteAction="{ row, rowIndex }">
<QTd class="col">
<QIcon
name="delete"
size="sm"
@ -624,7 +605,6 @@ function handleOnDataSave({ CrudModelRef }) {
{{ t('globals.delete') }}
</QTooltip>
</QIcon>
</QTd>
</template>
</VnTable>
@ -679,6 +659,12 @@ tbody tr.highlight .q-td {
background-color: transparent;
}
}
.subName {
margin-left: 5%;
font-size: 0.75rem;
text-transform: uppercase;
color: var(--vn-label-color);
}
</style>
<i18n>
es: