import {getFondWithPage} from "@/api/system-management/allAdministration";
import { getButtonList} from "@/api/user"
  import {loading,loadingClose,message,clearObjValue,sortDG} from '@/utils/common'
  const getDefaultState = () => {
    return {
        tableData:[], // 全宗list列表
        loading: false,
        pagination: {
            pageSize: 10,
            pageNum: 1,
            total: 0,
        },
        showButtons: {
          bc:false
        }
    }
  }
  const state = getDefaultState()
  const mutations = {
    GET_DATA(state, data) {
        state.tableData = data.list;
        state.pagination.total = data.total;
        state.loading = false;
    },
    GET_BUTTON_LIST(state, data) {
      data.forEach(item => {
        state.showButtons[item.key] = true
      })
    }
  }
  const actions = {
    // 全宗列表
    async getFondWithPage({
        commit,
        dispatch
    }, data) {
        await getFondWithPage(data).then(res => {
        try {
            commit('GET_DATA', res.body)
        } catch (err) {
            throw new Error(err)
        }
        })
    },
    async getButtonList({
      commit
    }, params) {
      await getButtonList(params).then(res => {
        commit('GET_BUTTON_LIST', res.body.list)
      })
    }
  }
  export default {
    namespaced: true,
    state,
    mutations,
    actions
  }
  