import { getAllRoles, Department, getAllDepartments, Role } from '@/api/system/user-query';
import { onMounted, ref } from 'vue';

export const getSelectList = () => {
  const roleList = ref<Role[]>([]);
  const getRoleList = () => {
    getAllRoles().then((res) => {
      roleList.value = res.list!;
    });
  };

  const departmentList = ref<Department[]>([]);
  const getDepartmentList = () => {
    getAllDepartments().then((res) => {
      departmentList.value = res;
    });
  };

  onMounted(() => {
    getRoleList();
    getDepartmentList();
  });

  return { roleList, getRoleList, departmentList, getDepartmentList };
};
export default getSelectList;
