2021-07-22 16:09:47 +01:00
|
|
|
import { Injectable } from '@angular/core';
|
|
|
|
|
import { localstoreService } from './localstore.service'
|
|
|
|
|
import { AES, enc, SHA1 } from 'crypto-js'
|
|
|
|
|
|
|
|
|
|
@Injectable({
|
|
|
|
|
providedIn: 'root'
|
|
|
|
|
})
|
|
|
|
|
export class PedidosStoreService {
|
|
|
|
|
|
2021-07-30 16:55:13 +01:00
|
|
|
private _listParecer: Event[] = []
|
|
|
|
|
private _listDeferimento: Event[] = []
|
2021-07-22 16:09:47 +01:00
|
|
|
// local storage keyName
|
|
|
|
|
private keyNameparecer: string;
|
|
|
|
|
private keyNamedeferiemnto: string;
|
2021-07-23 05:43:52 +01:00
|
|
|
private _countparecer = 0
|
2021-07-30 16:55:13 +01:00
|
|
|
private _countDeferiemnto = 0
|
2021-07-22 16:09:47 +01:00
|
|
|
|
|
|
|
|
constructor() {
|
|
|
|
|
|
2023-01-12 15:27:09 +01:00
|
|
|
this.keyNameparecer = (SHA1("PedidosStoreService"+"parecer")).toString()
|
|
|
|
|
this.keyNamedeferiemnto = (SHA1("PedidosStoreService"+"deferimneto")).toString()
|
2021-07-22 16:09:47 +01:00
|
|
|
|
|
|
|
|
setTimeout(()=>{
|
2021-07-30 16:55:13 +01:00
|
|
|
let restoreParecer = localstoreService.get(this.keyNameparecer, {})
|
|
|
|
|
let restoreDeferimento = localstoreService.get(this.keyNamedeferiemnto, {})
|
2021-07-23 16:05:43 +01:00
|
|
|
|
2021-07-30 16:55:13 +01:00
|
|
|
this._listParecer = restoreDeferimento.listDeferimento || []
|
|
|
|
|
this._listDeferimento = restoreParecer.listParecer || []
|
|
|
|
|
this._countparecer = parseInt(restoreParecer.count) || 0
|
|
|
|
|
this._countDeferiemnto = parseInt(restoreDeferimento.count) || 0
|
2021-07-23 16:05:43 +01:00
|
|
|
|
2021-07-22 16:09:47 +01:00
|
|
|
}, 10)
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-23 14:54:40 +01:00
|
|
|
get listparecer(): any[] {
|
|
|
|
|
return this._listParecer || []
|
2021-07-22 16:09:47 +01:00
|
|
|
}
|
|
|
|
|
|
2022-05-23 14:54:40 +01:00
|
|
|
get listdeferimento(): any[] {
|
|
|
|
|
return this._listDeferimento || []
|
2021-07-30 16:55:13 +01:00
|
|
|
}
|
|
|
|
|
|
2021-07-23 05:43:52 +01:00
|
|
|
get countparecer() {
|
2021-08-25 08:51:52 +01:00
|
|
|
return this._countparecer || 0
|
2021-07-22 16:09:47 +01:00
|
|
|
}
|
2021-07-23 10:35:53 +01:00
|
|
|
set countparecer(value: number) {
|
2021-07-23 05:43:52 +01:00
|
|
|
this._countparecer = value
|
2021-07-30 16:55:13 +01:00
|
|
|
this.saveParecer()
|
2021-07-23 05:43:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get countdeferimento() {
|
2021-08-25 08:51:52 +01:00
|
|
|
return this._countDeferiemnto || 0
|
2021-07-23 05:43:52 +01:00
|
|
|
}
|
2021-07-23 10:35:53 +01:00
|
|
|
set countdeferimento(value: number ) {
|
2021-07-30 16:55:13 +01:00
|
|
|
this._countDeferiemnto = value
|
|
|
|
|
this.saveDeferimento()
|
2021-07-22 16:09:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
resetparecer(eventsList: any) {
|
2021-07-30 16:55:13 +01:00
|
|
|
this._listParecer = eventsList
|
2021-07-22 16:09:47 +01:00
|
|
|
|
2021-07-30 16:55:13 +01:00
|
|
|
this.countparecer = this._listParecer.length
|
|
|
|
|
this.saveDeferimento()
|
2023-02-13 16:45:12 +01:00
|
|
|
if(window['all-process']) {
|
|
|
|
|
window['all-process']()
|
|
|
|
|
}
|
2023-02-13 17:51:36 +01:00
|
|
|
if(window['all-process-gabinete']) {
|
|
|
|
|
window['all-process-gabinete']()
|
|
|
|
|
}
|
2021-07-22 16:09:47 +01:00
|
|
|
}
|
|
|
|
|
|
2021-07-30 16:55:13 +01:00
|
|
|
resetdeferimento(list: any) {
|
|
|
|
|
this._listDeferimento = list
|
2021-07-22 16:09:47 +01:00
|
|
|
|
2021-07-30 16:55:13 +01:00
|
|
|
this.countdeferimento =this._listDeferimento.length
|
|
|
|
|
this.saveParecer()
|
2023-02-13 17:51:36 +01:00
|
|
|
if(window['all-process']) {
|
|
|
|
|
window['all-process']()
|
|
|
|
|
}
|
|
|
|
|
if(window['all-process-gabinete']) {
|
|
|
|
|
window['all-process-gabinete']()
|
|
|
|
|
}
|
2021-07-30 16:55:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private saveParecer() {
|
2021-07-22 16:09:47 +01:00
|
|
|
setTimeout(()=>{
|
|
|
|
|
localstoreService.set(this.keyNameparecer,{
|
2021-07-30 16:55:13 +01:00
|
|
|
listParecer: this._listParecer,
|
|
|
|
|
count: this._countparecer,
|
2021-07-22 16:09:47 +01:00
|
|
|
})
|
|
|
|
|
}, 10)
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-30 16:55:13 +01:00
|
|
|
private saveDeferimento() {
|
|
|
|
|
setTimeout(()=>{
|
|
|
|
|
localstoreService.set(this.keyNamedeferiemnto,{
|
|
|
|
|
listDeferimento: this._listParecer,
|
|
|
|
|
count: this._countDeferiemnto,
|
|
|
|
|
})
|
|
|
|
|
}, 10)
|
|
|
|
|
|
|
|
|
|
}
|
2021-07-22 16:09:47 +01:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const PedidosStore = new PedidosStoreService()
|