organization.ts 1.3 KB

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