- 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

@@ -23,7 +23,8 @@ import globalroutines from '../globalroutines/index'
export const useCircuitStore = defineStore('CircuitStore', {
state: (): ICircuitState => ({
listcircuits: []
listcircuits: [],
listaccounts: [],
}),
getters: {},
@@ -72,6 +73,23 @@ export const useCircuitStore = defineStore('CircuitStore', {
return this.listcircuits.find((rec: ICircuit) => rec.name === circuitname)
},
getCircuitByCircuitId(circuitId: string): ICircuit | null | undefined {
return this.listcircuits.find((rec: ICircuit) => rec._id === circuitId)
},
getNameByCircuitId(circuitId: string): string {
const circuit = this.getCircuitByCircuitId(circuitId);
return circuit && circuit.name ? circuit.name : ''
},
getCircuitsLabelValue(): any {
let arr = []
for (const circ of this.listcircuits) {
arr.push({label: circ.name, value: circ._id})
}
return arr
},
getCircuitByPath(circuitpath: string): ICircuit | null {
const ris = this.listcircuits.find((rec: ICircuit) => rec.path === circuitpath)
return ris ? ris : null
@@ -99,6 +117,26 @@ export const useCircuitStore = defineStore('CircuitStore', {
return false
},
getAccountByCircuitId(circuitId: string): any {
if (this.listaccounts) {
return this.listaccounts.find((rec: IAccount) => rec.circuitId === circuitId)
}
return null
},
getAccountsListNameValue(): any[] {
let arr = []
if (this.listaccounts) {
for (const acc of this.listaccounts) {
let chi = acc.username ? acc.username : (acc.groupname ? 'Collettivo: ' + acc.groupname : 'Comunitario: ' + acc.contocom)
if (acc.circuitId) {
chi = '[' + this.getNameByCircuitId(acc.circuitId) + '] ' + chi
}
arr.push({label: chi, value: acc._id})
}
}
return arr
},
},
})

View File

@@ -18,7 +18,7 @@ export const costanti = {
},
ENABLE_FRIENDS: false,
ENABLE_CONTI_COMUNITARI: true,
ENABLE_CONTI_COLLETTIVI: true,
AccountType: {
USER: 0,

View File

@@ -2880,7 +2880,7 @@ export const colTableCircuitComplete = [
]
export const colTableCircuit = [
// AddCol({ name: 'groupnameId', label_trans: 'circuit.groupnameId', fieldtype: costanti.FieldType.select, jointable: 'mygroups' }), // da togliere poi
AddCol({ name: '_id', label_trans: 'circuit.Id' }), // da togliere poi
AddCol({
name: 'name', label_trans: 'circuit.name',
required: true,
@@ -2986,9 +2986,36 @@ export const colTableCircuit = [
]
export const colmyUserCircuit = [
AddCol({ name: 'circuitId', label_trans: 'account.circuitId', fieldtype: costanti.FieldType.string }),
AddCol({ name: 'userId', label_trans: 'account.users', fieldtype: costanti.FieldType.select, jointable: 'users' }),
AddCol({ name: 'name', label_trans: 'circuit.name' }),
AddCol({
name: 'circuitId', label_trans: 'account.circuitId',
fieldtype: costanti.FieldType.select,
jointable: 'listcircuits',
}),
AddCol({ name: 'username', label_trans: 'account.users', fieldtype: costanti.FieldType.username_chip,
tipovisu: costanti.TipoVisu.LINK }),
AddCol({
name: 'contocom',
label_trans: 'movement.accountFromComId',
foredit: false,
tipovisu: costanti.TipoVisu.LINK,
fieldtype: costanti.FieldType.username_chip,
link: '/circuits/contocom',
noshowlabel: true,
tipoconto: costanti.AccountType.COMMUNITY_ACCOUNT,
}),
AddCol({
name: 'groupname',
label_trans: 'circuit.contocoll',
foredit: false,
tipovisu: costanti.TipoVisu.LINK,
fieldtype: costanti.FieldType.username_chip,
link: '/circuits/groupname',
noshowlabel: true,
tipoconto: costanti.AccountType.COLLECTIVE_ACCOUNT,
}),
AddCol({ name: 'deperibile', label_trans: 'account.deperibile', fieldtype: costanti.FieldType.boolean }),
AddCol({ name: 'fidoConcesso', label_trans: 'account.fidoConcesso', fieldtype: costanti.FieldType.number }),
AddCol({ name: 'qta_maxConcessa', label_trans: 'account.qta_maxConcessa', fieldtype: costanti.FieldType.number }),
@@ -3022,8 +3049,10 @@ export const colTableNotifCoins = [
export const colTableMovement = [
AddCol({ name: 'transactionDate', label_trans: 'movement.transactionDate', fieldtype: costanti.FieldType.date }),
AddCol({ name: 'accountFromId', label_trans: 'movement.accountFromId', fieldtype: costanti.FieldType.string, required: true }),
AddCol({ name: 'accountToId', label_trans: 'movement.accountToId', fieldtype: costanti.FieldType.string, required: true }),
AddCol({ name: 'accountFromId', label_trans: 'movement.accountFromId', fieldtype: costanti.FieldType.select,
required: true, jointable: 'listaccounts', }),
AddCol({ name: 'accountToId', label_trans: 'movement.accountToId', fieldtype: costanti.FieldType.select,
required: true, jointable: 'listaccounts' }),
AddCol({ name: 'amount', label_trans: 'movement.amount', fieldtype: costanti.FieldType.number, required: true }),
AddCol({ name: 'causal', label_trans: 'movement.causal' }),
AddCol({ name: 'causal_table', label_trans: 'movement.causal_table' }),
@@ -3423,6 +3452,30 @@ export const fieldsTable = {
collabel: 'username',
noshow: true,
},
{
value: 'circuits',
label: 'Circuiti',
columns: colTableCircuit,
colkey: '_id',
collabel: 'name',
noshow: true,
},
{
value: 'listcircuits',
label: 'Lista Circuiti',
columns: colTableGeneric,
colkey: 'value',
collabel: 'label',
noshow: true,
},
{
value: 'listaccounts',
label: 'Lista Account',
columns: colTableGeneric,
colkey: 'value',
collabel: 'label',
noshow: true,
},
{
value: 'visibility',
label: 'Visibilità Permessi',
@@ -3710,13 +3763,6 @@ export const fieldsTable = {
colkey: 'value',
collabel: 'label',
},
{
value: 'circuits',
label: 'Circuiti',
columns: colTableCircuit,
colkey: '_id',
collabel: 'name',
},
{
value: toolsext.TABTYPEHOSP,
label: 'Tipo Ospitalità',

View File

@@ -7173,6 +7173,23 @@ export const tools = {
return []
},
async loadAccounts() {
const userStore = useUserStore()
const circuitStore = useCircuitStore()
// Carica il profilo di quest'utente
await userStore.loadAllAccounts().then((ris) => {
// console.log('ris', ris)
if (ris) {
circuitStore.listaccounts = ris.listaccounts ? ris.listaccounts : []
return true
}
})
return false
},
async loadrecProfile() {
const userStore = useUserStore()
@@ -7560,6 +7577,7 @@ export const tools = {
return myemail.search(/hotmail/i) !== -1
|| myemail.search(/outlook/i) !== -1
|| myemail.search(/live.it/i) !== -1
|| myemail.search(/live.com/i) !== -1
|| myemail.search(/microsoft/i) !== -1
},
// || myemail.search(/yahoo/i) !== -1

View File

@@ -467,13 +467,27 @@ export const useUserStore = defineStore('UserStore', {
return tools.getCommonAllRecord([...this.my.profile.handshake], [...myuser.profile.handshake], 'username')
},
getAccountByCircuitId(circuitId: string): any {
if (this.my.profile.useraccounts) {
return this.my.profile.useraccounts.find((rec: IAccount) => rec.circuitId === circuitId)
}
return null
},
getAccountsListNameValue(): any[] {
let arr = []
const circuitStore = useCircuitStore()
if (this.my.profile.useraccounts) {
for (const acc of this.my.profile.useraccounts) {
let chi = acc.username ? acc.username : (acc.groupname ? acc.groupname : acc.contocom)
if (acc.circuit) {
chi += ' (' + circuitStore.getNameByCircuitId(acc.circuitId) + ')'
}
arr.push({label: chi, value: acc._id})
}
}
return arr
},
IsRefusedCircuitByName(circuitname: string): boolean {
if (this.my.profile.refused_circuits)
@@ -482,7 +496,6 @@ export const useUserStore = defineStore('UserStore', {
return false
},
getImgByCircuit(circ: ICircuit | null): string {
try {
@@ -500,7 +513,6 @@ export const useUserStore = defineStore('UserStore', {
return this.getImgByCircuit(mycirc)
},
getImgByGroup(group: IMyGroup | null): string {
try {
@@ -607,9 +619,15 @@ export const useUserStore = defineStore('UserStore', {
name = myrec.dest
}
} else if (tipoconto === costanti.AccountType.COLLECTIVE_ACCOUNT) {
return myrec.descr
if (myrec.hasOwnProperty('descr'))
return myrec.descr
else if (myrec.hasOwnProperty('groupname'))
return myrec.groupname
} else if (tipoconto === costanti.AccountType.COMMUNITY_ACCOUNT) {
return myrec.name
if (myrec.hasOwnProperty('name'))
return myrec.name
else if (myrec.hasOwnProperty('contocom'))
return myrec.contocom
}
return name
@@ -1413,6 +1431,16 @@ export const useUserStore = defineStore('UserStore', {
},
async loadAllAccounts() {
return Api.SendReq('/account/loadall', 'POST', null)
.then((res) => {
return res.data
}).catch((error) => {
return {}
})
},
async setFriendsCmd($q: any, t: any, usernameOrig: string, usernameDest: string, cmd: number, value: any) {
return Api.SendReq('/users/friends/cmd', 'POST', { usernameOrig, usernameDest, cmd, value })
.then((res) => {

View File

@@ -182,7 +182,7 @@ export const useGlobalStore = defineStore('GlobalStore', {
mygroups: [],
selElem: {},
editOn: false,
myselector: { data: {}, table: ''},
myselector: { data: {}, table: '' },
addNewRecord: '',
isAppRunning: false,
deferredPrompt: null,
@@ -254,6 +254,7 @@ export const useGlobalStore = defineStore('GlobalStore', {
let ris: any = []
const calendarStore = useCalendarStore()
const circuitStore = useCircuitStore()
const userStore = useUserStore()
const messageStore = useMessageStore()
const notifStore = useNotifStore()
@@ -285,6 +286,9 @@ export const useGlobalStore = defineStore('GlobalStore', {
else if (table === 'departments') ris = state.departments
else if (table === 'sharewithus') ris = state.sharewithus
else if (table === 'paymenttypes') ris = state.paymenttypes
else if (table === 'circuits') ris = circuitStore.listcircuits
else if (table === 'listcircuits') ris = circuitStore.getCircuitsLabelValue()
else if (table === 'listaccounts') ris = circuitStore.getAccountsListNameValue()
else if (table === 'bookings')
return calendarStore.bookedevent
else if (table === 'users')
@@ -491,6 +495,8 @@ export const useGlobalStore = defineStore('GlobalStore', {
infooter: true,
}
// console.log('Sito Online? ', toolsext.sito_online(false))
if (!toolsext.sito_online(false)) {
static_data.routes = [sito_offline, last]
} else {
@@ -519,8 +525,26 @@ export const useGlobalStore = defineStore('GlobalStore', {
if (!$router.hasRoute(route.name)) {
$router.addRoute(route)
}
if (route.routes2) {
for (const route2 of route.routes2) {
if (!$router.hasRoute(route2.name)) {
$router.addRoute(route2)
}
if (route2.routes2) {
for (const route3 of route2.routes2) {
if (!$router.hasRoute(route3.name)) {
$router.addRoute(route3)
}
}
}
}
}
})
if (!tools.sito_online(false)) {
$router.replace('/sito_offline')
}
@@ -1458,6 +1482,7 @@ export const useGlobalStore = defineStore('GlobalStore', {
calendarStore.contribtype = (res.data.contribtype) ? res.data.contribtype : []
circuitStore.listcircuits = (res.data.listcircuits) ? res.data.listcircuits : []
circuitStore.listaccounts = (res.data.listaccounts) ? res.data.listaccounts : []
this.settings = (res.data.settings) ? [...res.data.settings] : []
this.disciplines = (res.data.disciplines) ? [...res.data.disciplines] : []
@@ -1483,7 +1508,6 @@ export const useGlobalStore = defineStore('GlobalStore', {
this.mygroups = (res.data.mygroups) ? [...res.data.mygroups] : []
this.adtypes = (res.data.adtypes) ? [...res.data.adtypes] : []
this.adtypegoods = (res.data.adtypegoods) ? [...res.data.adtypegoods] : []
circuitStore.listcircuits = (res.data.listcircuits) ? [...res.data.listcircuits] : []
// console.log('res.data.cart', res.data.cart)
@@ -1750,7 +1774,13 @@ export const useGlobalStore = defineStore('GlobalStore', {
if (costanti.TABLES_ARRAY.includes(table)) {
const newarr = []
for (const value of myarr) {
newarr.push({ value, label: value })
let label = value
if (table === 'mygroups')
label = value.descr
else if (table === 'circuits')
label = value.name
newarr.push({ value, label })
}
myarr = newarr
@@ -1814,7 +1844,7 @@ export const useGlobalStore = defineStore('GlobalStore', {
const collab = fieldsTable.getLabelByTable(col.jointable)
for (let index = 0; index < myarrtab.length; index++) {
let obj = {label: '', value: 0}
let obj = { label: '', value: 0 }
obj.label = myarrtab[index][collab]
obj.value = myarrtab[index][key]
myarrrec.push(obj)