'use strict';

var vue = require('vue');
var pinia = require('pinia');
var lodashEs = require('lodash-es');
require('../../../api/guardBasic/controller/index.js');
var core = require('@vueuse/core');
var usePostBasicV1UserListUserOrg = require('../../../api/guardBasic/controller/JiChuFuWu/YongHuGuanLi/usePostBasicV1UserListUserOrg.js');

const useOrgUserListStore = pinia.defineStore("gmOrgUserList", () => {
  const { isLoading, exec, data: userListData } = usePostBasicV1UserListUserOrg.usePostBasicV1UserListUserOrg();
  const userList = vue.computed(() => userListData.value?.data || []);
  const orgUserList = vue.computed(() => {
    const familyGroup = lodashEs.groupBy(userList.value, "family_code");
    return Object.keys(familyGroup).map((familyCode) => {
      return {
        label: familyGroup[familyCode][0].family_name,
        value: familyCode,
        children: familyGroup[familyCode].map((it) => ({ label: it.user_name, value: it.user_id }))
      };
    });
  });
  const getOrgUserList = async (input) => {
    return exec(input);
  };
  core.tryOnMounted(() => {
    if (userList.value.length !== 0 || isLoading.value) {
      return;
    }
    getOrgUserList({ user_status: 1 });
  });
  return {
    userList,
    isLoading,
    orgUserList,
    getOrgUserList
  };
});

exports.useOrgUserListStore = useOrgUserListStore;
//# sourceMappingURL=index.js.map
