forked from verdnatura/salix-front
refs #6545 refactor
This commit is contained in:
parent
a3d6275b2f
commit
a730f2c073
|
@ -2,19 +2,22 @@
|
||||||
import { ref, onMounted } from 'vue';
|
import { ref, onMounted } from 'vue';
|
||||||
import { useSession } from 'src/composables/useSession';
|
import { useSession } from 'src/composables/useSession';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
|
import { useQuasar } from 'quasar';
|
||||||
|
import VnConfirm from 'components/ui/VnConfirm.vue';
|
||||||
|
|
||||||
|
const quasar = useQuasar();
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const session = useSession();
|
const session = useSession();
|
||||||
const token = session.getToken();
|
const token = session.getToken();
|
||||||
|
|
||||||
const counters = ref({
|
const counters = ref({
|
||||||
alquilerBandeja: { count: 0, id: 27098, title: 'Alquiler de CC Bandeja' },
|
alquilerBandeja: { count: 0, id: 1, title: 'Alquiler de CC Bandeja' },
|
||||||
bandejaRota: { count: 0, id: 88381, title: 'CC Bandeja Rota' },
|
bandejaRota: { count: 0, id: 2, title: 'CC Bandeja Rota' },
|
||||||
carryOficial: { count: 0, id: 27097, title: ' Alquiler de CC Carry OFICIAL' },
|
carryOficial: { count: 0, id: 3, title: ' Alquiler de CC Carry OFICIAL' },
|
||||||
candadoRojo: { count: 0, id: 142252, title: 'CC Candado rojo' },
|
candadoRojo: { count: 0, id: 4, title: 'CC Candado rojo' },
|
||||||
sacadores: { count: 0, id: 142260, title: 'CC Sacadores' },
|
sacadores: { count: 0, id: 5, title: 'CC Sacadores' },
|
||||||
sinChapa: { count: 0, id: 142258, title: 'CC Sin Chapa' },
|
sinChapa: { count: 0, id: 6, title: 'CC Sin Chapa' },
|
||||||
carroRoto: { count: 0, id: 142251, title: 'Carro Roto' },
|
carroRoto: { count: 0, id: 7, title: 'Carro Roto' },
|
||||||
});
|
});
|
||||||
|
|
||||||
const actions = {
|
const actions = {
|
||||||
|
@ -35,24 +38,45 @@ function getUrl(id) {
|
||||||
return `/api/Images/catalog/200x200/${id}/download?access_token=${token}`;
|
return `/api/Images/catalog/200x200/${id}/download?access_token=${token}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleEvent(type, action) {
|
async function handleEvent(type, action) {
|
||||||
const counter = counters.value[type].count;
|
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);
|
||||||
localStorage.setItem(type, counters.value[type].count);
|
localStorage.setItem(type, counters.value[type].count);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function confirm() {
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
quasar
|
||||||
|
.dialog({
|
||||||
|
component: VnConfirm,
|
||||||
|
componentProps: {
|
||||||
|
title: t('Are you sure?'),
|
||||||
|
message: t('Se pondrá el contador a cero'),
|
||||||
|
},
|
||||||
|
})
|
||||||
|
.onOk(() => resolve(true))
|
||||||
|
.onCancel(() => resolve(false));
|
||||||
|
});
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<QList class="q-mx-auto q-mt-xl">
|
<QList class="row q-mx-auto q-mt-xl">
|
||||||
<QItem v-for="(props, name) in counters" :key="name">
|
<QItem v-for="(props, name) in counters" :key="name" class="col-6">
|
||||||
<QItemSection>
|
<QItemSection>
|
||||||
<p class="text-h5">{{ props.title }}</p>
|
|
||||||
<QImg
|
<QImg
|
||||||
:src="getUrl(props.id)"
|
:src="getUrl(props.id)"
|
||||||
width="150px"
|
width="130px"
|
||||||
@click="handleEvent(name, 'add')"
|
@click="handleEvent(name, 'add')"
|
||||||
/>
|
/>
|
||||||
|
<p class="title">{{ props.title }}</p>
|
||||||
</QItemSection>
|
</QItemSection>
|
||||||
<QItemSection>
|
<QItemSection class="q-ma-none">
|
||||||
<QItemLabel class="text-h4">
|
<QItemLabel class="text-h4">
|
||||||
{{ props.count }}
|
{{ props.count }}
|
||||||
</QItemLabel>
|
</QItemLabel>
|
||||||
|
@ -61,6 +85,7 @@ function handleEvent(type, action) {
|
||||||
class="text-center q-mr-xs"
|
class="text-center q-mr-xs"
|
||||||
color="warning"
|
color="warning"
|
||||||
dense
|
dense
|
||||||
|
size="sm"
|
||||||
@click="handleEvent(name, 'substract')"
|
@click="handleEvent(name, 'substract')"
|
||||||
>
|
>
|
||||||
{{ t('Substract 1') }}
|
{{ t('Substract 1') }}
|
||||||
|
@ -69,12 +94,14 @@ function handleEvent(type, action) {
|
||||||
class="text-center q-ml-xs"
|
class="text-center q-ml-xs"
|
||||||
color="red"
|
color="red"
|
||||||
dense
|
dense
|
||||||
|
size="sm"
|
||||||
@click="handleEvent(name, 'flush')"
|
@click="handleEvent(name, 'flush')"
|
||||||
>
|
>
|
||||||
{{ t('Flush') }}
|
{{ t('Flush') }}
|
||||||
</QBtn>
|
</QBtn>
|
||||||
</QItemLabel>
|
</QItemLabel>
|
||||||
</QItemSection>
|
</QItemSection>
|
||||||
|
<QSeparator class="q-mt-sm q-mx-none" color="primary" />
|
||||||
</QItem>
|
</QItem>
|
||||||
</QList>
|
</QList>
|
||||||
</template>
|
</template>
|
||||||
|
@ -82,9 +109,20 @@ function handleEvent(type, action) {
|
||||||
.q-list {
|
.q-list {
|
||||||
max-width: 50em;
|
max-width: 50em;
|
||||||
}
|
}
|
||||||
|
@media (max-width: $breakpoint-sm) {
|
||||||
|
.q-item {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
.title {
|
||||||
|
min-height: 3em;
|
||||||
|
}
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
<i18n>
|
<i18n>
|
||||||
es:
|
es:
|
||||||
Substract 1: Quitar 1
|
Substract 1: Quitar 1
|
||||||
Flush: Vaciar
|
Flush: Vaciar
|
||||||
|
Are you sure?: ¿Estás seguro?
|
||||||
|
It will set to 0: Se pondrá a 0
|
||||||
</i18n>
|
</i18n>
|
||||||
|
|
Loading…
Reference in New Issue