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

export const ConfigStore = defineStore('ConfigStore', {
  state: () => ({
    menu_id: <any>'',
    pages: <any>[],
  }),

  actions: {
    set({menu_id, pages}:any){
      this.menu_id = menu_id
      this.pages = pages
    },
    get({page_code, container_code}:any){
      for(let page of this.pages){
        if(page.page_code == page_code){
          for(let containers of page.layouts){
            for(let item of containers.container){
              if(item.container_code == container_code){
                return item
              }
            }
          }
        }
      }
    },
    clear(){
      this.menu_id = ''
      this.pages = []
    }
  }
})
