- fix RIS in pendenti, se troppi msg, non compariva piu

- cataloghi, ricerca pickup
This commit is contained in:
Surya Paolo
2024-05-09 23:36:58 +02:00
parent 58f53f8c52
commit faf0fabfb0
68 changed files with 1776 additions and 188 deletions

View File

@@ -2098,6 +2098,7 @@ export const colTableOrdersCart = [
export const colTableProducts = [
AddCol({ name: 'active', label_trans: 'products.active', fieldtype: costanti.FieldType.boolean }),
AddCol({ name: 'isbn', label_trans: 'products.isbn' }),
AddCol({ name: 'name', label_trans: 'products.name' }),
AddCol({
name: 'idProductInfo',
label_trans: 'products.productInfo',
@@ -3703,6 +3704,7 @@ export const fieldsTable = {
'countries',
'phones',
'cities',
'products',
],
tableWithUsername: [
@@ -3767,7 +3769,7 @@ export const fieldsTable = {
label: 'Prodotti',
columns: colTableProducts,
colkey: '_id',
collabel: '_id',
collabel: 'name',
},
{
value: 'orderscarts',

View File

@@ -5806,6 +5806,9 @@ export const tools = {
if (res && res.arrrecnotif) {
notifStore.updateArrRecNotifFromServer(res.arrrecnotif)
}
if (res && res.arrrecnotifcoins) {
notifStore.updateArrRecNotifCoinsFromServer(res.arrrecnotifcoins)
}
if (res && res.userprofile) {
// console.log('updateMyData', res.userprofile)
@@ -7000,10 +7003,14 @@ export const tools = {
},
getValueByFunzOrVal(value: any, keyfunz: any) {
if (typeof keyfunz === 'function') {
return keyfunz(value)
} else {
return value[keyfunz]
try {
if (typeof keyfunz === 'function') {
return keyfunz(value)
} else {
return value[keyfunz]
}
} catch (e) {
return ''
}
},
@@ -7712,7 +7719,7 @@ export const tools = {
isTypeByRecMov(rec: IMovVisu) {
let type = costanti.TypeMov.Nessuno
if (rec && rec.userfrom) {
if (rec && (rec.userfrom || rec.userto || rec.groupfrom || rec.groupto)) {
const userStore = useUserStore()
if (rec.userfrom && userStore.my.username === rec.userfrom.username) {
type = costanti.TypeMov.Uscita
@@ -7732,6 +7739,11 @@ export const tools = {
return this.isTypeByRecMov(rec) === costanti.TypeMov.Entrata
},
isUscitaByRecMov(rec: IMovVisu) {
return this.isTypeByRecMov(rec) === costanti.TypeMov.Uscita
},
getSymbolByCircuit(circuit: any) {
try {
if (circuit.symbol) {
@@ -8584,7 +8596,7 @@ export const tools = {
return color
},
getIconByVersione (versione: number ) {
getIconByVersione(versione: number) {
let str = ''
if (versione === shared_consts.VERSIONE.NUOVO)
str = 'fas fa-book'
@@ -8615,8 +8627,42 @@ export const tools = {
// get the last 2 digit fraction part, of a decimal number
getDecPart2Digit(number: number) {
return Math.round(number * 100) % 100
}
return Math.round(number * 100) % 100
},
getRecordByField(field: any, record: any) {
let mioval = ''
if (field) {
const arrfields = field.split('.')
if (arrfields && arrfields.length > 0) {
try {
mioval = record[arrfields[0]][arrfields[1]]
} catch (e) {
return ''
}
} else {
mioval = record[field]
}
}
return mioval
},
setRecordByField(field: any, record: any, value: any) {
let mioval = ''
if (field) {
const arrfields = field.split('.')
if (arrfields && arrfields.length > 1) {
try {
record[arrfields[0]][arrfields[1]] = value
} catch (e) {
return record
}
} else {
record[field] = value
}
}
return record
},
// FINE !

View File

@@ -12,6 +12,7 @@ import { useUserStore } from '@store/UserStore'
export const useNotifStore = defineStore('NotifStore', {
state: (): INotifState => ({
last_notifs: [],
last_notifcoins: [],
show_all: true,
updateNotification: false,
countNotif: 0,
@@ -26,14 +27,14 @@ export const useNotifStore = defineStore('NotifStore', {
},
getlasts_coins: (mystate: INotifState) => (): INotif[] => {
const ctrec = (mystate.last_notifs) ? mystate.last_notifs.slice(0, 20).filter((rec) => (mystate.show_all ? true : !rec.read) && (rec.typedir === shared_consts.TypeNotifs.TYPEDIR_CIRCUITS)) : []
const ctrec = (mystate.last_notifcoins) ? mystate.last_notifcoins.filter((rec) => (mystate.show_all ? true : !rec.read) && (rec.typedir === shared_consts.TypeNotifs.TYPEDIR_CIRCUITS)) : []
return (ctrec)
},
getnotifs_coinsreq: (mystate: INotifState) => (): INotif[] => {
const ctrec = (mystate.last_notifs) ? mystate.last_notifs.slice(0, 20).filter((rec) => rec.typedir === shared_consts.TypeNotifs.TYPEDIR_CIRCUITS && rec.typeid === shared_consts.TypeNotifs.ID_CIRCUIT_SENDCOINSREQ && rec.status === shared_consts.CircuitsNotif.STATUS_NONE) : []
const ctrec = (mystate.last_notifcoins) ? mystate.last_notifcoins.filter((rec) => rec.typedir === shared_consts.TypeNotifs.TYPEDIR_CIRCUITS && rec.typeid === shared_consts.TypeNotifs.ID_CIRCUIT_SENDCOINSREQ && rec.status === shared_consts.CircuitsNotif.STATUS_NONE) : []
return (ctrec)
},
@@ -44,7 +45,7 @@ export const useNotifStore = defineStore('NotifStore', {
},
getnumCoinsUnread: (mystate: INotifState) => () => {
const myarr = mystate.last_notifs.filter((notif) => !notif.read && (notif.typedir === shared_consts.TypeNotifs.TYPEDIR_CIRCUITS))
const myarr = mystate.last_notifcoins.filter((notif) => !notif.read && (notif.typedir === shared_consts.TypeNotifs.TYPEDIR_CIRCUITS))
return (tools.isArray(myarr) ? myarr.length : 0)
},
@@ -85,6 +86,18 @@ export const useNotifStore = defineStore('NotifStore', {
}
}
},
updateRecNotifCoins(recnotif: INotif) {
if (recnotif) {
const myrec = this.last_notifcoins.find((rec: any) => rec._id === recnotif._id)
if (myrec) {
myrec.status = recnotif.status
myrec.read = recnotif.read
myrec.descr = recnotif.descr
this.updateArrNotif()
}
}
},
updateArrRecNotifFromServer(arrrecnotif: INotif[]) {
// console.log('arrrecnotif', arrrecnotif)
if (arrrecnotif && arrrecnotif.length > 0) {
@@ -93,6 +106,14 @@ export const useNotifStore = defineStore('NotifStore', {
this.updateArrNotif()
}
},
updateArrRecNotifCoinsFromServer(arrrecnotifcoins: INotif[]) {
// console.log('arrrecnotif', arrrecnotif)
if (arrrecnotifcoins && arrrecnotifcoins.length > 0) {
this.last_notifcoins = arrrecnotifcoins
this.updateArrNotif()
}
},
async setBadgeIconApp() {
// Get our dummy count and update it,
@@ -129,12 +150,17 @@ export const useNotifStore = defineStore('NotifStore', {
})
},
setRead(_id: string) {
setRead(_id: string, notifcoins: boolean) {
return Api.SendReq(`/sendnotif/set/${_id}/${process.env.APP_ID}`, 'GET', null)
.then((res) => {
// console.log('res', res)
if (res) {
const rec = this.last_notifs.find((rec: any) => rec._id === _id)
let rec = null
if (!notifcoins)
rec = this.last_notifs.find((rec: any) => rec._id === _id)
else
rec = this.last_notifcoins.find((rec: any) => rec._id === _id)
if (rec) {
rec.read = true
}
@@ -148,12 +174,15 @@ export const useNotifStore = defineStore('NotifStore', {
})
},
deleteRec(username: string, id: string) {
deleteRec(username: string, id: string, notifcoins: boolean) {
return Api.SendReq(`/sendnotif/del/${username}/${id}/${process.env.APP_ID}`, 'GET', null)
.then((res) => {
// console.log('res', res)
if (res) {
this.last_notifs = this.last_notifs.filter((rec) => rec._id !== id)
if (!notifcoins)
this.last_notifs = this.last_notifs.filter((rec) => rec._id !== id)
else
this.last_notifcoins = this.last_notifcoins.filter((rec) => rec._id !== id)
}
this.updateArrNotif()
@@ -171,9 +200,9 @@ export const useNotifStore = defineStore('NotifStore', {
// console.log('res', res)
if (res) {
if (qualinotif === shared_consts.QualiNotifs.CIRCUITS)
this.last_notifs = this.last_notifs.filter((rec: INotif) => rec.typedir !== shared_consts.TypeNotifs.TYPEDIR_CIRCUITS)
this.last_notifcoins = []
else if (qualinotif === shared_consts.QualiNotifs.OTHERS)
this.last_notifs = this.last_notifs.filter((rec: INotif) => rec.typedir === shared_consts.TypeNotifs.TYPEDIR_CIRCUITS)
this.last_notifs = []
this.updateArrNotif()
}
@@ -189,16 +218,22 @@ export const useNotifStore = defineStore('NotifStore', {
return ''
},
async updateNotifDataFromServer({ username, lastdataread }: { username: string, lastdataread: Date }) {
async updateNotifDataFromServer({ username, lastdataread, qualinotif }: { username: string, lastdataread: Date, qualinotif: number }) {
// console.log('updateNotifDataFromServer', username, lastdataread)
return Api.SendReq(`/sendnotif/${username}/${lastdataread}/${process.env.APP_ID}`, 'GET', null)
return Api.SendReq(`/sendnotif/${username}/${lastdataread}/${process.env.APP_ID}/${qualinotif}`, 'GET', null)
.then((res) => {
// console.log('res', res)
if (!!res.data && !!res.data.arrnotif) {
this.last_notifs = res.data.arrnotif
if (qualinotif === shared_consts.QualiNotifs.CIRCUITS)
this.last_notifcoins = res.data.arrnotif
else
this.last_notifs = res.data.arrnotif
} else {
this.last_notifs = []
if (qualinotif === shared_consts.QualiNotifs.CIRCUITS)
this.last_notifcoins = []
else
this.last_notifs = []
}
this.updateArrNotif()
tools.updateMyData(res.data.ris)

View File

@@ -1,4 +1,4 @@
import { IBaseOrder, ICart, IOrder, IOrderCart, IProduct, IProductsState, IProductInfo, ICatProd, IUserShort, IGasordine } from 'model'
import { IBaseOrder, ICart, IOrder, IOrderCart, IProduct, IProductsState, IProductInfo, ICatProd, IUserShort, IGasordine, IAuthor } from 'model'
import { Api } from '@api'
import { serv_constants } from '@src/store/Modules/serv_constants'
@@ -107,6 +107,7 @@ export const useProducts = defineStore('Products', {
orders: [],
catprods: [],
catprods_gas: [],
authors: [],
subcatprods: [],
productInfos: [],
userActive: { username: '', name: '', surname: '', _id: '' },
@@ -123,6 +124,24 @@ export const useProducts = defineStore('Products', {
},
getAuthors: (state: IProductsState) => (): any[] => {
// Get the list of authors, for the q-select component using state.authors array
// [{name: xxx, value: _id }]
// add default value for q-select
const options = [
{
label: '[Tutti]',
value: '',
},
...state.authors.map((rec: IAuthor) => {
return { label: rec.name + (rec.surname ? ' ' + rec.surname : ''), value: rec._id }
}),
]
return options
},
getNumProdTot: (state: IProductsState) => (): number => {
return state.products.length
},

View File

@@ -1647,6 +1647,9 @@ export const useUserStore = defineStore('UserStore', {
if (res && res.data.arrrecnotif) {
notifStore.updateArrRecNotifFromServer(res.data.arrrecnotif)
}
if (res && res.data.arrrecnotifcoins) {
notifStore.updateArrRecNotifCoinsFromServer(res.data.arrrecnotifcoins)
}
if (res.data.useraccounts && res.data.useraccounts.length > 0) {
this.my.profile.useraccounts = res.data.useraccounts
}
@@ -1782,12 +1785,15 @@ export const useUserStore = defineStore('UserStore', {
return await Api.SendReq('/users/circuits/cmd', 'POST', { usernameOrig, circuitname, cmd, value, extrarec })
.then((res) => {
this.updateTables = true
const notifStore = useNotifStore()
if (res.data.recnotif) {
const notifStore = useNotifStore()
notifStore.updateRecNotif(res.data.recnotif)
notifStore.updateArrRecNotifFromServer(res.data.arrrecnotif)
if (res.data.recnotif.typedir === shared_consts.TypeNotifs.TYPEDIR_CIRCUITS) {
notifStore.updateRecNotifCoins(res.data.recnotif)
notifStore.updateArrRecNotifCoinsFromServer(res.data.arrrecnotifcoins)
} else {
notifStore.updateRecNotif(res.data.recnotif)
notifStore.updateArrRecNotifFromServer(res.data.arrrecnotif)
}
}
return res.data
}).catch((error) => {

View File

@@ -329,7 +329,7 @@ export const useGlobalStore = defineStore('GlobalStore', {
else if (table === 'storehouses') ris = state.storehouses
else if (table === 'providers') ris = state.providers
else if (table === 'productinfos') ris = Products.productInfos
else if (table === 'product') ris = Products.products
// else if (table === 'products') ris = Products.products
else if (table === 'gasordines') ris = state.gasordines
else if (table === 'scontisticas') ris = state.scontisticas
else if (table === 'groups') ris = state.groups
@@ -339,6 +339,7 @@ export const useGlobalStore = defineStore('GlobalStore', {
else if (table === 'categorys') ris = state.categories
else if (table === 'catprods') ris = Products.catprods
else if (table === 'catprods_gas') ris = Products.catprods_gas
else if (table === 'authors') ris = Products.authors
else if (table === 'catais') ris = state.catAI
else if (table === 'queryais') ris = state.queryAIList
else if (table === 'sharewithus') ris = state.sharewithus
@@ -1573,6 +1574,7 @@ export const useGlobalStore = defineStore('GlobalStore', {
Products.catprods = (res.data.catprods) ? [...res.data.catprods] : []
Products.catprods_gas = (res.data.catprods_gas) ? [...res.data.catprods_gas] : []
Products.authors = (res.data.authors) ? [...res.data.authors] : []
this.gasordines = (res.data.gasordines) ? [...res.data.gasordines] : []
this.scontisticas = (res.data.scontisticas) ? [...res.data.scontisticas] : []