zichan_area.ts 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import axios from "axios";
  2. import { ZichanArea } from "../../share/monitorTypes.ts";
  3. // 资产归属区域API接口定义
  4. export const ZichanAreaAPI = {
  5. // 获取资产归属区域列表
  6. getZichanAreaList: async (params?: {
  7. page?: number,
  8. limit?: number,
  9. name?: string,
  10. code?: string
  11. }) => {
  12. try {
  13. const response = await axios.get(`/zichan-areas`, { params });
  14. return response.data;
  15. } catch (error) {
  16. throw error;
  17. }
  18. },
  19. // 获取单个资产归属区域信息
  20. getZichanArea: async (id: number) => {
  21. try {
  22. const response = await axios.get(`/zichan-areas/${id}`);
  23. return response.data;
  24. } catch (error) {
  25. throw error;
  26. }
  27. },
  28. // 创建资产归属区域
  29. createZichanArea: async (data: Partial<ZichanArea>) => {
  30. try {
  31. const response = await axios.post(`/zichan-areas`, data);
  32. return response.data;
  33. } catch (error) {
  34. throw error;
  35. }
  36. },
  37. // 更新资产归属区域
  38. updateZichanArea: async (id: number, data: Partial<ZichanArea>) => {
  39. try {
  40. const response = await axios.put(`/zichan-areas/${id}`, data);
  41. return response.data;
  42. } catch (error) {
  43. throw error;
  44. }
  45. },
  46. // 删除资产归属区域
  47. deleteZichanArea: async (id: number) => {
  48. try {
  49. const response = await axios.delete(`/zichan-areas/${id}`);
  50. return response.data;
  51. } catch (error) {
  52. throw error;
  53. }
  54. }
  55. };