import { defineStore } from 'pinia';
import { useSessionStorage, tryOnMounted } from '@vueuse/core';
import '../../../../api/guardBasic/controller/index.mjs';
import { usePostBasicV1OrgFamilyList } from '../../../../api/guardBasic/controller/JiChuFuWu/ZuZhiGuanLi/usePostBasicV1OrgFamilyList.mjs';

const useOrgListStore = defineStore("gmOrgList", () => {
  const { isLoading, exec } = usePostBasicV1OrgFamilyList();
  const orgList = useSessionStorage("gmOrgList", [], { listenToStorageChanges: false });
  const getOrgList = async () => {
    if (orgList.value.length !== 0 || isLoading.value) {
      return;
    }
    return exec().then((res) => {
      if (res.data.value?.code == 200) {
        orgList.value = res.data.value?.data || [];
      }
    });
  };
  tryOnMounted(() => {
    getOrgList();
  });
  return {
    orgList,
    isLoading,
    getOrgList
  };
});

export { useOrgListStore };
//# sourceMappingURL=index.mjs.map
