Parcourir la source

refactor(api): 集中管理公共API类型定义并重构相关引用

feat(api): 新增订单发票明细和物流跟踪API模块
yz il y a 3 mois
Parent
commit
c610765bfc

+ 7 - 26
src/api/dealer/inventory.js

@@ -37,37 +37,18 @@ import request from '@/router/axios'
  * @property {string} [itemName] - 物料名称(可选)
  */
 
+// 引用公共类型定义
 /**
- * API响应数据类型定义
- * @typedef {Object} ApiResponse
- * @property {number} code - 响应状态码
- * @property {boolean} success - 是否成功
- * @property {string} msg - 响应消息
- * @property {Object} data - 响应数据
- */
-
-/**
- * 分页响应数据类型定义
- * @typedef {Object} PageResponse
- * @property {DealerInventoryRecord[]} records - 数据记录列表
- * @property {number} total - 总记录数
- * @property {number} size - 每页大小
- * @property {number} current - 当前页码
- * @property {number} pages - 总页数
- * @property {boolean} searchCount - 是否查询总数
- * @property {boolean} optimizeCountSql - 是否优化count查询
- * @property {boolean} hitCount - 是否命中缓存
- * @property {Array} orders - 排序信息
- * @property {string|null} countId - count查询ID
- * @property {number|null} maxLimit - 最大限制
+ * @typedef {import('../types/common.js').ApiResponse} ApiResponse
+ * @typedef {import('../types/common.js').PageResult} PageResponse
  */
 
 /**
  * 获取经销商库存列表
  * @param {InventoryListParams} params - 查询参数
- * @returns {Promise<AxiosResponse<{records: DealerInventoryRecord[], total: number, size: number, current: number}>>} 返回分页数据
+ * @returns {Promise<AxiosResponse<ApiResponse<PageResponse<DealerInventoryRecord>>>>} 返回分页数据
  */
