fix: non riuscivi ad acquistare i RIS al gruppo
- lista linkREG
This commit is contained in:
@@ -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'
|
||||
}]
|
||||
|
||||
Reference in New Issue
Block a user