Visu Sent Monete

This commit is contained in:
Paolo Arena
2022-09-13 12:28:33 +02:00
parent f59691985a
commit 44c75768c6
29 changed files with 301 additions and 69 deletions

View File

@@ -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,
}
},
})