- pagine admin: Accounts, Movements e Circuits.

- add change min e max range circuiti (per tutti i record).
This commit is contained in:
Surya Paolo
2023-02-06 22:58:18 +01:00
parent 0234e2323a
commit 5c2b28939b
24 changed files with 560 additions and 180 deletions

View File

@@ -69,6 +69,8 @@ export default defineComponent({
const groupSel = ref(<IMyGroup | null | undefined>null)
const datasaved = ref(<any>null)
const circuittoload = ref(<ICircuit | undefined>undefined)
const circuitloaded = ref(<ICircuit>{})
const circuitdest = ref(<ICircuit | undefined>undefined)
@@ -101,6 +103,12 @@ export default defineComponent({
})
watch(() => tipoConto.value, (newval, oldval) => {
if (tipoConto.value === costanti.AccountType.COLLECTIVE_ACCOUNT) {
if (arrGroupsList.value.length >= 1)
from_groupname.value = arrGroupsList.value[0]
}
aggiorna()
})
@@ -122,96 +130,110 @@ export default defineComponent({
groupSel.value = null
from_contocom.value = ''
accountloaded.value = null
circuittoload.value = circuitStore.listcircuits.find((rec: ICircuit) => rec.name === circuitsel.value)
if (circuittoload.value) {
await userStore.loadCircuit(circuittoload.value.path, '').then(({ data, status }: { data: any, status: number }) => {
try {
arrTypesAccounts.value = [
{
label: t('circuit.user'),
value: costanti.AccountType.USER,
},
]
if (!circuittoload.value || (circuittoload.value && circuittoload.value.name !== circuitsel.value)) {
circuittoload.value = circuitStore.listcircuits.find((rec: ICircuit) => rec.name === circuitsel.value)
if (circuittoload.value) {
await userStore.loadCircuit(circuittoload.value.path, '').then(({ data, status }: { data: any, status: number }) => {
datasaved.value = data
})
}
}
if (datasaved.value) {
try {
arrTypesAccounts.value = [
{
label: t('circuit.user'),
value: costanti.AccountType.USER,
},
]
if (!!data.circuit) {
circuitloaded.value = data.circuit
if (!!datasaved.value.circuit) {
circuitloaded.value = datasaved.value.circuit
if (tipoConto.value === costanti.AccountType.USER) {
accountloaded.value = userStore.getAccountByCircuitId(circuitloaded.value._id)
} else if (tipoConto.value === costanti.AccountType.COLLECTIVE_ACCOUNT) {
groupSel.value = userStore.my.profile.manage_mygroups.find((group: IMyGroup) => from_groupname.value === group.groupname)
if (tipoConto.value === costanti.AccountType.USER) {
accountloaded.value = userStore.getAccountByCircuitId(circuitloaded.value._id)
} else if (tipoConto.value === costanti.AccountType.COLLECTIVE_ACCOUNT) {
groupSel.value = userStore.my.profile.manage_mygroups.find((group: IMyGroup) => from_groupname.value === group.groupname)
accountloaded.value = groupSel.value ? groupSel.value.account : null
} else if (tipoConto.value === costanti.AccountType.COMMUNITY_ACCOUNT) {
from_contocom.value = circuitloaded.value.path
accountloaded.value = circuitloaded.value ? circuitloaded.value.account : null
}
accountloaded.value = groupSel.value ? groupSel.value.account : null
} else if (tipoConto.value === costanti.AccountType.COMMUNITY_ACCOUNT) {
from_contocom.value = circuitloaded.value.path
accountloaded.value = circuitloaded.value ? circuitloaded.value.account : null
}
groupsListAdmin.value = userStore.GroupsListWhereIAmAdminInTheCircuit(circuitloaded.value.name)
console.log('groupsListAdmin.value', groupsListAdmin.value)
groupsListAdmin.value = userStore.GroupsListWhereIAmAdminInTheCircuit(circuitloaded.value.name)
console.log('groupsListAdmin.value', groupsListAdmin.value)
arrGroupsList.value = []
arrGroupsList.value = []
if (groupsListAdmin.value) {
for (const group of groupsListAdmin.value) {
if (groupsListAdmin.value) {
for (const group of groupsListAdmin.value) {
let aggiungi = true
if (props.to_group && props.to_group.groupname === group.groupname)
aggiungi = false
if (aggiungi)
arrGroupsList.value.push({ label: group.groupname, value: group.groupname });
}
}
}
if (arrGroupsList.value.length > 0) {
arrTypesAccounts.value.push(
{
label: t('circuit.conticollettivi'),
value: costanti.AccountType.COLLECTIVE_ACCOUNT,
})
}
if (tools.iCanSendCoinsSuperUserCircuit(circuitsel.value)) {
arrTypesAccounts.value.push({
label: t('circuit.contocom'),
value: costanti.AccountType.COMMUNITY_ACCOUNT,
if (arrGroupsList.value.length > 0) {
arrTypesAccounts.value.push(
{
label: t('circuit.conticollettivi'),
value: costanti.AccountType.COLLECTIVE_ACCOUNT,
})
}
if (tools.iCanSendCoinsSuperUserCircuit(circuitsel.value) && (!props.to_contocom)) {
arrTypesAccounts.value.push({
label: t('circuit.contocom'),
value: costanti.AccountType.COMMUNITY_ACCOUNT,
})
}
// if (tools.iAmAdminCircuit(circuitloaded.value.name))
// arrGroupsList.value.push({ label: circuitloaded.value.name, value: circuitloaded.value.path });
// accountdest.value = userStore.getAccountByCircuitId(circuitloaded.value._id)
if (accountloaded.value) {
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 (tools.iAmAdminCircuit(circuitloaded.value.name))
// arrGroupsList.value.push({ label: circuitloaded.value.name, value: circuitloaded.value.path });
if (remainingCoins.value < 10) {
remainingCoins.value = 10
}
// accountdest.value = userStore.getAccountByCircuitId(circuitloaded.value._id)
if (accountloaded.value) {
remainingCoins.value = circuitStore.getRemainingCoinsToSend(accountloaded.value)
if (accountloaded.value.saldo > 0) {
maxsendable.value = accountloaded.value.saldo + accountloaded.value.fidoConcesso
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 valuenorm = ind * numstep.value
let value = ind * numstep.value
if (value > remainingCoins.value) {
break
} 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 valuenorm = ind * numstep.value
let value = ind * numstep.value
if (value > remainingCoins.value) {
break
} else {
const label = valuenorm.toString()
arrayMarkerLabel.value.push({ value, label })
}
const label = valuenorm.toString()
arrayMarkerLabel.value.push({ value, label })
}
}
}
} finally {
loading.value = false
}
})
} finally {
loading.value = false
}
}
}