organization.ts 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. import {
  2. addTreeitem,
  3. axios,
  4. delTreeitem,
  5. editTreeitem,
  6. getTreeselect,
  7. } from "@/request";
  8. export enum DeptType {
  9. corps = 1,
  10. detachment = 2,
  11. brigade = 3,
  12. }
  13. export type Organization = {
  14. ancestors: string;
  15. children?: Organization[];
  16. deptType: DeptType;
  17. id: string;
  18. leader: string;
  19. level: number;
  20. name: string;
  21. parentId: string;
  22. parentName: string;
  23. phone: string;
  24. remark: string;
  25. };
  26. export const getOrganizationTree = async (type?: string) =>
  27. (await axios.get<Organization[]>(getTreeselect, { headers: { share: 1 }, params: { type, ingoreRes: true, share: 1, } })).data;
  28. export const addOrganization = async (
  29. dept: Omit<Organization, "id">,
  30. deptIds: string[]
  31. ) => {
  32. await axios.post(addTreeitem, {
  33. superior: "sheq",
  34. ...dept,
  35. deptIdList: deptIds.join(","),
  36. });
  37. };
  38. export const setOrganization = async (
  39. dept: Organization,
  40. deptIds: string[]
  41. ) => {
  42. await axios.post(editTreeitem, {
  43. superior: "sheq",
  44. ...dept,
  45. deptIdList: deptIds.join(","),
  46. });
  47. };
  48. export const delOrganization = async (deptId: string) =>
  49. axios.post(delTreeitem + deptId);