0
0
Fork 0

fix: editTableOptions

This commit is contained in:
Javier Segarra 2024-09-06 14:47:29 +02:00
parent 31b8088b5f
commit 3276548f88
1 changed files with 64 additions and 15 deletions

View File

@ -180,6 +180,61 @@ const columns = computed(() => [
}, },
]); ]);
const editTableFieldsOptions = [
{
field: 'rate2',
label: t('item.fixedPrice.groupingPrice'),
component: 'input',
attrs: {
type: 'number',
},
},
{
field: 'rate3',
label: t('item.fixedPrice.packingPrice'),
component: 'input',
attrs: {
type: 'number',
},
},
{
field: 'minPrice',
label: t('item.fixedPrice.minPrice'),
component: 'input',
attrs: {
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'),
component: 'date',
},
{
field: 'ended',
label: t('item.fixedPrice.ended'),
component: 'date',
},
{
field: 'warehouseFk',
label: t('item.fixedPrice.warehouse'),
component: 'select',
attrs: {
options: [],
'option-label': 'name',
'option-value': 'id',
},
},
];
const getRowUpdateInputEvents = (props, resetMinPrice, inputType = 'text') => { const getRowUpdateInputEvents = (props, resetMinPrice, inputType = 'text') => {
return inputType === 'text' return inputType === 'text'
? { ? {
@ -298,11 +353,12 @@ const openEditTableCellDialog = () => {
}; };
const onEditCellDataSaved = async () => { const onEditCellDataSaved = async () => {
rowsSelected.value = []; rowsSelected.value = [];
tableRef.value.reload();
}; };
const removeFuturePrice = async () => { const removeFuturePrice = async () => {
try { try {
rowsSelected.value.forEach(({ id }) => { rowsSelected.value.forEach(({ id }) => {
const rowIndex = fixedPrices.value.findIndex((r) => r.id === id); const rowIndex = fixedPrices.value.findIndex(({ id }) => id === id);
removePrice(id, rowIndex); removePrice(id, rowIndex);
}); });
} catch (err) { } catch (err) {
@ -311,27 +367,18 @@ const removeFuturePrice = async () => {
}; };
const quasar = useQuasar(); const quasar = useQuasar();
function confirmRemove(item) { function confirmRemove(item, isFuture) {
const promise = async () =>
isFuture ? removeFuturePrice(item.id) : removePrice(item.id);
quasar.dialog({ quasar.dialog({
component: VnConfirm, component: VnConfirm,
componentProps: { componentProps: {
title: t('globals.rowWillBeRemoved'), title: t('globals.rowWillBeRemoved'),
message: t('globals.confirmDeletion'), message: t('globals.confirmDeletion'),
promise: async () => removePrice(item.id), promise,
}, },
}); });
} }
function confirmRemoveFuturePrice(item) {
quasar.dialog({
component: VnConfirm,
componentProps: {
title: t('globals.rowWillBeRemoved'),
message: t('globals.confirmDeletion'),
promise: async () => removeFuturePrice(item.id),
},
});
}
const removePrice = async (id) => { const removePrice = async (id) => {
try { try {
await axios.delete(`FixedPrices/${id}`); await axios.delete(`FixedPrices/${id}`);
@ -393,7 +440,7 @@ const itemFixedPriceFilterRef = ref();
color="primary" color="primary"
icon="delete" icon="delete"
flat flat
@click="confirmRemoveFuturePrice" @click="(row) => confirmRemove(row, true)"
:title="t('globals.remove')" :title="t('globals.remove')"
v-if="rowsSelected.length" v-if="rowsSelected.length"
/> />
@ -597,6 +644,8 @@ const itemFixedPriceFilterRef = ref();
@on-data-saved="onEditCellDataSaved()" @on-data-saved="onEditCellDataSaved()"
/> />
</QDialog> </QDialog>
{{ rowsSelected }}
**{{ editTableFieldsOptions }}
</QPage> </QPage>
</template> </template>
<style lang="scss"> <style lang="scss">