dictionary.ts 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. import {
  2. AddDictionaryListParams,
  3. AllMaterialListData,
  4. BaseListResult,
  5. BaseResult,
  6. DictionaryData,
  7. DictionaryParamsType,
  8. EditDictionaryListParams,
  9. EditDictionaryParams,
  10. GetAllMaterialListParams,
  11. GetDictionaryListParams,
  12. } from '@models';
  13. import {request} from './request';
  14. const BASE_URL = '/dictionary';
  15. /** 获取字典列表 */
  16. // eslint-disable-next-line max-params
  17. export function getDictionaryOptions(
  18. type: DictionaryParamsType,
  19. nameOrCode?: string,
  20. signal?: AbortSignal,
  21. ): BaseResult<DictionaryData[]> {
  22. return request({
  23. method: 'GET',
  24. data: {type, nameOrCode},
  25. url: `${BASE_URL}/getDictionary`,
  26. signal,
  27. });
  28. }
  29. /** 获取字典分页列表 */
  30. export function getDictionaryList(
  31. data: GetDictionaryListParams,
  32. signal?: AbortSignal,
  33. ): BaseListResult<DictionaryData> {
  34. return request({
  35. method: 'GET',
  36. data,
  37. url: `${BASE_URL}/getDictionaryPage`,
  38. signal,
  39. });
  40. }
  41. /** 获取字典详情内容 */
  42. export function getDictionaryInfo(
  43. type: DictionaryParamsType,
  44. id?: string,
  45. code?: string,
  46. ): BaseListResult<DictionaryData> {
  47. return request({
  48. method: 'GET',
  49. data: {page: '1', limit: '1', type, tldId: id, code},
  50. url: `${BASE_URL}/getDictionaryPage`,
  51. });
  52. }
  53. /** 修改物料字典内容 */
  54. export function editDictionary(data: EditDictionaryParams): BaseResult {
  55. return request({
  56. method: 'PUT',
  57. data,
  58. url: '/materialClass/updateMaterial',
  59. });
  60. }
  61. /** 修改物料字典 */
  62. export function editDictionaryData(data: EditDictionaryListParams): BaseResult {
  63. return request({
  64. method: 'POST',
  65. data,
  66. url: `${BASE_URL}/updateDictionary`,
  67. });
  68. }
  69. /** 新增物料字典 */
  70. export function addDictionaryData(data: AddDictionaryListParams): BaseResult {
  71. return request({
  72. method: 'POST',
  73. data,
  74. url: `${BASE_URL}/addDictionary`,
  75. });
  76. }
  77. /** 删除物料字典 */
  78. export function deleteDictionaryData(data: {
  79. id: string;
  80. type: DictionaryParamsType;
  81. }): BaseResult {
  82. return request({
  83. method: 'DELETE',
  84. data,
  85. url: `${BASE_URL}/deleteDictionary`,
  86. });
  87. }
  88. /** 修改仓库类型 */
  89. export function editStorageType(data: {
  90. warehouseType: string;
  91. id: string;
  92. }): BaseResult {
  93. return request({
  94. method: 'PUT',
  95. data,
  96. url: '/maintenance/updateWarehouse',
  97. });
  98. }
  99. /** 导出物料信息 */
  100. export function exportMaterial(data: GetDictionaryListParams): any {
  101. return request({
  102. method: 'GET',
  103. data,
  104. url: `${BASE_URL}/export`,
  105. skipError: true,
  106. });
  107. }
  108. /** 导出字典表信息 */
  109. export function exportDictionary(data: GetDictionaryListParams): any {
  110. return request({
  111. method: 'GET',
  112. data,
  113. url: `${BASE_URL}/dictionariesExport`,
  114. skipError: true,
  115. });
  116. }
  117. /** 获取所有字典信息 */
  118. export function getAllMaterialList(
  119. data: GetAllMaterialListParams,
  120. signal?: AbortSignal,
  121. ): BaseResult<AllMaterialListData[]> {
  122. return request({
  123. url: `${BASE_URL}/getMaterial`,
  124. data,
  125. method: 'GET',
  126. signal,
  127. });
  128. }