A5Section.ts 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import http from "@/utils/http";
  2. import { AppDispatch } from "..";
  3. import { A5TableType } from "@/types";
  4. /**
  5. * 获取部门管理树型数据
  6. */
  7. export const A5_APIgetList = () => {
  8. return async (dispatch: AppDispatch) => {
  9. const res = await http.get("sys/dept/getTree");
  10. if (res.code === 0) {
  11. const arr: A5TableType[] = res.data;
  12. arr.forEach((v) => {
  13. v.level = 1;
  14. if (v.children && v.children.length) {
  15. v.children.forEach((v2) => {
  16. v2.level = 2;
  17. if (v2.children && v2.children.length) {
  18. v2.children.forEach((v3) => {
  19. v3.level = 3;
  20. if (v3.children && v3.children.length) {
  21. v3.children.forEach((v4) => {
  22. v4.level = 4;
  23. });
  24. }
  25. });
  26. }
  27. });
  28. }
  29. });
  30. dispatch({ type: "Section/getList", payload: arr });
  31. }
  32. };
  33. };
  34. /**
  35. * 获取部门管理树型数据
  36. */
  37. export const A5_APIsort = (id1: string, id2: string) => {
  38. return http.get(`sys/dept/sort/${id1}/${id2}`);
  39. };
  40. /**
  41. * 新增和编辑
  42. */
  43. export const A5_APIadd = (data: any) => {
  44. return http.post("sys/dept/save", data);
  45. };
  46. /**
  47. * 删除
  48. */
  49. export const A5_APIdel = (id:string) => {
  50. return http.get(`sys/dept/remove/${id}`);
  51. };