Visu Sent Monete
This commit is contained in:
@@ -7,6 +7,8 @@ import { useUserStore } from '@store/UserStore'
|
||||
import { useCircuitStore } from '@store/CircuitStore'
|
||||
import { useQuasar } from 'quasar'
|
||||
import { useI18n } from '@/boot/i18n'
|
||||
import { CMyUser } from '@/components/CMyUser'
|
||||
import { costanti } from '@costanti'
|
||||
|
||||
export default defineComponent({
|
||||
name: 'CSendCoins',
|
||||
@@ -21,7 +23,7 @@ export default defineComponent({
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
components: { CCurrencyValue },
|
||||
components: { CCurrencyValue, CMyUser },
|
||||
|
||||
setup(props, { emit }) {
|
||||
const $q = useQuasar()
|
||||
@@ -42,11 +44,13 @@ export default defineComponent({
|
||||
const accountloaded = ref(<IAccount | undefined>undefined)
|
||||
const accountdest = ref(<IAccount | undefined>undefined)
|
||||
const remainingCoins = ref(0)
|
||||
const maxsendable = ref(0)
|
||||
const numstep = ref(0)
|
||||
|
||||
const priceLabel = computed(() => circuitloaded.value ? `${qty.value} ` + circuitloaded.value.symbol : '')
|
||||
const arrayMarkerLabel = ref(<any>[])
|
||||
|
||||
const qtyRef = ref(null)
|
||||
const qtyRef = ref(<any>null)
|
||||
|
||||
watch(() => circuitsel.value, (newval, oldval) => {
|
||||
aggiorna()
|
||||
@@ -63,15 +67,30 @@ export default defineComponent({
|
||||
accountloaded.value = userStore.getAccountByCircuitId(circuitloaded.value._id)
|
||||
// accountdest.value = userStore.getAccountByCircuitId(circuitloaded.value._id)
|
||||
if (accountloaded.value) {
|
||||
remainingCoins.value = tools.getRemainingCoinsToSend(accountloaded.value)
|
||||
const quanti = [ ...Array(100).keys() ].map( i => i+1)
|
||||
remainingCoins.value = circuitStore.getRemainingCoinsToSend(accountloaded.value)
|
||||
if (accountloaded.value.saldo > 0) {
|
||||
maxsendable.value = accountloaded.value.saldo + accountloaded.value.fidoConcesso
|
||||
} else {
|
||||
maxsendable.value = accountloaded.value.fidoConcesso
|
||||
}
|
||||
|
||||
if (remainingCoins.value < 10) {
|
||||
remainingCoins.value = 10
|
||||
}
|
||||
|
||||
numstep.value = Math.round(maxsendable.value / 10)
|
||||
if (numstep.value < 1) {
|
||||
numstep.value = 1
|
||||
}
|
||||
|
||||
const quanti = [...Array(20).keys()].map(i => i + 1)
|
||||
for (const ind of quanti) {
|
||||
let value = ind * 10
|
||||
let value = ind * numstep.value
|
||||
if (value > remainingCoins.value) {
|
||||
break
|
||||
} else {
|
||||
const label = value.toString()
|
||||
arrayMarkerLabel.value.push({value, label})
|
||||
arrayMarkerLabel.value.push({ value, label })
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -108,19 +127,19 @@ export default defineComponent({
|
||||
|
||||
if (props.to_user.username && qty.value && circuitloaded.value) {
|
||||
const myrecsendcoin: ISendCoin = {
|
||||
qty: qty.value,
|
||||
qty: tools.convstrToNum(qty.value),
|
||||
dest: props.to_user.username,
|
||||
circuitname: circuitsel.value,
|
||||
causal: causal.value,
|
||||
symbol: circuitloaded.value.symbol,
|
||||
}
|
||||
console.log('myrecsendcoin', myrecsendcoin)
|
||||
if (circuitloaded.value) {
|
||||
tools.sendCoinsByCircuit($q, circuitloaded.value, myrecsendcoin).then((ris: any) => {
|
||||
if (ris) {
|
||||
show.value = false
|
||||
}
|
||||
})
|
||||
if (myrecsendcoin) {
|
||||
tools.sendCoinsByCircuit($q, circuitloaded.value, myrecsendcoin)
|
||||
.then((ris: any) => {
|
||||
if (ris) {
|
||||
show.value = false
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -145,6 +164,11 @@ export default defineComponent({
|
||||
arrayMarkerLabel,
|
||||
remainingCoins,
|
||||
qtyRef,
|
||||
maxsendable,
|
||||
circuitStore,
|
||||
numstep,
|
||||
costanti,
|
||||
userStore,
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<div>
|
||||
<q-dialog v-model="show" :maximized="$q.screen.lt.sm" @hide="hide">
|
||||
<q-dialog v-model="show" :maximized="$q.screen.lt.sm" @hide="hide" @show="qtyRef.focus()">
|
||||
<q-card class="dialog_card">
|
||||
<q-toolbar class="bg-primary text-white">
|
||||
<q-toolbar-title>
|
||||
@@ -22,48 +22,57 @@
|
||||
|
||||
</CCurrencyValue>
|
||||
|
||||
<q-input v-model="from_username" label="Mittente" class="full-width" disable>
|
||||
</q-input>
|
||||
<q-input v-model="to_user.username" label="Destinatario" class="full-width" disable>
|
||||
<q-input v-model="from_username" label="Mittente" class="full-width" readonly>
|
||||
</q-input>
|
||||
<CMyUser
|
||||
:mycontact="to_user"
|
||||
:visu="costanti.FIND_PEOPLE"
|
||||
@setCmd="tools.setCmd"
|
||||
labelextra="Destinatario"
|
||||
>
|
||||
</CMyUser>
|
||||
<q-input v-model="causal" label="Note" class="full-width">
|
||||
</q-input>
|
||||
|
||||
<div>
|
||||
<q-input
|
||||
ref="qtyRef"
|
||||
class="q-py-sm text-h5"
|
||||
outlined v-model="qty" type="number"
|
||||
:rules="[ val => val <= circuitStore.getRemainingCoinsToSend(accountloaded) || t('circuit.qta_remaining_to_send', { maxqta: circuitStore.getRemainingCoinsToSend(accountloaded), symbol: circuitloaded.symbol })]"
|
||||
:label="t('movement.amount_to_send', {qtamax: circuitStore.getRemainingCoinsToSend(accountloaded).toFixed(2) + ` ` + circuitloaded.symbol})"
|
||||
>
|
||||
<!--val => val > circuitStore.getMaxCoinsToSend(accountloaded) || t('circuit.qta_max_to_send', { maxqta: tools.getRemainingCoinsToSend(accountloaded), symbol: circuitloaded.symbol })]" -->
|
||||
<template v-slot:append>
|
||||
<div class="text-h5">
|
||||
<em class="q-px-sm text-white rounded-borders"
|
||||
:style="`background-color: ` + (circuitloaded.color ? circuitloaded.color : '#ff5500')">{{ circuitloaded.symbol }}</em>
|
||||
</div>
|
||||
</template>
|
||||
</q-input>
|
||||
|
||||
<q-input
|
||||
ref="qtyRef"
|
||||
class="q-px-sm text-h5"
|
||||
outlined v-model="qty" type="number"
|
||||
:rules="[ val => val < tools.getRemainingCoinsToSend(accountloaded) || t('circuit.qta_remaining_to_send', { maxqta: tools.getRemainingCoinsToSend(accountloaded), symbol: circuitloaded.symbol })]" :label="t('movement.amount')"
|
||||
>
|
||||
<!--val => val > tools.getMaxCoinsToSend(accountloaded) || t('circuit.qta_max_to_send', { maxqta: tools.getRemainingCoinsToSend(accountloaded), symbol: circuitloaded.symbol })]" -->
|
||||
<template v-slot:append>
|
||||
<div class="text-h5">
|
||||
<em class="q-px-sm text-white rounded-borders" :style="`background-color: ` + (circuitloaded.color ? circuitloaded.color : '#ff5500')">{{ circuitloaded.symbol }}</em>
|
||||
</div>
|
||||
</template>
|
||||
</q-input>
|
||||
|
||||
<q-slider
|
||||
v-model="qty"
|
||||
color="green"
|
||||
markers
|
||||
:step="5"
|
||||
:marker-labels="arrayMarkerLabel"
|
||||
label-always
|
||||
:label-value="priceLabel"
|
||||
switch-label-side
|
||||
switch-marker-labels-side
|
||||
:inner-max="remainingCoins"
|
||||
:min="0"
|
||||
:max="accountloaded.fidoConcesso"
|
||||
/>
|
||||
<q-slider
|
||||
v-model="qty"
|
||||
color="green"
|
||||
markers
|
||||
track-size="10px"
|
||||
:step="numstep"
|
||||
:marker-labels="arrayMarkerLabel"
|
||||
label-always
|
||||
:label-value="priceLabel"
|
||||
switch-label-side
|
||||
switch-marker-labels-side
|
||||
:inner-max="remainingCoins"
|
||||
:min="0"
|
||||
:max="Number(maxsendable.toFixed(2))"
|
||||
/>
|
||||
</div>
|
||||
|
||||
</q-card-section>
|
||||
<q-card-actions align="center">
|
||||
<q-btn
|
||||
:disable="qtyRef ? qtyRef.hasError : false"
|
||||
:label="$t('circuit.sendcoinsto', {qty, coin: circuitsel, dest: to_user.username })" color="primary"
|
||||
:label="$t('circuit.sendcoinsto', {qty, coin: circuitsel, dest: to_user.username })" color="positive"
|
||||
@click="sendCoin()"></q-btn>
|
||||
<q-btn flat :label="$t('dialog.cancel')" color="primary" v-close-popup></q-btn>
|
||||
</q-card-actions>
|
||||
|
||||
Reference in New Issue
Block a user