0
0
Fork 0

feat(addSpecific): refs #6545 add feats and fixes

This commit is contained in:
Pablo Natek 2023-12-06 14:14:47 +01:00
parent 915f7ea45d
commit 6c524932ee
1 changed files with 20 additions and 8 deletions

View File

@ -14,17 +14,17 @@ const counters = ref({
alquilerBandeja: { count: 0, id: 96001, title: 'CC Bandeja' }, alquilerBandeja: { count: 0, id: 96001, title: 'CC Bandeja' },
bandejaRota: { count: 0, id: 88381, title: 'CC Bandeja Rota' }, bandejaRota: { count: 0, id: 88381, title: 'CC Bandeja Rota' },
carryOficial: { count: 0, id: 96000, title: 'CC Carry OFICIAL TAG5' }, carryOficial: { count: 0, id: 96000, title: 'CC Carry OFICIAL TAG5' },
candadoRojo: { count: 0, id: 142252, title: 'CC Candado rojo' }, candadoRojo: { count: 0, id: 96002, title: 'CC Carry NO OFICIAL' },
sacadores: { count: 0, id: 142260, title: 'CC Sacadores' }, sacadores: { count: 0, id: 142260, title: 'CC Sacadores' },
sinChapa: { count: 0, id: 142258, title: 'CC Sin Chapa' }, sinChapa: { count: 0, id: 2214, title: 'DC Carry Sin Placa CC' },
carroRoto: { count: 0, id: 142251, title: 'Carro Roto' }, carroRoto: { count: 0, id: 142251, title: 'Carro Roto' },
}); });
const actions = { const actions = {
add: (value) => value + 1, add: (counter) => counter + 1,
subtract: (value) => (value ? value - 1 : 0), subtract: (counter) => (counter ? counter - 1 : 0),
flush: () => 0, flush: () => 0,
addSpecific: (value) => value + 30, addSpecific: (counter, amount) => counter + amount,
}; };
onMounted(() => { onMounted(() => {
@ -39,14 +39,14 @@ function getUrl(id) {
return `/api/Images/catalog/200x200/${id}/download?access_token=${token}`; return `/api/Images/catalog/200x200/${id}/download?access_token=${token}`;
} }
async function handleEvent(type, action) { async function handleEvent(type, action, amount) {
const counter = counters.value[type].count; const counter = counters.value[type].count;
let isOk = true; let isOk = true;
if (action == 'flush') isOk = await confirm(); if (action == 'flush') isOk = await confirm();
if (isOk) { if (isOk) {
counters.value[type].count = actions[action](counter); counters.value[type].count = actions[action](counter, amount);
localStorage.setItem(type, counters.value[type].count); localStorage.setItem(type, counters.value[type].count);
} }
} }
@ -87,10 +87,21 @@ function confirm() {
color="warning" color="warning"
dense dense
size="sm" size="sm"
@click="handleEvent(name, 'addSpecific')" v-if="props.title === 'CC Bandeja'"
@click="handleEvent(name, 'addSpecific', 30)"
> >
{{ t('Add 30') }} {{ t('Add 30') }}
</QBtn> </QBtn>
<QBtn
class="text-center q-mr-xs"
color="warning"
dense
size="sm"
v-else
@click="handleEvent(name, 'addSpecific', 10)"
>
{{ t('Add 10') }}
</QBtn>
</QItemLabel> </QItemLabel>
<QItemLabel> <QItemLabel>
<QBtn <QBtn
@ -135,6 +146,7 @@ function confirm() {
es: es:
Subtract 1: Quitar 1 Subtract 1: Quitar 1
Add 30: Añadir 30 Add 30: Añadir 30
Add 10: Añadir 10
Flush: Vaciar Flush: Vaciar
Are you sure?: ¿Estás seguro? Are you sure?: ¿Estás seguro?
It will set to 0: Se pondrá a 0 It will set to 0: Se pondrá a 0