forecast-summary.js 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. import request from '@/router/axios'
  2. /**
  3. * 预测汇总查询参数类型定义
  4. * @typedef {Object} ForecastSummaryQueryParams
  5. * @property {number} [current=1] - 当前页码
  6. * @property {number} [size=10] - 每页数量
  7. * @property {number} [year] - 年份
  8. * @property {number} [month] - 月份
  9. * @property {number} [customerId] - 客户ID
  10. * @property {string} [customerCode] - 客户编码
  11. * @property {string} [customerName] - 客户名称
  12. * @property {number} [brandId] - 品牌ID
  13. * @property {string} [brandCode] - 品牌编码
  14. * @property {string} [brandName] - 品牌名称
  15. * @property {number} [itemId] - 物料ID
  16. * @property {string} [itemCode] - 物料编码
  17. * @property {string} [itemName] - 物料名称
  18. * @property {number} [approvalStatus] - 审批状态 0未审批 1已通过 2已拒绝
  19. */
  20. /**
  21. * 预测汇总数据项类型定义
  22. * @typedef {Object} ForecastSummaryItem
  23. * @property {string} id - 预测汇总ID
  24. * @property {string} createUser - 创建用户ID
  25. * @property {string} createDept - 创建部门ID
  26. * @property {string} createTime - 创建时间
  27. * @property {string} updateUser - 更新用户ID
  28. * @property {string} updateTime - 更新时间
  29. * @property {number} status - 状态
  30. * @property {number} isDeleted - 是否删除
  31. * @property {number} year - 年份
  32. * @property {number} month - 月份
  33. * @property {number} customerId - 客户ID
  34. * @property {string} customerCode - 客户编码
  35. * @property {string} customerName - 客户名称
  36. * @property {number} brandId - 品牌ID
  37. * @property {string} brandCode - 品牌编码
  38. * @property {string} brandName - 品牌名称
  39. * @property {number} itemId - 物料ID
  40. * @property {string} itemCode - 物料编码
  41. * @property {string} itemName - 物料名称
  42. * @property {string} specs - 规格
  43. * @property {string} pattern - 花纹
  44. * @property {string} forecastQuantity - 预测数量
  45. * @property {number} approvalStatus - 审批状态 0未审批 1已通过 2已拒绝
  46. * @property {number|null} approvedBy - 审批人ID
  47. * @property {string|null} approvedName - 审批人姓名
  48. * @property {string|null} approvedTime - 审批时间
  49. */
  50. /**
  51. * 预测汇总分页响应数据类型定义
  52. * @typedef {Object} ForecastSummaryPageResponse
  53. * @property {ForecastSummaryItem[]} records - 预测汇总数据记录
  54. * @property {number} total - 总记录数
  55. * @property {number} size - 每页数量
  56. * @property {number} current - 当前页码
  57. * @property {Array} orders - 排序信息
  58. * @property {boolean} optimizeCountSql - 是否优化count查询
  59. * @property {boolean} hitCount - 是否命中count缓存
  60. * @property {string|null} countId - count查询ID
  61. * @property {number|null} maxLimit - 最大限制
  62. * @property {boolean} searchCount - 是否查询count
  63. * @property {number} pages - 总页数
  64. */
  65. /**
  66. * API响应数据类型定义
  67. * @template T
  68. * @typedef {Object} ApiResponse
  69. * @property {ApiResponseData<T>} data
  70. * @property {ApiResponseData<T>} data
  71. * @property {string} statusText - HTTP状态文本 (来自AxiosResponse)
  72. * @property {Object} headers - 响应头信息 (来自AxiosResponse)
  73. * @property {string} [headers.content-type] - 内容类型
  74. * @property {Object} config - 请求配置信息 (来自AxiosResponse)
  75. * @property {string} [config.method] - 请求方法
  76. * @property {string} [config.url] - 请求URL
  77. * @property {Record<string, any>} [config.params] - 请求参数
  78. * @property {Record<string, any>} [config.headers] - 请求头
  79. */
  80. /**
  81. * API响应内层data类型定义
  82. * @template T
  83. * @typedef {Object} ApiResponseData
  84. * @property {number} code - 响应码
  85. * @property {boolean} success - 是否成功
  86. * @property {T} data - 响应数据
  87. * @property {string} msg - 响应消息
  88. */
  89. /**
  90. * 获取预测汇总列表
  91. * @param {number} [current=1] - 当前页码
  92. * @param {number} [size=10] - 每页数量
  93. * @param {ForecastSummaryQueryParams} [params={}] - 查询参数
  94. * @returns {Promise<ApiResponse<ForecastSummaryPageResponse>>} 预测汇总列表响应
  95. * @description 获取经销商销售预测汇总列表,支持多条件查询和分页
  96. * @example
  97. * // 获取第一页10条数据
  98. * const result = await getForecastSummaryList(1, 10)
  99. *
  100. * // 按年月查询
  101. * const result = await getForecastSummaryList(1, 10, { year: 2023, month: 8 })
  102. *
  103. * // 按客户查询
  104. * const result = await getForecastSummaryList(1, 10, { customerId: 1002 })
  105. *
  106. * // 按审批状态查询
  107. * const result = await getForecastSummaryList(1, 10, { approvalStatus: 2 })
  108. */
  109. export const getForecastSummaryList = async (current = 1, size = 10, params = {}) => {
  110. return request({
  111. url: '/api/blade-factory/api/factory/forecast-summary',
  112. method: 'get',
  113. params: {
  114. current,
  115. size,
  116. ...params
  117. }
  118. })
  119. }
  120. /**
  121. * 获取预测汇总详情
  122. * @param {string|number} forecastSummaryId - 预测汇总ID
  123. * @returns {Promise<ApiResponse<ForecastSummaryItem>>} 预测汇总详情响应
  124. * @description 根据ID获取预测汇总的详细信息
  125. * @example
  126. * const result = await getForecastSummaryDetail('1954819531796865026')
  127. *
  128. * // 处理响应数据
  129. * if (result.success && result.code === 200) {
  130. * const summaryData = result.data
  131. * console.log('预测汇总详情:', summaryData)
  132. * }
  133. */
  134. export const getForecastSummaryDetail = async (forecastSummaryId) => {
  135. return request({
  136. url: `/api/blade-factory/api/factory/forecast-summary/${forecastSummaryId}`,
  137. method: 'get'
  138. })
  139. }