zichan_category.ts 1.6 KB

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