- Invio RIS migliorata grafica e aggiunto tastierino numerico.
This commit is contained in:
@@ -7,15 +7,17 @@ import { useUserStore } from '@store/UserStore'
|
||||
import { useCircuitStore } from '@store/CircuitStore'
|
||||
import { useQuasar } from 'quasar'
|
||||
import { useI18n } from '@/boot/i18n'
|
||||
import { CNumericKeyboard } from '@/components/CNumericKeyboard'
|
||||
import { CMyUserOnlyView } from '@/components/CMyUserOnlyView'
|
||||
import { CMyGroupOnlyView } from '@/components/CMyGroupOnlyView'
|
||||
import { CCheckCircuitsEnabled } from '@/components/CCheckCircuitsEnabled'
|
||||
import { costanti } from '@costanti'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { shared_consts } from '@src/common/shared_vuejs'
|
||||
|
||||
export default defineComponent({
|
||||
name: 'CSendCoins',
|
||||
emits: ['close'],
|
||||
emits: ['close', 'showed'],
|
||||
props: {
|
||||
showprop: {
|
||||
type: Boolean,
|
||||
@@ -28,7 +30,7 @@ export default defineComponent({
|
||||
qtydefault: {
|
||||
type: String,
|
||||
required: false,
|
||||
default: '1'
|
||||
default: ''
|
||||
},
|
||||
to_user: {
|
||||
type: Object as PropType<IUserFields>,
|
||||
@@ -51,12 +53,12 @@ export default defineComponent({
|
||||
default: null,
|
||||
},
|
||||
sendRIS: {
|
||||
type: Number,
|
||||
type: String,
|
||||
required: false,
|
||||
default: 1,
|
||||
default: '',
|
||||
},
|
||||
},
|
||||
components: { CSaldo, CMyUserOnlyView, CMyGroupOnlyView, CCheckCircuitsEnabled },
|
||||
components: { CSaldo, CMyUserOnlyView, CMyGroupOnlyView, CCheckCircuitsEnabled, CNumericKeyboard },
|
||||
|
||||
setup(props, { emit }) {
|
||||
const $q = useQuasar()
|
||||
@@ -80,6 +82,8 @@ export default defineComponent({
|
||||
const groupSel = ref(<IMyGroup | null | undefined>null)
|
||||
|
||||
const datasaved = ref(<any>null)
|
||||
const step = ref(0)
|
||||
const sendCoinDialog = ref(null)
|
||||
|
||||
const circuittoload = ref(<ICircuit | undefined>undefined)
|
||||
const circuitloaded = ref(<ICircuit>{})
|
||||
@@ -89,12 +93,7 @@ export default defineComponent({
|
||||
const remainingCoins = ref(0)
|
||||
const maxsendable = ref(0)
|
||||
const numstep = ref(0)
|
||||
const arrTypesAccounts = ref(<any>[
|
||||
{
|
||||
label: t('circuit.user'),
|
||||
value: shared_consts.AccountType.USER,
|
||||
},
|
||||
])
|
||||
const arrTypesAccounts = ref(<any>[])
|
||||
const tipoConto = ref(shared_consts.AccountType.USER)
|
||||
|
||||
const priceLabel = computed(() => circuitloaded.value ? `${qty.value} ` + circuitloaded.value.symbol : '')
|
||||
@@ -119,6 +118,8 @@ export default defineComponent({
|
||||
from_groupname.value = arrGroupsList.value[0].value
|
||||
}
|
||||
|
||||
tools.setCookie(tools.COOK_TIPOCONTO, tipoConto.value.toString())
|
||||
|
||||
aggiorna()
|
||||
})
|
||||
|
||||
@@ -156,7 +157,7 @@ export default defineComponent({
|
||||
try {
|
||||
arrTypesAccounts.value = [
|
||||
{
|
||||
label: t('circuit.user'),
|
||||
label: t('circuit.personale') + ' ' + from_username.value,
|
||||
value: shared_consts.AccountType.USER,
|
||||
},
|
||||
]
|
||||
@@ -250,13 +251,17 @@ export default defineComponent({
|
||||
|
||||
async function mounted() {
|
||||
|
||||
loading.value = true
|
||||
|
||||
arrTypesAccounts.value = [
|
||||
{
|
||||
label: t('circuit.user'),
|
||||
label: t('circuit.personale') + ' ' + from_username.value,
|
||||
value: shared_consts.AccountType.USER,
|
||||
},
|
||||
]
|
||||
|
||||
tipoConto.value = tools.getCookie(tools.COOK_TIPOCONTO, shared_consts.AccountType.USER, true)
|
||||
|
||||
// ....
|
||||
if (props.to_user) {
|
||||
console.log('user', props.to_user)
|
||||
@@ -273,7 +278,8 @@ export default defineComponent({
|
||||
circuitsel.value = bothcircuits.value[0]
|
||||
}
|
||||
|
||||
qty.value = props.qtydefault
|
||||
if (props.qtydefault)
|
||||
qty.value = props.qtydefault
|
||||
|
||||
if (props.sendRIS) {
|
||||
qty.value = props.sendRIS
|
||||
@@ -282,6 +288,7 @@ export default defineComponent({
|
||||
await aggiorna()
|
||||
|
||||
showpage.value = true
|
||||
loading.value = false
|
||||
}
|
||||
|
||||
if (props.to_group) {
|
||||
@@ -314,6 +321,9 @@ export default defineComponent({
|
||||
|
||||
showpage.value = true
|
||||
}
|
||||
|
||||
loading.value = false
|
||||
emit('showed', true)
|
||||
}
|
||||
|
||||
function hide() {
|
||||
@@ -358,6 +368,99 @@ export default defineComponent({
|
||||
}
|
||||
}
|
||||
|
||||
function ifNextCheck(actualstep: number) {
|
||||
|
||||
let fase1ok = false
|
||||
|
||||
if (circuitloaded.value && !!circuitloaded.value._id) {
|
||||
fase1ok = !(
|
||||
!circuitloaded.value.transactionsEnabled ||
|
||||
(tipoConto.value === shared_consts.AccountType.USER &&
|
||||
props.to_user &&
|
||||
from_username.value === props.to_user.username) ||
|
||||
(tipoConto.value ===
|
||||
shared_consts.AccountType.COLLECTIVE_ACCOUNT &&
|
||||
!from_groupname.value) ||
|
||||
(tipoConto.value ===
|
||||
shared_consts.AccountType.COLLECTIVE_ACCOUNT &&
|
||||
props.to_group &&
|
||||
from_groupname.value &&
|
||||
props.to_group.groupname === from_groupname.value) ||
|
||||
(tipoConto.value ===
|
||||
shared_consts.AccountType.COMMUNITY_ACCOUNT &&
|
||||
!from_contocom.value)
|
||||
)
|
||||
}
|
||||
|
||||
if (actualstep === 0) {
|
||||
return fase1ok
|
||||
} else if (actualstep === 1) {
|
||||
return fase1ok && checkRisValid()
|
||||
} else if (actualstep === 2) {
|
||||
return fase1ok && checkRisValid()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function checkRisValid() {
|
||||
return qty.value ? qty.value && getQty() > 0.01 && accountloaded.value
|
||||
&& getQty() <= circuitStore.getRemainingCoinsToSend(accountloaded.value) : false
|
||||
}
|
||||
|
||||
function getQty(): number {
|
||||
let myqty: number | null = null
|
||||
|
||||
try {
|
||||
if (qty.value) {
|
||||
myqty = parseFloat(String(qty.value))
|
||||
}
|
||||
} catch (e) {
|
||||
return 0
|
||||
}
|
||||
|
||||
return myqty ? myqty : 0
|
||||
}
|
||||
|
||||
function getTitle(step: number) {
|
||||
|
||||
if (step === 0) {
|
||||
return 'Circuito'
|
||||
} else if (step === 1) {
|
||||
return 'Quantità'
|
||||
} else if (step === 2) {
|
||||
return 'Causale'
|
||||
}
|
||||
}
|
||||
function getIcon(step: number) {
|
||||
|
||||
if (step === 0) {
|
||||
return 'circuit'
|
||||
} else if (step === 1) {
|
||||
return 'attach_money'
|
||||
} else if (step === 2) {
|
||||
return 'description'
|
||||
}
|
||||
}
|
||||
|
||||
function clickAvanti(actualstep: number) {
|
||||
if (actualstep === 0) {
|
||||
step.value = 1
|
||||
} else if (actualstep === 1) {
|
||||
step.value = 2
|
||||
} else if (actualstep === 2) {
|
||||
sendCoin()
|
||||
}
|
||||
}
|
||||
function clickIndietro(actualstep: number) {
|
||||
if (actualstep === 1) {
|
||||
step.value = 0
|
||||
} else if (actualstep === 2) {
|
||||
step.value = 1
|
||||
} else if (actualstep === 0) {
|
||||
hide()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
onMounted(mounted)
|
||||
|
||||
@@ -392,6 +495,14 @@ export default defineComponent({
|
||||
arrTypesAccounts,
|
||||
loading,
|
||||
showProvinceToSelect,
|
||||
shared_consts,
|
||||
step,
|
||||
ifNextCheck,
|
||||
clickIndietro,
|
||||
clickAvanti,
|
||||
getTitle,
|
||||
getIcon,
|
||||
sendCoinDialog,
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user