feat(addSpecific): refs #6545 add feats and fixes
gitea/salix-front/pipeline/head This commit looks good Details

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' },
bandejaRota: { count: 0, id: 88381, title: 'CC Bandeja Rota' },
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' },
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' },
});
const actions = {
add: (value) => value + 1,
subtract: (value) => (value ? value - 1 : 0),
add: (counter) => counter + 1,
subtract: (counter) => (counter ? counter - 1 : 0),
flush: () => 0,
addSpecific: (value) => value + 30,
addSpecific: (counter, amount) => counter + amount,
};
onMounted(() => {
@ -39,14 +39,14 @@ function getUrl(id) {
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;
let isOk = true;
if (action == 'flush') isOk = await confirm();
if (isOk) {
counters.value[type].count = actions[action](counter);
counters.value[type].count = actions[action](counter, amount);
localStorage.setItem(type, counters.value[type].count);
}
}
@ -87,10 +87,21 @@ function confirm() {
color="warning"
dense
size="sm"
@click="handleEvent(name, 'addSpecific')"
v-if="props.title === 'CC Bandeja'"
@click="handleEvent(name, 'addSpecific', 30)"
>
{{ t('Add 30') }}
</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>
<QBtn
@ -135,6 +146,7 @@ function confirm() {
es:
Subtract 1: Quitar 1
Add 30: Añadir 30
Add 10: Añadir 10
Flush: Vaciar
Are you sure?: ¿Estás seguro?
It will set to 0: Se pondrá a 0