-export const getInventoryList = (params) => {
+export const getInventoryList = async (params) => {
   return request({
     url: '/api/blade-factory/api/factory/dealer-inventory',
     method: 'get',
@@ -82,9 +63,9 @@ export const getInventoryList = (params) => {
 /**
  * 获取经销商库存详情
  * @param {string} inventoryId - 库存记录ID
- * @returns {Promise<AxiosResponse<DealerInventoryRecord>>} 返回库存详情
+ * @returns {Promise<AxiosResponse<ApiResponse<DealerInventoryRecord>>>} 返回库存详情
  */
-export const getInventoryDetail = (inventoryId) => {
+export const getInventoryDetail = async (inventoryId) => {
   return request({
     url: `/api/blade-factory/api/factory/dealer-inventory/${inventoryId}`,
     method: 'get'

+ 109 - 28
src/api/order/address.js

@@ -1,18 +1,30 @@
-import request from '@/router/axios';
+import request from '@/router/axios'
 
-export const getList = (current, size, params) => {
+/**
+ * 地址分页查询
+ * @param {number} current - 当前页码
+ * @param {number} size - 每页大小
+ * @param {CustomerAddressQueryParams} params - 查询参数
+ * @returns {Promise<AxiosResponse<ApiResponse<PageResult<CustomerAddressItem>>>>} 分页查询结果
+ */
+export const getList = async (current, size, params) => {
   return request({
     url: '/api/blade-factory/api/factory/address',
     method: 'get',
     params: {
       ...params,
-      current: current,
+      current,
       size
     }
   })
 }
 
-export const add = (row) => {
+/**
+ * 添加地址
+ * @param {CustomerAddressForm} row - 地址表单数据
+ * @returns {Promise<AxiosResponse<ApiResponse<boolean>>>} 添加结果
+ */
+export const add = async (row) => {
   return request({
     url: '/api/blade-factory/api/factory/address',
     method: 'post',
@@ -20,7 +32,12 @@ export const add = (row) => {
   })
 }
 
-export const update = (row) => {
+/**
+ * 修改地址
+ * @param {CustomerAddressForm} row - 地址表单数据
+ * @returns {Promise<AxiosResponse<ApiResponse<boolean>>>} 修改结果
+ */
+export const update = async (row) => {
   return request({
     url: '/api/blade-factory/api/factory/address',
     method: 'put',
@@ -28,17 +45,27 @@ export const update = (row) => {
   })
 }
 
-export const remove = (ids) => {
+/**
+ * 删除地址
+ * @param {string} ids - 要删除的ID,多个用逗号分隔
+ * @returns {Promise<AxiosResponse<ApiResponse<boolean>>>} 删除结果
+ */
+export const remove = async (ids) => {
   return request({
     url: '/api/blade-factory/api/factory/address/remove',
-    method: 'post',
+    method: 'delete',
     params: {
       ids
     }
   })
 }
 
-export const getDetail = (id) => {
+/**
+ * 获取地址详情
+ * @param {string|number} id - 地址ID
+ * @returns {Promise<AxiosResponse<ApiResponse<CustomerAddressItem>>>} 地址详情
+ */
+export const getDetail = async (id) => {
   return request({
     url: `/api/blade-factory/api/factory/address/${id}`,
     method: 'get'
@@ -95,27 +122,81 @@ export const getDetail = (id) => {
  * @property {number} isActive - 是否启用 0-禁用 1-启用
  */
 
+// 引用公共类型定义
+/**
+ * @typedef {import('../types/common.js').ApiResponse} ApiResponse
+ * @typedef {import('../types/common.js').PageResult} PageResult
+ */
+
+/**
+ * 获取客户地址列表
+ * @param {string|number} customerId - 客户ID
+ * @returns {Promise<AxiosResponse<ApiResponse<CustomerAddressItem[]>>>} 客户地址列表
+ */
+export const getAddressList = async (customerId) => {
+  return request({
+    url: '/api/blade-factory/api/factory/salesOrder/getAddressList',
+    method: 'get',
+    params: {
+      customerId
+    }
+  })
+}
+
+/**
+ * 添加客户地址
+ * @param {CustomerAddressForm} row - 地址表单数据
+ * @returns {Promise<AxiosResponse<ApiResponse<boolean>>>} 添加结果
+ */
+export const addAddress = async (row) => {
+  return request({
+    url: '/api/blade-factory/api/factory/salesOrder/addAddress',
+    method: 'post',
+    data: row
+  })
+}
+
 /**
- * @typedef {Object} PageResult
- * @template T
- * @property {T[]} records - 数据记录
- * @property {number} total - 总记录数
- * @property {number} size - 每页大小
- * @property {number} current - 当前页码
- * @property {Array} orders - 排序信息
- * @property {boolean} optimizeCountSql - 是否优化count查询
- * @property {boolean} hitCount - 是否命中count缓存
- * @property {null} countId - count查询ID
- * @property {null} maxLimit - 最大限制
- * @property {boolean} searchCount - 是否查询count
- * @property {number} pages - 总页数
+ * 更新客户地址
+ * @param {CustomerAddressForm} row - 地址表单数据
+ * @returns {Promise<AxiosResponse<ApiResponse<boolean>>>} 更新结果
  */
+export const updateAddress = async (row) => {
+  return request({
+    url: '/api/blade-factory/api/factory/salesOrder/updateAddress',
+    method: 'put',
+    data: row
+  })
+}
 
 /**
- * @typedef {Object} ApiResponse
- * @template T
- * @property {number} code - 响应码
- * @property {boolean} success - 是否成功
- * @property {T} data - 响应数据
- * @property {string} msg - 响应消息
- */
+ * 设置默认地址
+ * @param {string|number} id - 地址ID
+ * @param {string|number} customerId - 客户ID
+ * @returns {Promise<AxiosResponse<ApiResponse<boolean>>>} 设置结果
+ */
+export const setDefaultAddress = async (id, customerId) => {
+  return request({
+    url: '/api/blade-factory/api/factory/salesOrder/setDefaultAddress',
+    method: 'put',
+    params: {
+      id,
+      customerId
+    }
+  })
+}
+
+/**
+ * 删除客户地址
+ * @param {string|number} id - 地址ID
+ * @returns {Promise<AxiosResponse<ApiResponse<boolean>>>} 删除结果
+ */
+export const deleteAddress = async (id) => {
+  return request({
+    url: '/api/blade-factory/api/factory/salesOrder/deleteAddress',
+    method: 'delete',
+    params: {
+      id
+    }
+  })
+}

+ 8 - 23
src/api/order/invoice.js

@@ -67,25 +67,10 @@ import { INVOICE_TYPES, INVOICE_STATUS } from '@/views/order/invoice/constants'
  * @property {string} invoiceDate - 开票日期 格式:YYYY-MM-DD
  */
 
+// 引用公共类型定义
 /**
- * API响应类型定义
- * @template T
- * @typedef {Object} ApiResponse
- * @property {number} code - 响应码
- * @property {boolean} success - 是否成功
- * @property {T} data - 响应数据
- * @property {string} msg - 响应消息
- */
-
-/**
- * 分页结果类型定义
- * @template T
- * @typedef {Object} PageResult
- * @property {T[]} records - 数据记录
- * @property {number} total - 总记录数
- * @property {number} size - 每页大小
- * @property {number} current - 当前页码
- * @property {number} pages - 总页数
+ * @typedef {import('../types/common.js').ApiResponse} ApiResponse
+ * @typedef {import('../types/common.js').PageResult} PageResult
  */
 
 /**
@@ -112,7 +97,7 @@ export const getList = async (current, size, params) => {
  * @param {InvoiceForm} row - 发票表单数据
  * @returns {Promise<AxiosResponse<ApiResponse<boolean>>>} 添加结果
  */
-export const add = (row) => {
+export const add = async (row) => {
   return request({
     url: '/api/blade-factory/api/factory/order-invoice',
     method: 'post',
@@ -125,7 +110,7 @@ export const add = (row) => {
  * @param {InvoiceForm} row - 发票表单数据
  * @returns {Promise<AxiosResponse<ApiResponse<boolean>>>} 修改结果
  */
-export const update = (row) => {
+export const update = async (row) => {
   return request({
     url: '/api/blade-factory/api/factory/order-invoice',
     method: 'put',
@@ -138,7 +123,7 @@ export const update = (row) => {
  * @param {string} ids - 要删除的ID,多个用逗号分隔
  * @returns {Promise<AxiosResponse<ApiResponse<boolean>>>} 删除结果
  */
-export const remove = (ids) => {
+export const remove = async (ids) => {
   return request({
     url: '/api/blade-factory/api/factory/order-invoice/remove',
     method: 'delete',
@@ -153,7 +138,7 @@ export const remove = (ids) => {
  * @param {string} id - 发票ID
  * @returns {Promise<AxiosResponse<ApiResponse<InvoiceItem>>>} 发票详情
  */
-export const getDetail = (id) => {
+export const getDetail = async (id) => {
   return request({
     url: '/api/blade-factory/api/factory/order-invoice/detail',
     method: 'get',
@@ -185,7 +170,7 @@ export const updateStatus = async (ids, status) => {
  * @param {number} orderId - 订单ID
  * @returns {Promise<AxiosResponse<ApiResponse<InvoiceItem[]>>>} 发票列表
  */
-export const getInvoicesByOrderId = (orderId) => {
+export const getInvoicesByOrderId = async (orderId) => {
   return request({
     url: '/api/blade-factory/api/factory/order-invoice/by-order',
     method: 'get',

+ 169 - 0
src/api/order/order-invoice-item.js

@@ -0,0 +1,169 @@
+import request from '@/router/axios'
+
+/**
+ * 发票明细查询参数类型定义
+ * @typedef {Object} InvoiceItemQueryParams
+ * @property {string|number} [invoiceId] - 发票ID
+ * @property {string} [invoiceNo] - 发票号码
+ * @property {string|number} [orderId] - 订单ID
+ * @property {string|number} [orderItemId] - 订单明细ID
+ * @property {string|number} [itemId] - 物料ID
+ * @property {string} [itemCode] - 物料编码
+ * @property {string} [itemName] - 物料名称
+ * @property {string} [specs] - 物料规格
+ */
+
+/**
+ * 发票明细表单数据类型定义
+ * @typedef {Object} InvoiceItemForm
+ * @property {string|number} [id] - 明细ID(修改时必填)
+ * @property {string|number} invoiceId - 发票ID
+ * @property {string} invoiceNo - 发票号码
+ * @property {string|number} orderId - 订单ID
+ * @property {string|number} orderItemId - 订单明细ID
+ * @property {string|number} itemId - 物料ID
+ * @property {string} itemCode - 物料编码
+ * @property {string} itemName - 物料名称
+ * @property {string} specs - 物料规格
+ * @property {string|number} quantity - 开票数量
+ * @property {string|number} unitPrice - 含税单价
+ * @property {string|number} taxRate - 税率(如0.13表示13%)
+ * @property {string|number} amount - 不含税金额
+ * @property {string|number} taxAmount - 税额
+ * @property {string|number} totalAmount - 价税合计
+ */
+
+/**
+ * 发票明细记录类型定义
+ * @typedef {Object} InvoiceItemRecord
+ * @property {string} id - 明细ID
+ * @property {string} createUser - 创建用户ID
+ * @property {string} createDept - 创建部门ID
+ * @property {string} createTime - 创建时间
+ * @property {string} updateUser - 更新用户ID
+ * @property {string} updateTime - 更新时间
+ * @property {0|1} status - 状态 1-正常 0-禁用
+ * @property {0|1} isDeleted - 是否删除 0-未删除 1-已删除
+ * @property {string|number} invoiceId - 发票ID
+ * @property {string} invoiceNo - 发票号码
+ * @property {string|number} orderId - 订单ID
+ * @property {string|number} orderItemId - 订单明细ID
+ * @property {string|number} itemId - 物料ID
+ * @property {string} itemCode - 物料编码
+ * @property {string} itemName - 物料名称
+ * @property {string} specs - 物料规格
+ * @property {string} quantity - 开票数量
+ * @property {string} unitPrice - 含税单价
+ * @property {string} taxRate - 税率
+ * @property {string} amount - 不含税金额
+ * @property {string} taxAmount - 税额
+ * @property {string} totalAmount - 价税合计
+ */
+
+// 引用公共类型定义
+/**
+ * @typedef {import('../types/common.js').ApiResponse} ApiResponse
+ * @typedef {import('../types/common.js').PageResult} PageResult
+ */
+
+/**
+ * 发票明细分页查询
+ * @param {number} current - 当前页码
+ * @param {number} size - 每页大小
+ * @param {InvoiceItemQueryParams} params - 查询参数
+ * @returns {Promise<AxiosResponse<ApiResponse<PageResult<InvoiceItemRecord>>>>} 分页查询结果
+ */
+export const getList = async (current, size, params) => {
+  return request({
+    url: '/api/blade-factory/api/factory/order-invoice-item',
+    method: 'get',
+    params: {
+      ...params,
+      current,
+      size
+    }
+  })
+}
+
+/**
+ * 添加发票明细
+ * @param {InvoiceItemForm} row - 发票明细表单数据
+ * @returns {Promise<AxiosResponse<ApiResponse<boolean>>>} 添加结果
+ */
+export const add = async (row) => {
+  return request({
+    url: '/api/blade-factory/api/factory/order-invoice-item',
+    method: 'post',
+    data: row
+  })
+}
+
+/**
+ * 修改发票明细
+ * @param {InvoiceItemForm} row - 发票明细表单数据
+ * @returns {Promise<AxiosResponse<ApiResponse<boolean>>>} 修改结果
+ */
+export const update = async (row) => {
+  return request({
+    url: '/api/blade-factory/api/factory/order-invoice-item',
+    method: 'put',
+    data: row
+  })
+}
+
+/**
+ * 删除发票明细
+ * @param {string} ids - 要删除的ID,多个用逗号分隔
+ * @returns {Promise<AxiosResponse<ApiResponse<boolean>>>} 删除结果
+ */
+export const remove = async (ids) => {
+  return request({
+    url: '/api/blade-factory/api/factory/order-invoice-item/remove',
+    method: 'delete',
+    params: {
+      ids
+    }
+  })
+}
+
+/**
+ * 获取发票明细详情
+ * @param {string|number} id - 发票明细ID
+ * @returns {Promise<AxiosResponse<ApiResponse<InvoiceItemRecord>>>} 发票明细详情
+ */
+export const getDetail = async (id) => {
+  return request({
+    url: `/api/blade-factory/api/factory/order-invoice-item/${id}`,
+    method: 'get'
+  })
+}
+
+/**
+ * 根据发票ID获取发票明细列表
+ * @param {string|number} invoiceId - 发票ID
+ * @returns {Promise<AxiosResponse<ApiResponse<InvoiceItemRecord[]>>>} 发票明细列表
+ */
+export const getItemsByInvoiceId = async (invoiceId) => {
+  return request({
+    url: '/api/blade-factory/api/factory/order-invoice-item/by-invoice',
+    method: 'get',
+    params: {
+      invoiceId
+    }
+  })
+}
+
+/**
+ * 根据订单ID获取发票明细列表
+ * @param {string|number} orderId - 订单ID
+ * @returns {Promise<AxiosResponse<ApiResponse<InvoiceItemRecord[]>>>} 发票明细列表
+ */
+export const getItemsByOrderId = async (orderId) => {
+  return request({
+    url: '/api/blade-factory/api/factory/order-invoice-item/by-order',
+    method: 'get',
+    params: {
+      orderId
+    }
+  })
+}

+ 11 - 33
src/api/order/order-item.js

@@ -72,31 +72,10 @@ import { ORDER_ITEM_STATUS } from '@/constants';
  * @property {typeof ORDER_ITEM_STATUS[keyof typeof ORDER_ITEM_STATUS]} itemStatus - 明细状态
  */
 
+// 引用公共类型定义
 /**
- * API响应类型定义
- * @template T
- * @typedef {Object} ApiResponse
- * @property {number} code - 响应码
- * @property {boolean} success - 是否成功
- * @property {T} data - 响应数据
- * @property {string} msg - 响应消息
- */
-
-/**
- * 分页结果类型定义
- * @template T
- * @typedef {Object} PageResult
- * @property {T[]} records - 数据记录
- * @property {number} total - 总记录数
- * @property {number} size - 每页大小
- * @property {number} current - 当前页码
- * @property {Array} orders - 排序信息
- * @property {boolean} optimizeCountSql - 是否优化count查询
- * @property {boolean} hitCount - 是否命中count缓存
- * @property {string|null} countId - count查询ID
- * @property {string|null} maxLimit - 最大限制
- * @property {boolean} searchCount - 是否查询count
- * @property {number} pages - 总页数
+ * @typedef {import('../types/common.js').ApiResponse} ApiResponse
+ * @typedef {import('../types/common.js').PageResult} PageResult
  */
 
 /**
@@ -104,9 +83,9 @@ import { ORDER_ITEM_STATUS } from '@/constants';
  * @param {number} current - 当前页码
  * @param {number} size - 每页大小
  * @param {OrderItemQueryParams} params - 查询参数
- * @returns {Promise<AxiosResponse<PageResult<OrderItemRecord>>>} 分页查询结果
+ * @returns {Promise<AxiosResponse<ApiResponse<PageResult<OrderItemRecord>>>>} 分页查询结果
  */
-export const getList = (current, size, params) => {
+export const getList = async (current, size, params) => {
   return request({
     url: '/api/blade-factory/api/factory/order-item',
     method: 'get',
@@ -121,9 +100,9 @@ export const getList = (current, size, params) => {
 /**
  * 新增订单明细
  * @param {OrderItemForm} row - 订单明细数据
- * @returns {Promise<AxiosResponse<bool>>} 新增结果
+ * @returns {Promise<AxiosResponse<ApiResponse<boolean>>>} 新增结果
  */
-export const add = (row) => {
+export const add = async (row) => {
   return request({
     url: '/api/blade-factory/api/factory/order-item',
     method: 'post',
@@ -134,9 +113,9 @@ export const add = (row) => {
 /**
  * 更新订单明细
  * @param {OrderItemForm} row - 订单明细数据
- * @returns {Promise<AxiosResponse<bool>>} 更新结果
+ * @returns {Promise<AxiosResponse<ApiResponse<boolean>>>} 更新结果
  */
-export const update = (row) => {
+export const update = async (row) => {
   return request({
     url: '/api/blade-factory/api/factory/order-item',
     method: 'put',
@@ -144,13 +123,12 @@ export const update = (row) => {
   })
 }
 
-
 /**
  * 获取订单明细详情
  * @param {string|number} id - 订单明细ID
- * @returns {Promise<AxiosResponse<OrderItemRecord>>} 订单明细详情
+ * @returns {Promise<AxiosResponse<ApiResponse<OrderItemRecord>>>} 订单明细详情
  */
-export const getDetail = (id) => {
+export const getDetail = async (id) => {
   return request({
     url: `/api/blade-factory/api/factory/order-item/${id}`,
     method: 'get'

+ 17 - 38
src/api/order/order.js

@@ -6,15 +6,15 @@ import { ORDER_TYPES, ORDER_STATUS } from '@/constants';
  * @param {number} current - 当前页码
  * @param {number} size - 每页大小
  * @param {OrderQueryParams} params - 查询参数
- * @returns {Promise<AxiosResponse<PageResult<OrderItem>>>} 订单列表响应
+ * @returns {Promise<AxiosResponse<ApiResponse<PageResult<OrderItem>>>>} 订单列表响应
  */
-export const getList = (current, size, params) => {
+export const getList = async (current, size, params) => {
   return request({
     url: '/api/blade-factory/api/factory/order',
     method: 'get',
     params: {
       ...params,
-      current: current,
+      current,
       size
     }
   })
@@ -23,9 +23,9 @@ export const getList = (current, size, params) => {
 /**
  * 新增订单
  * @param {OrderForm} row - 订单表单数据
- * @returns {Promise<AxiosResponse<OrderItem>>} 新增订单响应
+ * @returns {Promise<AxiosResponse<ApiResponse<boolean>>>} 新增订单响应
  */
-export const add = (row) => {
+export const add = async (row) => {
   return request({
     url: '/api/blade-factory/api/factory/order',
     method: 'post',
@@ -36,9 +36,9 @@ export const add = (row) => {
 /**
  * 更新订单
  * @param {OrderForm} row - 订单表单数据
- * @returns {Promise<AxiosResponse<OrderItem>>} 更新订单响应
+ * @returns {Promise<AxiosResponse<ApiResponse<boolean>>>} 更新订单响应
  */
-export const update = (row) => {
+export const update = async (row) => {
   return request({
     url: '/api/blade-factory/api/factory/order',
     method: 'put',
@@ -49,12 +49,12 @@ export const update = (row) => {
 /**
  * 删除订单
  * @param {string} ids - 订单ID列表,多个ID用逗号分隔
- * @returns {Promise<AxiosResponse<boolean>>} 删除订单响应
+ * @returns {Promise<AxiosResponse<ApiResponse<boolean>>>} 删除订单响应
  */
-export const remove = (ids) => {
+export const remove = async (ids) => {
   return request({
     url: '/api/blade-factory/api/factory/order/remove',
-    method: 'post',
+    method: 'delete',
     params: {
       ids
     }
@@ -64,9 +64,9 @@ export const remove = (ids) => {
 /**
  * 获取订单详情
  * @param {string|number} id - 订单ID
- * @returns {Promise<AxiosResponse<OrderItem>>} 订单详情响应
+ * @returns {Promise<AxiosResponse<ApiResponse<OrderItem>>>} 订单详情响应
  */
-export const getDetail = (id) => {
+export const getDetail = async (id) => {
   return request({
     url: `/api/blade-factory/api/factory/order/${id}`,
     method: 'get'
@@ -76,9 +76,9 @@ export const getDetail = (id) => {
 /**
  * 获取客户地址列表
  * @param {string} customerCode - 客户编码
- * @returns {Promise<AxiosResponse<CustomerAddressOption[]>>} 客户地址列表响应
+ * @returns {Promise<AxiosResponse<ApiResponse<CustomerAddressOption[]>>>} 客户地址列表响应
  */
-export const getCustomerAddressList = (customerCode) => {
+export const getCustomerAddressList = async (customerCode) => {
   return request({
     url: '/api/blade-factory/api/factory/address',
     method: 'get',
@@ -168,29 +168,8 @@ export const getCustomerAddressList = (customerCode) => {
  * @property {0|1} isDefault - 是否默认地址 0-否 1-是
  */
 
+// 引用公共类型定义
 /**
- * API响应类型定义
- * @template T
- * @typedef {Object} ApiResponse
- * @property {number} code - 响应码
- * @property {boolean} success - 是否成功
- * @property {T} data - 响应数据
- * @property {string} msg - 响应消息
- */
-
-/**
- * 分页结果类型定义
- * @template T
- * @typedef {Object} PageResult
- * @property {T[]} records - 数据列表
- * @property {number} total - 总记录数
- * @property {number} size - 每页大小
- * @property {number} current - 当前页码
- * @property {number} pages - 总页数
- * @property {Array} orders - 排序信息
- * @property {boolean} optimizeCountSql - 是否优化count查询
- * @property {boolean} hitCount - 是否命中count缓存
- * @property {string|null} countId - count查询ID
- * @property {number|null} maxLimit - 最大限制
- * @property {boolean} searchCount - 是否查询count
+ * @typedef {import('../types/common.js').ApiResponse} ApiResponse
+ * @typedef {import('../types/common.js').PageResult} PageResult
  */

+ 256 - 0
src/api/order/sales-order.js

@@ -0,0 +1,256 @@
+import request from '@/router/axios'
+
+/**
+ * 库存查询参数类型定义
+ * @typedef {Object} InventoryQueryParams
+ * @property {string|number} [itemId] - 物料ID
+ * @property {string} [itemCode] - 物料编码
+ * @property {string} [itemName] - 物料名称
+ * @property {string} [specs] - 物料规格
+ * @property {string|number} [warehouseId] - 仓库ID
+ * @property {string} [warehouseCode] - 仓库编码
+ * @property {string} [warehouseName] - 仓库名称
+ * @property {string|number} [customerId] - 客户ID
+ * @property {string} [customerCode] - 客户编码
+ */
+
+/**
+ * 库存记录类型定义
+ * @typedef {Object} InventoryRecord
+ * @property {string} id - 库存记录ID
+ * @property {string} itemId - 物料ID
+ * @property {string} itemCode - 物料编码
+ * @property {string} itemName - 物料名称
+ * @property {string} specs - 物料规格
+ * @property {string} unit - 单位
+ * @property {string} warehouseId - 仓库ID
+ * @property {string} warehouseCode - 仓库编码
+ * @property {string} warehouseName - 仓库名称
+ * @property {string} customerId - 客户ID
+ * @property {string} customerCode - 客户编码
+ * @property {string} customerName - 客户名称
+ * @property {string} quantity - 库存数量
+ * @property {string} availableQuantity - 可用数量
+ * @property {string} reservedQuantity - 预留数量
+ * @property {string} lastUpdateTime - 最后更新时间
+ */
+
+/**
+ * 物料档案查询参数类型定义
+ * @typedef {Object} MaterialQueryParams
+ * @property {string} [itemCode] - 物料编码
+ * @property {string} [itemName] - 物料名称
+ * @property {string} [specs] - 物料规格
+ * @property {string} [category] - 物料分类
+ * @property {string} [brand] - 品牌
+ * @property {0|1} [status] - 状态 1-正常 0-禁用
+ */
+
+/**
+ * 物料档案记录类型定义
+ * @typedef {Object} MaterialRecord
+ * @property {string} id - 物料ID
+ * @property {string} createUser - 创建用户ID
+ * @property {string} createDept - 创建部门ID
+ * @property {string} createTime - 创建时间
+ * @property {string} updateUser - 更新用户ID
+ * @property {string} updateTime - 更新时间
+ * @property {0|1} status - 状态 1-正常 0-禁用
+ * @property {0|1} isDeleted - 是否删除 0-未删除 1-已删除
+ * @property {string} itemCode - 物料编码
+ * @property {string} itemName - 物料名称
+ * @property {string} specs - 物料规格
+ * @property {string} unit - 单位
+ * @property {string} category - 物料分类
+ * @property {string} brand - 品牌
+ * @property {string} model - 型号
+ * @property {string} description - 描述
+ * @property {string} unitPrice - 单价
+ * @property {string} remark - 备注
+ */
+
+/**
+ * 销售订单明细查询参数类型定义
+ * @typedef {Object} SalesOrderItemQueryParams
+ * @property {string|number} [orderId] - 订单ID
+ * @property {string} [orderNo] - 订单号
+ * @property {string|number} [itemId] - 物料ID
+ * @property {string} [itemCode] - 物料编码
+ * @property {string} [itemName] - 物料名称
+ * @property {string} [specs] - 物料规格
+ * @property {0|1|2|3} [status] - 状态 0-待确认 1-已确认 2-已发货 3-已完成
+ */
+
+/**
+ * 销售订单明细记录类型定义
+ * @typedef {Object} SalesOrderItemRecord
+ * @property {string} id - 明细ID
+ * @property {string} createUser - 创建用户ID
+ * @property {string} createDept - 创建部门ID
+ * @property {string} createTime - 创建时间
+ * @property {string} updateUser - 更新用户ID
+ * @property {string} updateTime - 更新时间
+ * @property {0|1} status - 状态 1-正常 0-禁用
+ * @property {0|1} isDeleted - 是否删除 0-未删除 1-已删除
+ * @property {string} orderId - 订单ID
+ * @property {string} orderNo - 订单号
+ * @property {string} itemId - 物料ID
+ * @property {string} itemCode - 物料编码
+ * @property {string} itemName - 物料名称
+ * @property {string} specs - 物料规格
+ * @property {string} unit - 单位
+ * @property {string} quantity - 订购数量
+ * @property {string} unitPrice - 单价
+ * @property {string} amount - 金额
+ * @property {string} deliveredQuantity - 已发货数量
+ * @property {string} remainingQuantity - 剩余数量
+ * @property {0|1|2|3} itemStatus - 明细状态
+ * @property {string} deliveryDate - 交货日期
+ * @property {string} remark - 备注
+ */
+
+// 引用公共类型定义
+/**
+ * @typedef {import('../types/common.js').ApiResponse} ApiResponse
+ * @typedef {import('../types/common.js').PageResult} PageResult
+ */
+
+/**
+ * 库存查询(分页)
+ * @param {number} current - 当前页码
+ * @param {number} size - 每页大小
+ * @param {InventoryQueryParams} params - 查询参数
+ * @returns {Promise<AxiosResponse<ApiResponse<PageResult<InventoryRecord>>>>} 分页查询结果
+ */
+export const getInventoryList = async (current, size, params) => {
+  return request({
+    url: '/api/blade-factory/api/factory/salesOrder/whqoh/list',
+    method: 'get',
+    params: {
+      ...params,
+      current,
+      size
+    }
+  })
+}
+
+/**
+ * 获取库存详情
+ * @param {string|number} id - 库存记录ID
+ * @returns {Promise<AxiosResponse<ApiResponse<InventoryRecord>>>} 库存详情
+ */
+export const getInventoryDetail = async (id) => {
+  return request({
+    url: `/api/blade-factory/api/factory/salesOrder/whqoh/${id}`,
+    method: 'get'
+  })
+}
+
+/**
+ * 获取完整库存列表(不分页)
+ * @param {InventoryQueryParams} params - 查询参数
+ * @returns {Promise<AxiosResponse<ApiResponse<InventoryRecord[]>>>} 库存列表
+ */
+export const getInventoryFullList = async (params) => {
+  return request({
+    url: '/api/blade-factory/api/factory/salesOrder/whqoh/fullList',
+    method: 'get',
+    params
+  })
+}
+
+/**
+ * 物料档案查询(分页)
+ * @param {number} current - 当前页码
+ * @param {number} size - 每页大小
+ * @param {MaterialQueryParams} params - 查询参数
+ * @returns {Promise<AxiosResponse<ApiResponse<PageResult<MaterialRecord>>>>} 分页查询结果
+ */
+export const getMaterialList = async (current, size, params) => {
+  return request({
+    url: '/api/blade-factory/api/factory/salesOrder/item/list',
+    method: 'get',
+    params: {
+      ...params,
+      current,
+      size
+    }
+  })
+}
+
+/**
+ * 获取物料档案详情
+ * @param {string|number} id - 物料ID
+ * @returns {Promise<AxiosResponse<ApiResponse<MaterialRecord>>>} 物料详情
+ */
+export const getMaterialDetail = async (id) => {
+  return request({
+    url: `/api/blade-factory/api/factory/salesOrder/item/${id}`,
+    method: 'get'
+  })
+}
+
+/**
+ * 获取完整物料档案列表(不分页)
+ * @param {MaterialQueryParams} params - 查询参数
+ * @returns {Promise<AxiosResponse<ApiResponse<MaterialRecord[]>>>} 物料列表
+ */
+export const getMaterialFullList = async (params) => {
+  return request({
+    url: '/api/blade-factory/api/factory/salesOrder/item/fullList',
+    method: 'get',
+    params
+  })
+}
+
+/**
+ * 添加订单明细
+ * @param {SalesOrderItemRecord} row - 订单明细数据
+ * @returns {Promise<AxiosResponse<ApiResponse<boolean>>>} 添加结果
+ */
+export const addOrderItem = async (row) => {
+  return request({
+    url: '/api/blade-factory/api/factory/salesOrder/addOrderItem',
+    method: 'post',
+    data: row
+  })
+}
+
+/**
+ * 更新订单明细
+ * @param {SalesOrderItemRecord} row - 订单明细数据
+ * @returns {Promise<AxiosResponse<ApiResponse<boolean>>>} 更新结果
+ */
+export const updateOrderItem = async (row) => {
+  return request({
+    url: '/api/blade-factory/api/factory/salesOrder/updateOrderItem',
+    method: 'put',
+    data: row
+  })
+}
+
+/**
+ * 更新订单
+ * @param {Object} row - 订单数据
+ * @returns {Promise<AxiosResponse<ApiResponse<boolean>>>} 更新结果
+ */
+export const updateOrder = async (row) => {
+  return request({
+    url: '/api/blade-factory/api/factory/salesOrder/updateOrder',
+    method: 'put',
+    data: row
+  })
+}
+
+/**
+ * 添加订单
+ * @param {Object} row - 订单数据
+ * @returns {Promise<AxiosResponse<ApiResponse<boolean>>>} 添加结果
+ */
+export const addOrder = async (row) => {
+  return request({
+    url: '/api/blade-factory/api/factory/salesOrder/addOrder',
+    method: 'post',
+    data: row
+  })
+}

+ 46 - 25
src/api/shipment/index.js

@@ -54,17 +54,48 @@ import request from '@/router/axios'
  */
 
 /**
+ * 订单发货查询参数类型定义
+ * @typedef {Object} OrderShipmentQueryParams
+ * @property {number} current - 当前页码
+ * @property {number} size - 每页大小
+ * @property {string} [shipmentNo] - 发货单号
+ * @property {string} [orderCode] - 订单编号
+ * @property {string} [carrierName] - 承运商名称
+ * @property {number} [shipmentStatus] - 发货状态
+ */
+
+/**
+ * 发货单明细查询参数类型定义
+ * @typedef {Object} ShipmentItemQueryParams
+ * @property {number} current - 当前页码
+ * @property {number} size - 每页大小
+ * @property {string} [shipmentNo] - 发货单号
+ * @property {string} [itemCode] - 物料编码
+ * @property {string} [itemName] - 物料名称
+ */
+
+/**
+ * 物流跟踪查询参数类型定义
+ * @typedef {Object} ShipmentTrackingQueryParams
+ * @property {number} current - 当前页码
+ * @property {number} size - 每页大小
+ * @property {string} [shipmentNo] - 发货单号
+ * @property {string} [trackingNo] - 运单号
+ * @property {string} [trackingStatus] - 跟踪状态
+ */
+
+// 引用公共类型定义
+/**
+ * @typedef {import('../types/common.js').ApiResponse} ApiResponse
+ * @typedef {import('../types/common.js').PageResult} PageResult
+ */
+
+/**
  * 获取订单发货主表列表
- * @param {Object} params - 查询参数
- * @param {number} params.current - 当前页码
- * @param {number} params.size - 每页大小
- * @param {string} [params.shipmentNo] - 发货单号
- * @param {string} [params.orderCode] - 订单编号
- * @param {string} [params.carrierName] - 承运商名称
- * @param {number} [params.shipmentStatus] - 发货状态
- * @returns {Promise<AxiosResponse<{records: OrderShipmentItem[], total: number, size: number, current: number}>>}
+ * @param {OrderShipmentQueryParams} params - 查询参数
+ * @returns {Promise<AxiosResponse<ApiResponse<PageResult<OrderShipmentItem>>>>} 分页查询结果
  */
-export const getOrderShipmentList = (params) => {
+export const getOrderShipmentList = async (params) => {
   return request({
     url: '/blade-factory/api/factory/order-shipment',
     method: 'get',
@@ -74,15 +105,10 @@ export const getOrderShipmentList = (params) => {
 
 /**
  * 获取发货单明细列表
- * @param {Object} params - 查询参数
- * @param {number} params.current - 当前页码
- * @param {number} params.size - 每页大小
- * @param {string} [params.shipmentNo] - 发货单号
- * @param {string} [params.itemCode] - 物料编码
- * @param {string} [params.itemName] - 物料名称
- * @returns {Promise<AxiosResponse<{records: ShipmentItemDetail[], total: number, size: number, current: number}>>}
+ * @param {ShipmentItemQueryParams} params - 查询参数
+ * @returns {Promise<AxiosResponse<ApiResponse<PageResult<ShipmentItemDetail>>>>} 分页查询结果
  */
-export const getShipmentItemList = (params) => {
+export const getShipmentItemList = async (params) => {
   return request({
     url: '/blade-factory/api/factory/shipment-item',
     method: 'get',
@@ -92,15 +118,10 @@ export const getShipmentItemList = (params) => {
 
 /**
  * 获取物流跟踪信息列表
- * @param {Object} params - 查询参数
- * @param {number} params.current - 当前页码
- * @param {number} params.size - 每页大小
- * @param {string} [params.shipmentNo] - 发货单号
- * @param {string} [params.trackingNo] - 运单号
- * @param {string} [params.trackingStatus] - 跟踪状态
- * @returns {Promise<AxiosResponse<{records: ShipmentTrackingInfo[], total: number, size: number, current: number}>>}
+ * @param {ShipmentTrackingQueryParams} params - 查询参数
+ * @returns {Promise<AxiosResponse<ApiResponse<PageResult<ShipmentTrackingInfo>>>>} 分页查询结果
  */
-export const getShipmentTrackingList = (params) => {
+export const getShipmentTrackingList = async (params) => {
   return request({
     url: '/blade-factory/api/factory/shipment-tracking',
     method: 'get',

+ 224 - 0
src/api/shipment/shipment-tracking.js

@@ -0,0 +1,224 @@
+import request from '@/router/axios'
+
+/**
+ * 物流跟踪查询参数类型定义
+ * @typedef {Object} ShipmentTrackingQueryParams
+ * @property {string|number} [shipmentId] - 发货单ID
+ * @property {string} [shipmentNo] - 发货单号
+ * @property {string|number} [orderId] - 订单ID
+ * @property {string} [orderNo] - 订单号
+ * @property {string} [trackingNo] - 物流单号
+ * @property {string} [logisticsCompany] - 物流公司
+ * @property {string} [logisticsCompanyCode] - 物流公司编码
+ * @property {string} [status] - 物流状态
+ * @property {string} [startTime] - 开始时间
+ * @property {string} [endTime] - 结束时间
+ */
+
+/**
+ * 物流跟踪表单数据类型定义
+ * @typedef {Object} ShipmentTrackingForm
+ * @property {string|number} [id] - 跟踪记录ID(修改时必填)
+ * @property {string|number} shipmentId - 发货单ID
+ * @property {string} shipmentNo - 发货单号
+ * @property {string|number} orderId - 订单ID
+ * @property {string} orderNo - 订单号
+ * @property {string} trackingNo - 物流单号
+ * @property {string} logisticsCompany - 物流公司
+ * @property {string} logisticsCompanyCode - 物流公司编码
+ * @property {string} status - 物流状态
+ * @property {string} statusDesc - 状态描述
+ * @property {string} [location] - 当前位置
+ * @property {string} [operateTime] - 操作时间
+ * @property {string} [operator] - 操作员
+ * @property {string} [remark] - 备注
+ */
+
+/**
+ * 物流跟踪记录类型定义
+ * @typedef {Object} ShipmentTrackingRecord
+ * @property {string} id - 跟踪记录ID
+ * @property {string} createUser - 创建用户ID
+ * @property {string} createDept - 创建部门ID
+ * @property {string} createTime - 创建时间
+ * @property {string} updateUser - 更新用户ID
+ * @property {string} updateTime - 更新时间
+ * @property {0|1} status - 状态 1-正常 0-禁用
+ * @property {0|1} isDeleted - 是否删除 0-未删除 1-已删除
+ * @property {string} shipmentId - 发货单ID
+ * @property {string} shipmentNo - 发货单号
+ * @property {string} orderId - 订单ID
+ * @property {string} orderNo - 订单号
+ * @property {string} trackingNo - 物流单号
+ * @property {string} logisticsCompany - 物流公司
+ * @property {string} logisticsCompanyCode - 物流公司编码
+ * @property {string} trackingStatus - 物流状态
+ * @property {string} statusDesc - 状态描述
+ * @property {string} location - 当前位置
+ * @property {string} operateTime - 操作时间
+ * @property {string} operator - 操作员
+ * @property {string} remark - 备注
+ */
+
+/**
+ * 物流跟踪详情类型定义
+ * @typedef {Object} ShipmentTrackingDetail
+ * @property {string} trackingNo - 物流单号
+ * @property {string} logisticsCompany - 物流公司
+ * @property {string} logisticsCompanyCode - 物流公司编码
+ * @property {string} currentStatus - 当前状态
+ * @property {string} currentLocation - 当前位置
+ * @property {string} lastUpdateTime - 最后更新时间
+ * @property {ShipmentTrackingStep[]} trackingSteps - 跟踪步骤列表
+ */
+
+/**
+ * 物流跟踪步骤类型定义
+ * @typedef {Object} ShipmentTrackingStep
+ * @property {string} time - 操作时间
+ * @property {string} status - 状态
+ * @property {string} statusDesc - 状态描述
+ * @property {string} location - 位置
+ * @property {string} [operator] - 操作员
+ * @property {string} [remark] - 备注
+ */
+
+// 引用公共类型定义
+/**
+ * @typedef {import('../types/common.js').ApiResponse} ApiResponse
+ * @typedef {import('../types/common.js').PageResult} PageResult
+ */
+
+/**
+ * 物流跟踪分页查询
+ * @param {number} current - 当前页码
+ * @param {number} size - 每页大小
+ * @param {ShipmentTrackingQueryParams} params - 查询参数
+ * @returns {Promise<AxiosResponse<ApiResponse<PageResult<ShipmentTrackingRecord>>>>} 分页查询结果
+ */
+export const getList = async (current, size, params) => {
+  return request({
+    url: '/api/blade-factory/api/factory/shipment-tracking',
+    method: 'get',
+    params: {
+      ...params,
+      current,
+      size
+    }
+  })
+}
+
+/**
+ * 添加物流跟踪记录
+ * @param {ShipmentTrackingForm} row - 物流跟踪表单数据
+ * @returns {Promise<AxiosResponse<ApiResponse<boolean>>>} 添加结果
+ */
+export const add = async (row) => {
+  return request({
+    url: '/api/blade-factory/api/factory/shipment-tracking',
+    method: 'post',
+    data: row
+  })
+}
+
+/**
+ * 修改物流跟踪记录
+ * @param {ShipmentTrackingForm} row - 物流跟踪表单数据
+ * @returns {Promise<AxiosResponse<ApiResponse<boolean>>>} 修改结果
+ */
+export const update = async (row) => {
+  return request({
+    url: '/api/blade-factory/api/factory/shipment-tracking',
+    method: 'put',
+    data: row
+  })
+}
+
+/**
+ * 删除物流跟踪记录
+ * @param {string} ids - 要删除的ID,多个用逗号分隔
+ * @returns {Promise<AxiosResponse<ApiResponse<boolean>>>} 删除结果
+ */
+export const remove = async (ids) => {
+  return request({
+    url: '/api/blade-factory/api/factory/shipment-tracking/remove',
+    method: 'delete',
+    params: {
+      ids
+    }
+  })
+}
+
+/**
+ * 获取物流跟踪记录详情
+ * @param {string|number} id - 跟踪记录ID
+ * @returns {Promise<AxiosResponse<ApiResponse<ShipmentTrackingRecord>>>} 物流跟踪记录详情
+ */
+export const getDetail = async (id) => {
+  return request({
+    url: `/api/blade-factory/api/factory/shipment-tracking/${id}`,
+    method: 'get'
+  })
+}
+
+/**
+ * 根据物流单号获取跟踪详情
+ * @param {string} trackingNo - 物流单号
+ * @returns {Promise<AxiosResponse<ApiResponse<ShipmentTrackingDetail>>>} 物流跟踪详情
+ */
+export const getTrackingDetail = async (trackingNo) => {
+  return request({
+    url: '/api/blade-factory/api/factory/shipment-tracking/detail',
+    method: 'get',
+    params: {
+      trackingNo
+    }
+  })
+}
+
+/**
+ * 根据发货单ID获取跟踪记录列表
+ * @param {string|number} shipmentId - 发货单ID
+ * @returns {Promise<AxiosResponse<ApiResponse<ShipmentTrackingRecord[]>>>} 跟踪记录列表
+ */
+export const getTrackingByShipmentId = async (shipmentId) => {
+  return request({
+    url: '/api/blade-factory/api/factory/shipment-tracking/by-shipment',
+    method: 'get',
+    params: {
+      shipmentId
+    }
+  })
+}
+
+/**
+ * 根据订单ID获取跟踪记录列表
+ * @param {string|number} orderId - 订单ID
+ * @returns {Promise<AxiosResponse<ApiResponse<ShipmentTrackingRecord[]>>>} 跟踪记录列表
+ */
+export const getTrackingByOrderId = async (orderId) => {
+  return request({
+    url: '/api/blade-factory/api/factory/shipment-tracking/by-order',
+    method: 'get',
+    params: {
+      orderId
+    }
+  })
+}
+
+/**
+ * 同步物流信息
+ * @param {string} trackingNo - 物流单号
+ * @param {string} logisticsCompanyCode - 物流公司编码
+ * @returns {Promise<AxiosResponse<ApiResponse<boolean>>>} 同步结果
+ */
+export const syncTrackingInfo = async (trackingNo, logisticsCompanyCode) => {
+  return request({
+    url: '/api/blade-factory/api/factory/shipment-tracking/sync',
+    method: 'post',
+    data: {
+      trackingNo,
+      logisticsCompanyCode
+    }
+  })
+}

+ 53 - 0
src/api/types/common.js

@@ -0,0 +1,53 @@
+/**
+ * 公共API类型定义
+ * @fileoverview 提供通用的API响应和分页类型定义,避免重复定义
+ */
+
+/**
+ * API响应类型定义
+ * @template T
+ * @typedef {Object} ApiResponse
+ * @property {number} code - 响应码
+ * @property {boolean} success - 是否成功
+ * @property {T} data - 响应数据
+ * @property {string} msg - 响应消息
+ */
+
+/**
+ * 分页结果类型定义
+ * @template T
+ * @typedef {Object} PageResult
+ * @property {T[]} records - 数据记录
+ * @property {number} total - 总记录数
+ * @property {number} size - 每页大小
+ * @property {number} current - 当前页码
+ * @property {Array} orders - 排序信息
+ * @property {boolean} optimizeCountSql - 是否优化count查询
+ * @property {boolean} hitCount - 是否命中count缓存
+ * @property {string|null} countId - count查询ID
+ * @property {string|null} maxLimit - 最大限制
+ * @property {boolean} searchCount - 是否查询count
+ * @property {number} pages - 总页数
+ */
+
+/**
+ * 基础查询参数类型定义
+ * @typedef {Object} BaseQueryParams
+ * @property {number} current - 当前页码
+ * @property {number} size - 每页大小
+ */
+
+/**
+ * 基础实体类型定义
+ * @typedef {Object} BaseEntity
+ * @property {string} id - 主键ID
+ * @property {string} createUser - 创建用户ID
+ * @property {string} createDept - 创建部门ID
+ * @property {string} createTime - 创建时间
+ * @property {string} updateUser - 更新用户ID
+ * @property {string} updateTime - 更新时间
+ * @property {0|1} status - 状态 1-正常 0-禁用
+ * @property {0|1} isDeleted - 是否删除 0-未删除 1-已删除
+ */
+
+export {}