order.js 6.4 KB

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