dict.ts 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. import { ApiInstance } from '../type'
  2. // 字典实体(与后端 SysDictVo 对应)
  3. export interface SysDictVo {
  4. id?: string
  5. typeId?: string
  6. typeCode?: string
  7. parentValue?: string
  8. value?: string
  9. label?: string
  10. description?: string
  11. sort?: string
  12. remarks?: string
  13. child?: SysDictVo[]
  14. // 前端扩展字段
  15. isEditing?: boolean
  16. tempLabel?: string
  17. }
  18. // 添加字典参数
  19. export interface AddDictParams {
  20. typeId?: string // 类型ID
  21. typeCode?: string // 类型编码
  22. parentValue?: string // 父级value
  23. value: string // 字典值(编码)
  24. label: string // 字典标签(名称)
  25. description?: string // 描述
  26. sort?: string // 排序
  27. remarks?: string // 备注
  28. }
  29. // 更新字典参数(所有字段可选,但必须传id)
  30. export interface UpdateDictParams {
  31. id: string
  32. typeId?: string
  33. typeCode?: string
  34. parentValue?: string
  35. value?: string
  36. label?: string
  37. description?: string
  38. sort?: string
  39. remarks?: string
  40. }
  41. const dictApi = (axiosInstance: ApiInstance) => ({
  42. // 树级查询列表
  43. queryTree: () => axiosInstance.post('/dict/queryTree'),
  44. // 添加字典
  45. addDict: (data: AddDictParams) => axiosInstance.post('/dict/addDict', data),
  46. // 修改字典
  47. updateDict: (data: UpdateDictParams) => axiosInstance.post('/dict/updateDict', data),
  48. // 删除字典
  49. deleteDict: (id: string) => axiosInstance.post('/dict/deleteDict', { id })
  50. })
  51. export default dictApi