Compare commits
18 Commits
dev
...
8944-Fixed
Author | SHA1 | Date |
---|---|---|
|
91c165a3d8 | |
|
1a6fd22b94 | |
|
701af0d9b8 | |
|
aba3e14f1b | |
|
b490dac628 | |
|
81c5f78751 | |
|
42e2721ea1 | |
|
5523362175 | |
|
c5f6e9dca1 | |
|
59f6946d8b | |
|
0c7a4c7cae | |
|
458758489b | |
|
a71f383996 | |
|
1d0febaa22 | |
|
4e172fc995 | |
|
5a36859f05 | |
|
5c719f22e0 | |
|
c679b77bbd |
|
@ -102,6 +102,10 @@ const $props = defineProps({
|
|||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
customMethod: {
|
||||
type: String,
|
||||
default: null,
|
||||
},
|
||||
});
|
||||
const emit = defineEmits(['onFetch', 'onDataSaved', 'submit']);
|
||||
const modelValue = computed(
|
||||
|
@ -237,7 +241,9 @@ async function save() {
|
|||
const url =
|
||||
$props.urlCreate || $props.urlUpdate || $props.url || arrayData.store.url;
|
||||
const response = await Promise.resolve(
|
||||
$props.saveFn ? $props.saveFn(body) : axios[method](url, body),
|
||||
$props.saveFn
|
||||
? $props.saveFn(body)
|
||||
: axios[$props.customMethod ?? method](url, body),
|
||||
);
|
||||
|
||||
if ($props.urlCreate) notify('globals.dataCreated', 'positive');
|
||||
|
|
|
@ -896,6 +896,7 @@ components:
|
|||
rate3: Packing price
|
||||
minPrice: Min. Price
|
||||
itemFk: Item id
|
||||
dated: Date
|
||||
userPanel:
|
||||
copyToken: Token copied to clipboard
|
||||
settings: Settings
|
||||
|
|
|
@ -980,6 +980,7 @@ components:
|
|||
rate3: Precio packing
|
||||
minPrice: Precio mínimo
|
||||
itemFk: Id item
|
||||
dated: Fecha
|
||||
userPanel:
|
||||
copyToken: Token copiado al portapapeles
|
||||
settings: Configuración
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
<script setup>
|
||||
import { onMounted, ref, onUnmounted, computed, watch } from 'vue';
|
||||
import axios from 'axios';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useQuasar } from 'quasar';
|
||||
|
||||
import { useStateStore } from 'stores/useStateStore';
|
||||
import { useState } from 'src/composables/useState';
|
||||
|
||||
import { beforeSave } from 'src/composables/updateMinPriceBeforeSave';
|
||||
|
||||
import FetchedTags from 'components/ui/FetchedTags.vue';
|
||||
|
@ -14,13 +16,13 @@ import RightMenu from 'src/components/common/RightMenu.vue';
|
|||
import VnTable from 'src/components/VnTable/VnTable.vue';
|
||||
import VnColor from 'src/components/common/VnColor.vue';
|
||||
|
||||
import { toDate } from 'src/filters';
|
||||
import { toDate, toCurrency } from 'src/filters';
|
||||
import { isLower, isBigger } from 'src/filters/date.js';
|
||||
import ItemFixedPriceFilter from './ItemFixedPriceFilter.vue';
|
||||
import ItemDescriptorProxy from './Card/ItemDescriptorProxy.vue';
|
||||
import { toCurrency } from 'src/filters';
|
||||
|
||||
const stateStore = useStateStore();
|
||||
const quasar = useQuasar();
|
||||
const { t } = useI18n();
|
||||
const tableRef = ref();
|
||||
const editFixedPriceForm = ref(null);
|
||||
|
@ -218,11 +220,36 @@ const dateStyle = (date) =>
|
|||
}
|
||||
: { color: dateColor, 'background-color': 'transparent' };
|
||||
|
||||
const onDataSaved = () => {
|
||||
tableRef.value.CrudModelRef.saveChanges();
|
||||
const onDataSaved = async (data) => {
|
||||
for (const row of data) {
|
||||
await axios.patch('FixedPrices/upsertFixedPrice', row);
|
||||
}
|
||||
selectedRows.value = [];
|
||||
tableRef.value.reload();
|
||||
tableRef.value.CrudModelRef.reset();
|
||||
};
|
||||
|
||||
async function saveData(data, getChanges) {
|
||||
const changes = getChanges();
|
||||
if (changes?.updates?.length) {
|
||||
for (const change of changes.updates) {
|
||||
const row = data.find((row) => row.id === change.where.id);
|
||||
await axios.patch('FixedPrices/upsertFixedPrice', row);
|
||||
}
|
||||
}
|
||||
|
||||
if (data?.deletes?.length) {
|
||||
for (const deleteItem of data.deletes) {
|
||||
await axios.delete(`FixedPrices/${deleteItem}`);
|
||||
quasar.notify({
|
||||
message: t('globals.dataDeleted'),
|
||||
color: 'positive',
|
||||
});
|
||||
}
|
||||
}
|
||||
tableRef.value.reload();
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
if (tableRef.value) {
|
||||
tableRef.value.showForm = false;
|
||||
|
@ -273,7 +300,8 @@ watch(
|
|||
data-key="ItemFixedPrices"
|
||||
url="FixedPrices/filter"
|
||||
:order="'name DESC'"
|
||||
save-url="FixedPrices/crud"
|
||||
save-url="FixedPrices/upsertFixedPrice"
|
||||
:saveFn="saveData"
|
||||
:columns="columns"
|
||||
:is-editable="true"
|
||||
:right-search="false"
|
||||
|
@ -283,7 +311,8 @@ watch(
|
|||
}"
|
||||
v-model:selected="selectedRows"
|
||||
:create="{
|
||||
urlCreate: 'FixedPrices',
|
||||
urlCreate: 'FixedPrices/upsertFixedPrice',
|
||||
customMethod: 'patch',
|
||||
title: t('Create fixed price'),
|
||||
formInitialData: { warehouseFk: warehouse },
|
||||
onDataSaved: () => tableRef.reload(),
|
||||
|
|
|
@ -3,6 +3,7 @@ import { useI18n } from 'vue-i18n';
|
|||
|
||||
import VnInputDate from 'src/components/common/VnInputDate.vue';
|
||||
import VnSelect from 'components/common/VnSelect.vue';
|
||||
import VnCheckbox from 'src/components/common/VnCheckbox.vue';
|
||||
import ItemsFilterPanel from 'src/components/ItemsFilterPanel.vue';
|
||||
|
||||
const { t } = useI18n();
|
||||
|
@ -51,42 +52,41 @@ const props = defineProps({
|
|||
/>
|
||||
</QItemSection>
|
||||
</QItem>
|
||||
<QSeparator />
|
||||
<QItemSection>
|
||||
<QIcon name="info" size="sm" class="info-icon cursor-pointer">
|
||||
<QTooltip>{{ t('params.incompatibleFilters') }}</QTooltip>
|
||||
</QIcon>
|
||||
<QItem>
|
||||
<QItemSection>
|
||||
<VnInputDate
|
||||
v-model="params.dated"
|
||||
:label="t('params.date')"
|
||||
filled
|
||||
/>
|
||||
</QItemSection>
|
||||
</QItem>
|
||||
<QItem>
|
||||
<QItemSection>
|
||||
<VnCheckbox
|
||||
v-model="params.showBadDates"
|
||||
:label="t(`params.showBadDates`)"
|
||||
toggle-indeterminate
|
||||
@update:model-value="searchFn()"
|
||||
/>
|
||||
</QItemSection>
|
||||
</QItem>
|
||||
</QItemSection>
|
||||
<QSeparator />
|
||||
<QItem>
|
||||
<QItemSection>
|
||||
<VnInputDate
|
||||
v-model="params.started"
|
||||
:label="t('params.started')"
|
||||
filled
|
||||
@update:model-value="searchFn()"
|
||||
/>
|
||||
</QItemSection>
|
||||
<QItemSection>
|
||||
<VnInputDate
|
||||
v-model="params.ended"
|
||||
:label="t('params.ended')"
|
||||
filled
|
||||
@update:model-value="searchFn()"
|
||||
/>
|
||||
</QItemSection>
|
||||
</QItem>
|
||||
<QItem>
|
||||
<QItemSection>
|
||||
<QCheckbox
|
||||
<VnCheckbox
|
||||
:label="t('params.mine')"
|
||||
v-model="params.mine"
|
||||
toggle-indeterminate
|
||||
@update:model-value="searchFn()"
|
||||
/>
|
||||
|
||||
<QCheckbox
|
||||
v-model="params.showBadDates"
|
||||
:label="t(`params.showBadDates`)"
|
||||
toggle-indeterminate
|
||||
@update:model-value="searchFn()"
|
||||
>
|
||||
</QCheckbox>
|
||||
|
||||
<QCheckbox
|
||||
<VnCheckbox
|
||||
:label="t('params.hasMinPrice')"
|
||||
v-model="params.hasMinPrice"
|
||||
toggle-indeterminate
|
||||
|
@ -97,6 +97,13 @@ const props = defineProps({
|
|||
</template>
|
||||
</ItemsFilterPanel>
|
||||
</template>
|
||||
<style lang="scss" scoped>
|
||||
.info-icon {
|
||||
position: relative;
|
||||
top: 0;
|
||||
left: 90%;
|
||||
}
|
||||
</style>
|
||||
<i18n>
|
||||
en:
|
||||
params:
|
||||
|
@ -107,6 +114,8 @@ en:
|
|||
mine: Mine
|
||||
showBadDates: Show future items
|
||||
hasMinPrice: Has Min Price
|
||||
date: Date
|
||||
incompatibleFilters: Cannot select "Date" and "Show future items" at the same time
|
||||
es:
|
||||
params:
|
||||
buyerFk: Comprador
|
||||
|
@ -116,4 +125,6 @@ es:
|
|||
mine: Para mi
|
||||
showBadDates: Ver items a futuro
|
||||
hasMinPrice: Precio mínimo
|
||||
date: Fecha
|
||||
incompatibleFilters: No se puede seleccionar "Fecha" y "Ver items a futuro" a la vez
|
||||
</i18n>
|
||||
|
|
|
@ -26,7 +26,6 @@ const $props = defineProps({
|
|||
default: () => {},
|
||||
},
|
||||
});
|
||||
|
||||
const { t } = useI18n();
|
||||
const emit = defineEmits(['onDataSaved']);
|
||||
|
||||
|
@ -38,7 +37,7 @@ const inputs = {
|
|||
select: markRaw(VnSelect),
|
||||
};
|
||||
|
||||
const newValue = ref(null);
|
||||
const newFieldValue = ref(null);
|
||||
const selectedField = ref(null);
|
||||
const closeButton = ref(null);
|
||||
const isLoading = ref(false);
|
||||
|
@ -46,7 +45,11 @@ const isLoading = ref(false);
|
|||
const onSubmit = async () => {
|
||||
isLoading.value = true;
|
||||
$props.rows.forEach((row) => {
|
||||
row[selectedField.value.name] = newValue.value;
|
||||
const newValue =
|
||||
selectedField.value.component === 'number'
|
||||
? parseInt(newFieldValue.value)
|
||||
: newFieldValue.value;
|
||||
row[selectedField.value.name] = newValue;
|
||||
});
|
||||
emit('onDataSaved', $props.rows);
|
||||
closeForm();
|
||||
|
@ -77,11 +80,19 @@ const closeForm = () => {
|
|||
data-cy="EditFixedPriceSelectOption"
|
||||
@update:model-value="newValue = null"
|
||||
:class="{ 'is-select': selectedField?.component === 'select' }"
|
||||
/>
|
||||
>
|
||||
<template #option="{ opt, itemProps }">
|
||||
<QItem v-bind="itemProps" class="q-pa-xs row items-center">
|
||||
<QItemSection class="col-9 justify-center">
|
||||
<span>{{ opt?.label }}</span>
|
||||
</QItemSection>
|
||||
</QItem>
|
||||
</template>
|
||||
</VnSelect>
|
||||
<component
|
||||
:is="inputs[selectedField?.component || 'input']"
|
||||
v-bind="selectedField?.attrs || {}"
|
||||
v-model="newValue"
|
||||
v-model="newFieldValue"
|
||||
:label="t('Value')"
|
||||
data-cy="EditFixedPriceValueOption"
|
||||
style="width: 200px"
|
||||
|
|
Loading…
Reference in New Issue