fix: non riuscivi ad acquistare i RIS al gruppo

- lista linkREG
This commit is contained in:
Surya Paolo
2025-03-23 22:53:53 +01:00
parent 4c82015f27
commit 2ba26f67cd
103 changed files with 3000 additions and 1164 deletions

View File

@@ -60,6 +60,7 @@ export const costanti = {
ACTIONTYPE: {
NONE: 0,
SEND_RIS: 1,
LINK_REG: 2,
},
Lang: {

View File

@@ -8002,61 +8002,77 @@ export const tools = {
return arr1.some((item: any) => arr2.includes(item))
},
// Function to return commonElements
getCommon(arr1: any, arr2: any, field: string): any[] {
// @ts-ignore
arr1.sort((a: any, b: any) => (a[field] > b[field]) - (a[field] < b[field])) // Sort both the arrays
// @ts-ignore
arr2.sort((a: any, b: any) => (a[field] > b[field]) - (a[field] < b[field]))
// Function to return common elements between two arrays
getCommon(arr1: any[], arr2: any[], field1: string, field2: string): any[] {
// Assicurati che gli array non siano null o undefined
if (!Array.isArray(arr1) || !Array.isArray(arr2)) {
console.error("Entrambi gli input devono essere array.");
return [];
}
// console.log('arr1', arr1)
// console.log('arr2', arr2)
const common = [] // Array to contain common elements
let i = 0, j = 0 // i points to arr1 and j to arr2
// Break if one of them runs out
// Ordina entrambi gli array in base ai campi specificati
arr1.sort((a, b) => (a[field1] > b[field1] ? 1 : a[field1] < b[field1] ? -1 : 0));
arr2.sort((a, b) => (a[field2] > b[field2] ? 1 : a[field2] < b[field2] ? -1 : 0));
const common: any[] = []; // Array per contenere gli elementi comuni
let i = 0, j = 0; // Indici per iterare sugli array
// Itera finché non si esaurisce uno dei due array
while (i < arr1.length && j < arr2.length) {
const value1 = arr1[i][field1];
const value2 = arr2[j][field2];
if (arr1[i][field] == arr2[j][field]) { // If both are same, add it to result
common.push(arr1[i][field])
i++
j++
} else if (arr1[i][field] < arr2[j][field]) { // Increment the smaller value so that
i++ // it could be matched with the larger
} // element
else {
j++
if (value1 === value2) {
// Se i valori sono uguali, aggiungi l'elemento al risultato
common.push(value1);
i++;
j++;
} else if (value1 < value2) {
// Incrementa l'indice dell'array con il valore minore
i++;
} else {
j++;
}
}
return common
return common;
},
// Function to return commonElements
getCommonAllRecord(arr1: any, arr2: any, field: string): any[] {
// @ts-ignore
arr1.sort((a: any, b: any) => (a[field] > b[field]) - (a[field] < b[field])) // Sort both the arrays
// @ts-ignore
arr2.sort((a: any, b: any) => (a[field] > b[field]) - (a[field] < b[field]))
// Function to return common objects between two arrays based on a specific field
getCommonAllRecord(arr1: any[], arr2: any[], field: string): any[] {
// Assicurati che gli array non siano null o undefined
if (!Array.isArray(arr1) || !Array.isArray(arr2)) {
console.error("Entrambi gli input devono essere array.");
return [];
}
// console.log('arr1', arr1)
// console.log('arr2', arr2)
const common = [] // Array to contain common elements
let i = 0, j = 0 // i points to arr1 and j to arr2
// Break if one of them runs out
// Ordina entrambi gli array in base al campo specificato
arr1.sort((a, b) => (a[field] > b[field] ? 1 : a[field] < b[field] ? -1 : 0));
arr2.sort((a, b) => (a[field] > b[field] ? 1 : a[field] < b[field] ? -1 : 0));
const common: any[] = []; // Array per contenere gli oggetti comuni
let i = 0, j = 0; // Indici per iterare sugli array
// Itera finché non si esaurisce uno dei due array
while (i < arr1.length && j < arr2.length) {
const value1 = arr1[i][field];
const value2 = arr2[j][field];
if (arr1[i][field] == arr2[j][field]) { // If both are same, add it to result
common.push(arr1[i])
i++
j++
} else if (arr1[i][field] < arr2[j][field]) { // Increment the smaller value so that
i++ // it could be matched with the larger
} // element
else {
j++
if (value1 === value2) {
// Se i valori sono uguali, aggiungi l'intero oggetto di arr1 al risultato
common.push(arr1[i]);
i++;
j++;
} else if (value1 < value2) {
// Incrementa l'indice dell'array con il valore minore
i++;
} else {
j++;
}
}
return common
return common;
},
isTypeByRecMov(rec: IMovVisu) {
@@ -8439,6 +8455,23 @@ export const tools = {
},
async addToTemporaryLinkReg(t: any) {
const userStore = useUserStore()
const username = userStore.my.username
return await userStore.seListLinkReg(username, '')
.then((data) => {
if (data.code === serv_constants.RIS_CODE_OK) {
return { msg: t('circuit.listlinkreg', { username }), ris: true }
} else {
return { msg: t('db.recfailed'), ris: false }
}
})
},
async receiveRisGroup(groupname: string, $q: any, t: any) {
const userStore = useUserStore()
@@ -9499,14 +9532,14 @@ export const tools = {
rec.testo_right = tools.resetIText(rec?.testo_right)
rec.testo_bottom = tools.resetIText(rec?.testo_bottom)
rec.dimensioni = {pagina: null, riga: null, scheda_prodotto: {}, immagine_prodotto: {}}
rec.dimensioni = { pagina: null, riga: null, scheda_prodotto: {}, immagine_prodotto: {} }
rec.dimensioni.pagina = tools.resetRecIPagina({})
rec.testo_right_attaccato = tools.resetIText({})
rec.testo_right = tools.resetIText({})
rec.testo_bottom = tools.resetIText({})
return rec
},
},
resetIBorder(rec: IBorder | null) {
if (!rec) {
@@ -9777,7 +9810,7 @@ export const tools = {
keycookie: '',
addall: true,
arrvalue: [],
filter: () => {},
filter: () => { },
useinput: false,
icon: 'fas fa-user'
}]

View File

@@ -86,6 +86,7 @@ export const DefaultUser: IUserFields = {
mygroups: [],
mycircuits: [],
last_circuitpath: '',
lastdate_LinkReg: tools.getLastDateReadReset(),
lastdate_reqRis: tools.getLastDateReadReset(),
manage_mygroups: [],
userstoverify: [],
@@ -550,20 +551,10 @@ export const useUserStore = defineStore('UserStore', {
},
getMyCircuitsInCommonByUser(user: IUserFields): any[] {
let arrout = []
addarrfinale(arrout: any): any[] {
let arrfinale = []
let vuoto = false
const circuitStore = useCircuitStore()
if (!this.my.profile.mycircuits || (!user || !user.profile || !user.profile.mycircuits))
vuoto = true // ok
else
arrout = tools.getCommon([...this.my.profile.mycircuits], [...user.profile.mycircuits], 'circuitname')
// controlla che il circuito sia Abilitato e Territoriale !
for (const circuitname of arrout) {
const circuit = circuitStore.getCircuitByName(circuitname)
@@ -580,22 +571,30 @@ export const useUserStore = defineStore('UserStore', {
}
}
// se non ho neanche 1 circuito in comune, metto il mio preferito
/*if (arrfinale.length <= 0) {
const circuit = circuitStore.getCircuitByProvince(this.my.profile.resid_province)
if (circuit)
arrfinale.push(circuit.name)
else {
if (this.my.profile.mycircuits.length > 0) {
arrfinale.push(this.my.profile.mycircuits[0].circuitname)
}
}
} else {
} */
// console.log('arrout', arrfinale)
return arrfinale
},
getMyCircuitsInCommonByUser(user: IUserFields): any[] {
let arrout = []
let vuoto = false
if (!this.my.profile.mycircuits || (!user || !user.profile || !user.profile.mycircuits))
vuoto = true // ok
else
arrout = tools.getCommon([...this.my.profile.mycircuits], [...user.profile.mycircuits], 'circuitname', 'circuitname')
return this.addarrfinale(arrout)
},
getMyCircuitsInCommonByGroup(group: IMyGroup): any[] {
console.log('this.my.profile.mycircuits', this.my.profile.mycircuits)
if (!this.my.profile.mycircuits || (!group || !group.mycircuits))
return []
const arrout = tools.getCommon([...this.my.profile.mycircuits], [...group.mycircuits], 'circuitname', 'name')
return this.addarrfinale(arrout)
},
getMyCircuits(): any[] {
@@ -605,12 +604,6 @@ export const useUserStore = defineStore('UserStore', {
return this.my.profile.mycircuits.map(item => item.circuitname)
},
getMyCircuitsInCommonByGroup(group: IMyGroup): any[] {
if (!this.my.profile.mycircuits || (!group || !group.mycircuits))
return []
return tools.getCommon([...this.my.profile.mycircuits], [...group.mycircuits], 'circuitname')
},
getMyHandshakeInCommon(myuser: IUserFields): any[] {
@@ -1727,6 +1720,21 @@ export const useUserStore = defineStore('UserStore', {
return {}
})
},
async seListLinkReg(username: string, groupname: string) {
const data = {
username,
groupname,
}
return Api.SendReq('/users/listlinkreg', 'POST', data)
.then((ris) => {
console.log('out:', ris)
return ris.data
}).catch((error) => {
return {}
})
},
async loadGroup(groupname: string, idnotif: string) {