order.js 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. import request from '@/router/axios';
  2. /**
  3. * 获取订单列表
  4. * @param {number} current - 当前页码
  5. * @param {number} size - 每页大小
  6. * @param {OrderQueryParams} params - 查询参数
  7. * @returns {Promise<AxiosResponse<PageResult<OrderItem>>>} 订单列表响应
  8. */
  9. export const getList = (current, size, params) => {
  10. return request({
  11. url: '/api/blade-factory/api/factory/order',
  12. method: 'get',
  13. params: {
  14. ...params,
  15. current: current,
  16. size
  17. }
  18. })
  19. }
  20. /**
  21. * 新增订单
  22. * @param {OrderForm} row - 订单表单数据
  23. * @returns {Promise<AxiosResponse<OrderItem>>} 新增订单响应
  24. */
  25. export const add = (row) => {
  26. return request({
  27. url: '/api/blade-factory/api/factory/order',
  28. method: 'post',
  29. data: row
  30. })
  31. }
  32. /**
  33. * 更新订单
  34. * @param {OrderForm} row - 订单表单数据
  35. * @returns {Promise<AxiosResponse<OrderItem>>} 更新订单响应
  36. */
  37. export const update = (row) => {
  38. return request({
  39. url: '/api/blade-factory/api/factory/order',
  40. method: 'put',
  41. data: row
  42. })
  43. }
  44. /**
  45. * 删除订单
  46. * @param {string} ids - 订单ID列表,多个ID用逗号分隔
  47. * @returns {Promise<AxiosResponse<boolean>>} 删除订单响应
  48. */
  49. export const remove = (ids) => {
  50. return request({
  51. url: '/api/blade-factory/api/factory/order/remove',
  52. method: 'post',
  53. params: {
  54. ids
  55. }
  56. })
  57. }
  58. /**
  59. * 获取订单详情
  60. * @param {string|number} id - 订单ID
  61. * @returns {Promise<AxiosResponse<OrderItem>>} 订单详情响应
  62. */
  63. export const getDetail = (id) => {
  64. return request({
  65. url: `/api/blade-factory/api/factory/order/${id}`,
  66. method: 'get'
  67. })
  68. }
  69. /**
  70. * 获取客户地址列表
  71. * @param {string} customerCode - 客户编码
  72. * @returns {Promise<AxiosResponse<PageResult<CustomerAddressOption>>>} 客户地址列表响应
  73. */
  74. export const getCustomerAddressList = (customerCode) => {
  75. return request({
  76. url: '/api/blade-factory/api/factory/address',
  77. method: 'get',
  78. params: {
  79. customerCode,
  80. size: 100
  81. }
  82. })
  83. }
  84. /**
  85. * 订单查询参数类型定义
  86. * @typedef {Object} OrderQueryParams
  87. * @property {string} [orderCode] - 订单编码
  88. * @property {string} [orgCode] - 组织编码
  89. * @property {string} [orgName] - 组织名称
  90. * @property {string} [customerCode] - 客户编码
  91. * @property {string} [customerName] - 客户名称
  92. * @property {number} [orderType] - 订单类型 0-采购订单 1-销售订单
  93. * @property {number} [status] - 订单状态 0-草稿 1-已提交 2-已确认 3-已完成 4-已取消
  94. * @property {string} [receiverName] - 收货人姓名
  95. * @property {string} [receiverPhone] - 收货人电话
  96. * @property {string} [createTimeStart] - 创建时间开始
  97. * @property {string} [createTimeEnd] - 创建时间结束
  98. */
  99. /**
  100. * 订单表单数据类型定义
  101. * @typedef {Object} OrderForm
  102. * @property {string|number} [id] - 订单ID(修改时必填)
  103. * @property {string} [orderCode] - 订单编码(系统自动生成)
  104. * @property {string|number} orgId - 组织ID
  105. * @property {string} orgCode - 组织编码
  106. * @property {string} orgName - 组织名称
  107. * @property {string|number} customerId - 客户ID
  108. * @property {string} customerCode - 客户编码
  109. * @property {string} customerName - 客户名称
  110. * @property {number} orderType - 订单类型 0-采购订单 1-销售订单
  111. * @property {number|string} totalAmount - 订单总金额
  112. * @property {number|string} totalQuantity - 订单总数量
  113. * @property {string|number} addressId - 收货地址ID
  114. * @property {string} receiverName - 收货人姓名
  115. * @property {string} receiverPhone - 收货人电话
  116. * @property {string} receiverAddress - 收货详细地址
  117. * @property {string} receiverRegion - 收货地区
  118. * @property {number} status - 订单状态 0-草稿 1-已提交 2-已确认 3-已完成 4-已取消
  119. */
  120. /**
  121. * 订单列表项类型定义
  122. * @typedef {Object} OrderItem
  123. * @property {string} id - 订单ID
  124. * @property {string} createUser - 创建用户ID
  125. * @property {string} createDept - 创建部门ID
  126. * @property {string} createTime - 创建时间
  127. * @property {string} updateUser - 更新用户ID
  128. * @property {string} updateTime - 更新时间
  129. * @property {number} status - 订单状态 0-草稿 1-已提交 2-已确认 3-已完成 4-已取消
  130. * @property {number} isDeleted - 是否删除 0-未删除 1-已删除
  131. * @property {string} orderCode - 订单编码
  132. * @property {number} orgId - 组织ID
  133. * @property {string} orgCode - 组织编码
  134. * @property {string} orgName - 组织名称
  135. * @property {number} customerId - 客户ID
  136. * @property {string} customerCode - 客户编码
  137. * @property {string} customerName - 客户名称
  138. * @property {number} orderType - 订单类型 0-采购订单 1-销售订单
  139. * @property {string} totalAmount - 订单总金额
  140. * @property {string} totalQuantity - 订单总数量
  141. * @property {number} addressId - 收货地址ID
  142. * @property {string} receiverName - 收货人姓名
  143. * @property {string} receiverPhone - 收货人电话
  144. * @property {string} receiverAddress - 收货详细地址
  145. * @property {string} receiverRegion - 收货地区
  146. * @property {string|null} submitTime - 提交时间
  147. * @property {string|null} confirmTime - 确认时间
  148. */
  149. /**
  150. * 客户地址选项类型定义
  151. * @typedef {Object} CustomerAddressOption
  152. * @property {number} id - 地址ID
  153. * @property {string} receiverName - 收货人姓名
  154. * @property {string} receiverPhone - 收货人电话
  155. * @property {string} receiverAddress - 收货详细地址
  156. * @property {string} regionName - 收货地区
  157. * @property {number} isDefault - 是否默认地址 0-否 1-是
  158. */
  159. /**
  160. * API响应类型定义
  161. * @template T
  162. * @typedef {Object} ApiResponse
  163. * @property {number} code - 响应码
  164. * @property {boolean} success - 是否成功
  165. * @property {T} data - 响应数据
  166. * @property {string} msg - 响应消息
  167. */
  168. /**
  169. * 分页结果类型定义
  170. * @template T
  171. * @typedef {Object} PageResult
  172. * @property {T[]} records - 数据列表
  173. * @property {number} total - 总记录数
  174. * @property {number} size - 每页大小
  175. * @property {number} current - 当前页码
  176. * @property {number} pages - 总页数
  177. * @property {Array} orders - 排序信息
  178. * @property {boolean} optimizeCountSql - 是否优化count查询
  179. * @property {boolean} hitCount - 是否命中count缓存
  180. * @property {string|null} countId - count查询ID
  181. * @property {number|null} maxLimit - 最大限制
  182. * @property {boolean} searchCount - 是否查询count
  183. */