import { getTree } from "@/api/archives-management/fileManagement/notRecycleBin.js";
import { getData } from "@/api/dataManagement/achievementIntroduction";
import { message } from "@/utils/common";
const getDefaultState = () => {
  return {
    treeData: [],
    tableLoading: false,
    loading: false,
    tableData: [],
    pagination: {
      pageSize: 10,
      pageNum: 1,
      total: 0
    }
  };
};
const state = getDefaultState();
const mutations = {
  GET_TREE(state, data) {
    state.treeData = data.list;
    state.loading = false;
  },
  GET_DATA(state, data) {
    state.tableData = data.list;
    state.pagination.total = data.total;
    state.tableLoading = false;
  }
};
const actions = {
  async getTree({ commit, dispatch }, data) {
    await getTree(data).then(res => {
      try {
        commit("GET_TREE", res.body);
      } catch (err) {
        throw new Error(err);
      }
    });
  },
  async getData({ commit, dispatch }, data) {
    await getData(data).then(res => {
      try {
        commit("GET_DATA", res.body);
      } catch (err) {
        throw new Error(err);
      }
    });
  }
};
export default {
  namespaced: true,
  state,
  mutations,
  actions
};
