add: iteration 1 finished
Finished simple calculator iteration
This commit is contained in:
parent
e4ff2ba229
commit
85e6035a9a
12 changed files with 293 additions and 34 deletions
|
@ -53,7 +53,7 @@
|
|||
<Icon name="uil:trash" mode="svg" />
|
||||
Entfernen
|
||||
</PpButton>
|
||||
<PpButton class="cta white">
|
||||
<PpButton v-if="false" class="cta white">
|
||||
<Icon name="uil:qrcode-scan" mode="svg" />
|
||||
Scan
|
||||
</PpButton>
|
||||
|
@ -72,46 +72,44 @@ type Props = {
|
|||
const { card } = defineProps<Props>()
|
||||
const emit = defineEmits(['remove', 'update'])
|
||||
|
||||
onMounted(() => {
|
||||
calculate()
|
||||
if (card.price) folded.value = true
|
||||
})
|
||||
|
||||
const root = ref<HTMLElement>()
|
||||
const folded = ref<boolean>(false)
|
||||
const deleting = ref<boolean>(false)
|
||||
|
||||
const ppr = ref(0)
|
||||
const pps = ref(0)
|
||||
const ppl = ref(0)
|
||||
const ppr = ref(card.ppr)
|
||||
const pps = ref(card.pps)
|
||||
const ppl = ref(card.ppl)
|
||||
|
||||
const intl = Intl.NumberFormat('de-DE', {
|
||||
style: 'currency',
|
||||
currency: 'EUR',
|
||||
})
|
||||
|
||||
const update = () => {
|
||||
emit('update', card)
|
||||
}
|
||||
|
||||
const calculate = () => {
|
||||
if (!card.price || !card.roles) return
|
||||
ppr.value = card.price / card.roles
|
||||
|
||||
if (!card.sheets) return
|
||||
if (!card.sheets) {
|
||||
update()
|
||||
return
|
||||
}
|
||||
pps.value = (ppr.value / card.sheets) * 10
|
||||
|
||||
if(!card.layers) return
|
||||
if(!card.layers) {
|
||||
update()
|
||||
return
|
||||
}
|
||||
ppl.value = (pps.value / card.layers) * 10
|
||||
|
||||
update()
|
||||
}
|
||||
|
||||
const deleteCard = async () => {
|
||||
root.value?.addEventListener('transitionend', () => {
|
||||
emit('remove')
|
||||
})
|
||||
const update = () => emit('update', { ...card, ppr: ppr.value, pps: pps.value, ppl: ppl.value })
|
||||
|
||||
const deleteCard = async () => {
|
||||
root.value?.addEventListener('transitionend', () => emit('remove'))
|
||||
deleting.value = true
|
||||
}
|
||||
|
||||
onMounted(() => folded.value = !!card.price)
|
||||
</script>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue