organization.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import { get } from "@/utils/request";
  2. import Vue from "vue";
  3. /**
  4. * 组织节点全量列表
  5. * GET /main/group/getGroupList
  6. *
  7. * 与 PC 端 onboardingHandling 对齐:一次拉全量(不传 type 参数),
  8. * 法人 / 部门由前端 utils/hr/organization-tree 拆分。
  9. */
  10. export async function listOrganizations(params = {}, loding = true) {
  11. const res = await get(Vue.prototype.apiUrl + "/main/group/getGroupList", params, loding);
  12. if (res.code == 0) {
  13. if (Array.isArray(res.data)) return res.data;
  14. // 兼容分页/包装返回:{ list | records | rows | data }
  15. const wrapper = res.data || {};
  16. const list = wrapper.list || wrapper.records || wrapper.rows || wrapper.data;
  17. return Array.isArray(list) ? list : [];
  18. }
  19. return Promise.reject(new Error(res.message));
  20. }
  21. /**
  22. * 根据部门获取员工列表
  23. * GET /main/user/getUserPage
  24. */
  25. export async function getUserPageByGroupId(params, loding = true) {
  26. const res = await get(Vue.prototype.apiUrl + "/main/user/getUserPage", params, loding);
  27. if (res.code == 0) {
  28. return res.data;
  29. }
  30. return Promise.reject(new Error(res.message));
  31. }
  32. /**
  33. * 根据人员 id 获取用户信息(含部门)
  34. * GET /main/user/getById/:id
  35. */
  36. export async function getUserById(id, loding = true) {
  37. const res = await get(Vue.prototype.apiUrl + `/main/user/getById/${id}`, {}, loding);
  38. if (res.code == 0) {
  39. return res.data;
  40. }
  41. return Promise.reject(new Error(res.message));
  42. }