mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 04:57:52 +00:00
fix
This commit is contained in:
@@ -9,114 +9,36 @@ import { isArray } from 'ionic-angular/umd/util/util';
|
||||
export class EventoaprovacaoStoreService {
|
||||
|
||||
// main data
|
||||
private _listPr: any[] = []
|
||||
private _listMd: any[] = []
|
||||
private _list: {[key: string]: any[]} = {}
|
||||
private _concatList = []
|
||||
|
||||
// local storage keyName
|
||||
private keyNamemd: string;
|
||||
private keyNamepr: string;
|
||||
private keyNameAll: string;
|
||||
|
||||
private _counts : {[key: string]: number} = {}
|
||||
private _countsAll = 0
|
||||
private _count = 0
|
||||
private _countPr = 0
|
||||
private _countMd = 0
|
||||
|
||||
constructor() {
|
||||
|
||||
this.keyNamemd = (SHA1("EventoaprovacaoStoreService"+"md")).toString()
|
||||
this.keyNamepr = (SHA1("EventoaprovacaoStoreService"+"pr")).toString()
|
||||
this.keyNameAll = (SHA1("EventoaprovacaoStoreService"+"all")).toString()
|
||||
|
||||
|
||||
setTimeout(()=>{
|
||||
let restoreMd = localstoreService.get(this.keyNamemd, [])
|
||||
let restorePr = localstoreService.get(this.keyNamepr, [])
|
||||
let {list , counts} = localstoreService.get(this.keyNameAll, {})
|
||||
|
||||
this._listPr = restorePr.listPr || []
|
||||
this._listMd = restoreMd.lisMd || []
|
||||
this._countMd = parseInt(restoreMd.countListMd) || 0
|
||||
this._countPr = parseInt(restorePr.countListPr) || 0
|
||||
this._count = (this._countMd + this._countPr) || 0
|
||||
this._list = list || {}
|
||||
|
||||
this.updateCount();
|
||||
}, 10)
|
||||
|
||||
}
|
||||
|
||||
get listpr() { return this._listPr || [] }
|
||||
get listmd() { return this._listMd || [] }
|
||||
|
||||
get count() { return this._count || 0 }
|
||||
set count(value: number) {
|
||||
this._count = value
|
||||
get countAll() {
|
||||
return this._countsAll
|
||||
}
|
||||
|
||||
get countPr() { return this._countPr || 0 }
|
||||
set countPr (value: number) {
|
||||
this._countPr = value
|
||||
}
|
||||
|
||||
get countMd() { return this._countMd || 0 }
|
||||
set countMd (value) {
|
||||
this._countMd = value
|
||||
}
|
||||
|
||||
resetpr(eventsList: any) {
|
||||
if(Array.isArray(eventsList)) {
|
||||
this._listPr = eventsList
|
||||
|
||||
this.countPr = this._listPr.length
|
||||
this.count = this.countPr + this.countMd
|
||||
|
||||
this.savePr()
|
||||
|
||||
if(window['all-process']) {
|
||||
window['all-process']()
|
||||
}
|
||||
if(window['all-process-gabinete']) {
|
||||
window['all-process-gabinete']()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
resetmd(eventsList: any) {
|
||||
if(Array.isArray(eventsList)) {
|
||||
this._listMd = eventsList
|
||||
|
||||
this.countMd = this._listMd.length
|
||||
this.count = this.countPr + this.countMd
|
||||
this.saveMd()
|
||||
|
||||
|
||||
if(window['all-process']) {
|
||||
window['all-process']()
|
||||
}
|
||||
if(window['all-process-gabinete']) {
|
||||
window['all-process-gabinete']()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private saveMd() {
|
||||
setTimeout(()=>{
|
||||
localstoreService.set(this.keyNamemd,{
|
||||
lisMd: this._listMd,
|
||||
countListMd: this._countMd
|
||||
})
|
||||
}, 10)
|
||||
|
||||
}
|
||||
|
||||
private savePr() {
|
||||
setTimeout(()=>{
|
||||
localstoreService.set(this.keyNamepr,{
|
||||
listPr: this._listPr,
|
||||
countListPr: this._countPr
|
||||
})
|
||||
}, 10)
|
||||
|
||||
get contactList() {
|
||||
return this._concatList
|
||||
}
|
||||
|
||||
|
||||
@@ -134,8 +56,28 @@ export class EventoaprovacaoStoreService {
|
||||
|
||||
setTimeout(() => {
|
||||
localstoreService.set(this.keyNameAll,{
|
||||
_list: this._list,
|
||||
_counts: this._counts
|
||||
list: this._list,
|
||||
counts: this._counts
|
||||
})
|
||||
}, 10)
|
||||
|
||||
|
||||
if(window['all-process']) {
|
||||
window['all-process']()
|
||||
}
|
||||
if(window['all-process-gabinete']) {
|
||||
window['all-process-gabinete']()
|
||||
}
|
||||
}
|
||||
|
||||
clear() {
|
||||
this._list = {}
|
||||
this._counts = {}
|
||||
|
||||
setTimeout(() => {
|
||||
localstoreService.set(this.keyNameAll,{
|
||||
list: this._list,
|
||||
counts: this._counts
|
||||
})
|
||||
}, 10)
|
||||
}
|
||||
@@ -145,13 +87,18 @@ export class EventoaprovacaoStoreService {
|
||||
}
|
||||
|
||||
updateCount() {
|
||||
let count = 0
|
||||
|
||||
let allList = []
|
||||
|
||||
for(let [name, value] of Object.entries(this._list)) {
|
||||
count = count + value.length
|
||||
allList = allList.concat(value)
|
||||
}
|
||||
this._countsAll = count
|
||||
|
||||
this._countsAll = allList.length
|
||||
this._concatList = allList
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
export const EventoAprovacaoStore = new EventoaprovacaoStoreService()
|
||||
|
||||
Reference in New Issue
Block a user