|  | @@ -1,27 +1,61 @@
 | 
	
		
			
				|  |  |  /* eslint-disable no-empty */
 | 
	
		
			
				|  |  | -export const getStorageByKey = key => {
 | 
	
		
			
				|  |  | -  let json = {}
 | 
	
		
			
				|  |  | -  try {
 | 
	
		
			
				|  |  | -    const val = sessionStorage.getItem(key) || '{}'
 | 
	
		
			
				|  |  | -    json = JSON.parse(val)
 | 
	
		
			
				|  |  | -  } catch (error) {}
 | 
	
		
			
				|  |  | -  return json
 | 
	
		
			
				|  |  | -}
 | 
	
		
			
				|  |  | +export class Searchs {
 | 
	
		
			
				|  |  | +  saveKey = 'searchs'
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -export const saveToStorage = (key, value = {}) => {
 | 
	
		
			
				|  |  | -  const searchs = getStorageByKey('searchs')
 | 
	
		
			
				|  |  | -  searchs[key] = value
 | 
	
		
			
				|  |  | -  sessionStorage.setItem('searchs', JSON.stringify(searchs))
 | 
	
		
			
				|  |  | -}
 | 
	
		
			
				|  |  | +  initSearch = {
 | 
	
		
			
				|  |  | +    form: {},
 | 
	
		
			
				|  |  | +    page: {},
 | 
	
		
			
				|  |  | +  }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +  searchs = {}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +  constructor(key) {
 | 
	
		
			
				|  |  | +    this.key = key
 | 
	
		
			
				|  |  | +    this.searchs = this.parse()
 | 
	
		
			
				|  |  | +  }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +  save() {
 | 
	
		
			
				|  |  | +    sessionStorage.setItem(this.saveKey, JSON.stringify(this.searchs))
 | 
	
		
			
				|  |  | +  }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +  parse() {
 | 
	
		
			
				|  |  | +    let json = {}
 | 
	
		
			
				|  |  | +    try {
 | 
	
		
			
				|  |  | +      const val = sessionStorage.getItem(this.saveKey)
 | 
	
		
			
				|  |  | +      json = JSON.parse(val) || {}
 | 
	
		
			
				|  |  | +    } catch (error) {}
 | 
	
		
			
				|  |  | +    return json
 | 
	
		
			
				|  |  | +  }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +  get(key) {
 | 
	
		
			
				|  |  | +    const k = (key || this.key)
 | 
	
		
			
				|  |  | +    if (!this.searchs[k]) {
 | 
	
		
			
				|  |  | +      this.searchs[k] = {...initSearch}
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +    return this.searchs[k]
 | 
	
		
			
				|  |  | +  }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +  remove(type) {
 | 
	
		
			
				|  |  | +    if (this.searchs && this.searchs[this.key]) {
 | 
	
		
			
				|  |  | +      type ? this.searchs[this.key][type] : this.searchs[this.key]
 | 
	
		
			
				|  |  | +      this.save()
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +    return this.searchs
 | 
	
		
			
				|  |  | +  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -export const getSearchs = key => {
 | 
	
		
			
				|  |  | -  const searchs = getStorageByKey('searchs')
 | 
	
		
			
				|  |  | -  return key ? (searchs[key] || {}) : searchs
 | 
	
		
			
				|  |  | +  update(data, key, type) {
 | 
	
		
			
				|  |  | +    const k = (key || this.key)
 | 
	
		
			
				|  |  | +    if (type) {
 | 
	
		
			
				|  |  | +      this.searchs[k][type] = data
 | 
	
		
			
				|  |  | +    } else {
 | 
	
		
			
				|  |  | +      this.searchs[k] = data
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +    this.save()
 | 
	
		
			
				|  |  | +    return this.searchs
 | 
	
		
			
				|  |  | +  }
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -export const removeSearchByKey = key => {
 | 
	
		
			
				|  |  | -  const searchs = getStorageByKey('searchs')
 | 
	
		
			
				|  |  | -  delete searchs[key]
 | 
	
		
			
				|  |  | -  sessionStorage.setItem('searchs', JSON.stringify(searchs))
 | 
	
		
			
				|  |  | -  return searchs
 | 
	
		
			
				|  |  | +const initSearch = {
 | 
	
		
			
				|  |  | +  form: {},
 | 
	
		
			
				|  |  | +  page: {},
 | 
	
		
			
				|  |  |  }
 |