/**
 *  动态页面 表单数据缓存
 */
import { defineStore } from 'pinia'

export const ParamsStore = defineStore('ParamsStore', {
  state: () => ({
    container: <any>{},
  }),

  actions: {
    set({page_code, container_code,  data}:any){
      if(!this.container[page_code]){
        this.container[page_code] = {}
      }
      let container_code_arr = container_code.split(',')
      for(let code of container_code_arr){
        Object.assign(this.container[page_code], {
          [code] : data
        })
      }
    },
    get({page_code, container_code,}:any){
      return this.container[page_code][container_code]
    },
    clear(){
      this.container = {}
    }
  }
})
