Browse Source

refactor(order): 集中管理订单相关常量至constants模块

yz 2 months ago
parent
commit
a2c88fd2d5

+ 6 - 5
src/api/order/order-item.js

@@ -1,4 +1,5 @@
 import request from '@/router/axios';
+import { ORDER_ITEM_STATUS } from '@/constants';
 
 /**
  * 订单明细查询参数类型定义
@@ -13,7 +14,7 @@ import request from '@/router/axios';
  * @property {string} [mainItemCategoryName] - 主物料分类名称
  * @property {string|number} [warehouseId] - 仓库ID
  * @property {string} [warehouseName] - 仓库名称
- * @property {number} [itemStatus] - 明细状态 0-待确认 1-已确认 2-生产中 3-已完成 4-已取消
+ * @property {keyof typeof ORDER_ITEM_STATUS} [itemStatus] - 明细状态
  */
 
 /**
@@ -37,7 +38,7 @@ import request from '@/router/axios';
  * @property {string|number} taxRate - 税率
  * @property {string|number} taxAmount - 税额
  * @property {string|number} totalAmount - 总金额
- * @property {number} itemStatus - 明细状态 0-待确认 1-已确认 2-生产中 3-已完成 4-已取消
+ * @property {keyof typeof ORDER_ITEM_STATUS} itemStatus - 明细状态
  */
 
 /**
@@ -49,8 +50,8 @@ import request from '@/router/axios';
  * @property {string} createTime - 创建时间
  * @property {string} updateUser - 更新用户ID
  * @property {string} updateTime - 更新时间
- * @property {number} status - 状态 1-正常 0-禁用
- * @property {number} isDeleted - 是否删除 0-未删除 1-已删除
+ * @property {0|1} status - 状态 1-正常 0-禁用
+ * @property {0|1} isDeleted - 是否删除 0-未删除 1-已删除
  * @property {string|number} orderId - 订单ID
  * @property {string} orderCode - 订单编码
  * @property {string|number} itemId - 物料ID
@@ -68,7 +69,7 @@ import request from '@/router/axios';
  * @property {string} taxRate - 税率
  * @property {string} taxAmount - 税额
  * @property {string} totalAmount - 总金额
- * @property {number} itemStatus - 明细状态 0-待确认 1-已确认 2-生产中 3-已完成 4-已取消
+ * @property {keyof typeof ORDER_ITEM_STATUS} itemStatus - 明细状态
  */
 
 /**

+ 9 - 8
src/api/order/order.js

@@ -1,4 +1,5 @@
 import request from '@/router/axios';
+import { ORDER_TYPES, ORDER_STATUS } from '@/constants';
 
 /**
  * 获取订单列表
@@ -96,8 +97,8 @@ export const getCustomerAddressList = (customerCode) => {
  * @property {string} [orgName] - 组织名称
  * @property {string} [customerCode] - 客户编码
  * @property {string} [customerName] - 客户名称
- * @property {number} [orderType] - 订单类型 0-采购订单 1-销售订单
- * @property {number} [status] - 订单状态 0-草稿 1-已提交 2-已确认 3-已完成 4-已取消
+ * @property {keyof typeof ORDER_TYPES} [orderType] - 订单类型
+ * @property {keyof typeof ORDER_STATUS} [status] - 订单状态
  * @property {string} [receiverName] - 收货人姓名
  * @property {string} [receiverPhone] - 收货人电话
  * @property {string} [createTimeStart] - 创建时间开始
@@ -115,7 +116,7 @@ export const getCustomerAddressList = (customerCode) => {
  * @property {string|number} customerId - 客户ID
  * @property {string} customerCode - 客户编码
  * @property {string} customerName - 客户名称
- * @property {number} orderType - 订单类型 0-采购订单 1-销售订单
+ * @property {keyof typeof ORDER_TYPES} orderType - 订单类型
  * @property {number|string} totalAmount - 订单总金额
  * @property {number|string} totalQuantity - 订单总数量
  * @property {string|number} addressId - 收货地址ID
@@ -123,7 +124,7 @@ export const getCustomerAddressList = (customerCode) => {
  * @property {string} receiverPhone - 收货人电话
  * @property {string} receiverAddress - 收货详细地址
  * @property {string} receiverRegion - 收货地区
- * @property {number} status - 订单状态 0-草稿 1-已提交 2-已确认 3-已完成 4-已取消
+ * @property {keyof typeof ORDER_STATUS} status - 订单状态
  */
 
 /**
@@ -135,8 +136,8 @@ export const getCustomerAddressList = (customerCode) => {
  * @property {string} createTime - 创建时间
  * @property {string} updateUser - 更新用户ID
  * @property {string} updateTime - 更新时间
- * @property {number} status - 订单状态 0-草稿 1-已提交 2-已确认 3-已完成 4-已取消
- * @property {number} isDeleted - 是否删除 0-未删除 1-已删除
+ * @property {keyof typeof ORDER_STATUS} status - 订单状态
+ * @property {0|1} isDeleted - 是否删除 0-未删除 1-已删除
  * @property {string} orderCode - 订单编码
  * @property {number} orgId - 组织ID
  * @property {string} orgCode - 组织编码
@@ -144,7 +145,7 @@ export const getCustomerAddressList = (customerCode) => {
  * @property {number} customerId - 客户ID
  * @property {string} customerCode - 客户编码
  * @property {string} customerName - 客户名称
- * @property {number} orderType - 订单类型 0-采购订单 1-销售订单
+ * @property {keyof typeof ORDER_TYPES} orderType - 订单类型
  * @property {string} totalAmount - 订单总金额
  * @property {string} totalQuantity - 订单总数量
  * @property {number} addressId - 收货地址ID
@@ -164,7 +165,7 @@ export const getCustomerAddressList = (customerCode) => {
  * @property {string} receiverPhone - 收货人电话
  * @property {string} receiverAddress - 收货详细地址
  * @property {string} regionName - 收货地区
- * @property {number} isDefault - 是否默认地址 0-否 1-是
+ * @property {0|1} isDefault - 是否默认地址 0-否 1-是
  */
 
 /**

+ 16 - 37
src/components/order-item-management/index.vue

@@ -43,6 +43,13 @@
 
 <script>
 import { getList, add, update, getDetail } from '@/api/order/order-item'
+import {
+  ORDER_ITEM_STATUS,
+  getOrderStatusLabel,
+  getOrderStatusTagType,
+  getOrderItemStatusLabel,
+  getOrderItemStatusTagType
+} from '@/constants'
 
 /**
  * 订单明细查询参数类型定义
@@ -57,7 +64,7 @@ import { getList, add, update, getDetail } from '@/api/order/order-item'
  * @property {string} [mainItemCategoryName] - 主物料分类名称
  * @property {string|number} [warehouseId] - 仓库ID
  * @property {string} [warehouseName] - 仓库名称
- * @property {number} [itemStatus] - 明细状态 0-待确认 1-已确认 2-生产中 3-已完成 4-已取消
+ * @property {keyof typeof ORDER_ITEM_STATUS} [itemStatus] - 明细状态
  */
 
 /**
@@ -81,7 +88,7 @@ import { getList, add, update, getDetail } from '@/api/order/order-item'
  * @property {string|number} taxRate - 税率
  * @property {string|number} taxAmount - 税额
  * @property {string|number} totalAmount - 总金额
- * @property {number} itemStatus - 明细状态 0-待确认 1-已确认 2-生产中 3-已完成 4-已取消
+ * @property {keyof typeof ORDER_ITEM_STATUS} itemStatus - 明细状态
  */
 
 /**
@@ -93,8 +100,8 @@ import { getList, add, update, getDetail } from '@/api/order/order-item'
  * @property {string} createTime - 创建时间
  * @property {string} updateUser - 更新用户ID
  * @property {string} updateTime - 更新时间
- * @property {number} status - 状态 1-正常 0-禁用
- * @property {number} isDeleted - 是否删除 0-未删除 1-已删除
+ * @property {0|1} status - 状态 1-正常 0-禁用
+ * @property {0|1} isDeleted - 是否删除 0-未删除 1-已删除
  * @property {string|number} orderId - 订单ID
  * @property {string} orderCode - 订单编码
  * @property {string|number} itemId - 物料ID
@@ -112,7 +119,7 @@ import { getList, add, update, getDetail } from '@/api/order/order-item'
  * @property {string} taxRate - 税率
  * @property {string} taxAmount - 税额
  * @property {string} totalAmount - 总金额
- * @property {number} itemStatus - 明细状态 0-待确认 1-已确认 2-生产中 3-已完成 4-已取消
+ * @property {keyof typeof ORDER_ITEM_STATUS} itemStatus - 明细状态
  */
 
 /**
@@ -628,14 +635,7 @@ export default {
      * @returns {string} 状态类型
      */
     getOrderStatusType(status) {
-      const statusMap = {
-        0: 'info',     // 草稿
-        1: 'warning',  // 已提交
-        2: 'primary',  // 已确认
-        3: 'success',  // 已完成
-        4: 'danger'    // 已取消
-      }
-      return statusMap[status] || 'info'
+      return getOrderStatusTagType(status)
     },
 
     /**
@@ -644,14 +644,7 @@ export default {
      * @returns {string} 状态文本
      */
     getOrderStatusText(status) {
-      const statusMap = {
-        0: '草稿',
-        1: '已提交',
-        2: '已确认',
-        3: '已完成',
-        4: '已取消'
-      }
-      return statusMap[status] || '未知'
+      return getOrderStatusLabel(status)
     },
 
     /**
@@ -660,14 +653,7 @@ export default {
      * @returns {string} 状态类型
      */
     getItemStatusType(status) {
-      const statusMap = {
-        0: 'info',     // 待确认
-        1: 'success',  // 已确认
-        2: 'warning',  // 生产中
-        3: 'success',  // 已完成
-        4: 'danger'    // 已取消
-      }
-      return statusMap[status] || 'info'
+      return getOrderItemStatusTagType(status)
     },
 
     /**
@@ -676,14 +662,7 @@ export default {
      * @returns {string} 状态文本
      */
     getItemStatusText(status) {
-      const statusMap = {
-        0: '待确认',
-        1: '已确认',
-        2: '生产中',
-        3: '已完成',
-        4: '已取消'
-      }
-      return statusMap[status] || '未知'
+      return getOrderItemStatusLabel(status)
     },
 
     /**

+ 3 - 16
src/components/order-item-table/index.vue

@@ -63,6 +63,7 @@
 
 <script>
 import { getList } from '@/api/order/order-item'
+import { getOrderItemStatusLabel, getOrderItemStatusTagType } from '@/constants'
 
 export default {
   name: 'OrderItemTable',
@@ -106,24 +107,10 @@ export default {
       }
     },
     getStatusText(status) {
-      const statusMap = {
-        0: '待确认',
-        1: '已确认',
-        2: '生产中',
-        3: '已完成',
-        4: '已取消'
-      }
-      return statusMap[status] || '未知'
+      return getOrderItemStatusLabel(status)
     },
     getStatusType(status) {
-      const typeMap = {
-        0: 'warning',
-        1: 'success',
-        2: 'primary',
-        3: 'info',
-        4: 'danger'
-      }
-      return typeMap[status] || 'info'
+      return getOrderItemStatusTagType(status)
     }
   },
   filters: {

+ 4 - 1
src/constants/index.js

@@ -24,4 +24,7 @@ export * from './marketing-activity'
 export * from './survey'
 
 // 经销商销售预测申报相关常量
-export * from './forecast'
+export * from './forecast'
+
+// 订单管理相关常量
+export * from './order'

+ 292 - 0
src/constants/order.js

@@ -0,0 +1,292 @@
+/**
+ * 订单管理相关常量定义
+ * @fileoverview 订单类型、订单状态、订单明细状态等枚举值和工具函数
+ */
+
+/**
+ * 订单类型枚举
+ * @readonly
+ * @enum {1}
+ */
+export const ORDER_TYPES = {
+  /** 普通订单 */
+  NORMAL: 1
+}
+
+/**
+ * 订单状态枚举
+ * @readonly
+ * @enum {0 | 1 | 2 | 3 | 4 | 5}
+ */
+export const ORDER_STATUS = {
+  /** 草稿 */
+  DRAFT: 0,
+  /** 已提交 */
+  SUBMITTED: 1,
+  /** 已确认 */
+  CONFIRMED: 2,
+  /** 部分发货 */
+  PARTIAL_SHIPPED: 3,
+  /** 已完成 */
+  COMPLETED: 4,
+  /** 已取消 */
+  CANCELLED: 5
+}
+
+/**
+ * 订单明细状态枚举
+ * @readonly
+ * @enum {0 | 1 | 2 | 3}
+ */
+export const ORDER_ITEM_STATUS = {
+  /** 未确认 */
+  UNCONFIRMED: 0,
+  /** 已确认 */
+  CONFIRMED: 1,
+  /** 部分发货 */
+  PARTIAL_SHIPPED: 2,
+  /** 已完成 */
+  COMPLETED: 3
+}
+
+/**
+ * 订单类型配置映射
+ * @readonly
+ * @type {Record<1, {readonly label: '普通订单', readonly type: 'primary', readonly color: '#409EFF'}>}
+ */
+export const ORDER_TYPE_CONFIG = {
+  [ORDER_TYPES.NORMAL]: {
+    label: '普通订单',
+    type: 'primary',
+    color: '#409EFF'
+  }
+}
+
+/**
+ * 订单状态配置映射
+ * @readonly
+ * @type {Record<0 | 1 | 2 | 3 | 4 | 5, {readonly label: string, readonly type: 'info' | 'warning' | 'primary' | 'success' | 'danger', readonly color: string}>}
+ */
+export const ORDER_STATUS_CONFIG = {
+  [ORDER_STATUS.DRAFT]: {
+    label: '草稿',
+    type: 'info',
+    color: '#909399'
+  },
+  [ORDER_STATUS.SUBMITTED]: {
+    label: '已提交',
+    type: 'warning',
+    color: '#E6A23C'
+  },
+  [ORDER_STATUS.CONFIRMED]: {
+    label: '已确认',
+    type: 'primary',
+    color: '#409EFF'
+  },
+  [ORDER_STATUS.PARTIAL_SHIPPED]: {
+    label: '部分发货',
+    type: 'warning',
+    color: '#E6A23C'
+  },
+  [ORDER_STATUS.COMPLETED]: {
+    label: '已完成',
+    type: 'success',
+    color: '#67C23A'
+  },
+  [ORDER_STATUS.CANCELLED]: {
+    label: '已取消',
+    type: 'danger',
+    color: '#F56C6C'
+  }
+}
+
+/**
+ * 订单明细状态配置映射
+ * @readonly
+ * @type {Record<0 | 1 | 2 | 3, {readonly label: string, readonly type: 'warning' | 'primary' | 'success', readonly color: string}>}
+ */
+export const ORDER_ITEM_STATUS_CONFIG = {
+  [ORDER_ITEM_STATUS.UNCONFIRMED]: {
+    label: '未确认',
+    type: 'warning',
+    color: '#E6A23C'
+  },
+  [ORDER_ITEM_STATUS.CONFIRMED]: {
+    label: '已确认',
+    type: 'primary',
+    color: '#409EFF'
+  },
+  [ORDER_ITEM_STATUS.PARTIAL_SHIPPED]: {
+    label: '部分发货',
+    type: 'warning',
+    color: '#E6A23C'
+  },
+  [ORDER_ITEM_STATUS.COMPLETED]: {
+    label: '已完成',
+    type: 'success',
+    color: '#67C23A'
+  }
+}
+
+/**
+ * 订单类型选项数据
+ * @readonly
+ * @type {ReadonlyArray<{readonly label: '普通订单', readonly value: 1}>}
+ */
+export const ORDER_TYPE_OPTIONS = [
+  { label: '普通订单', value: ORDER_TYPES.NORMAL }
+]
+
+/**
+ * 订单状态选项数据
+ * @readonly
+ * @type {ReadonlyArray<{readonly label: string, readonly value: 0 | 1 | 2 | 3 | 4 | 5}>}
+ */
+export const ORDER_STATUS_OPTIONS = [
+  { label: '草稿', value: ORDER_STATUS.DRAFT },
+  { label: '已提交', value: ORDER_STATUS.SUBMITTED },
+  { label: '已确认', value: ORDER_STATUS.CONFIRMED },
+  { label: '部分发货', value: ORDER_STATUS.PARTIAL_SHIPPED },
+  { label: '已完成', value: ORDER_STATUS.COMPLETED },
+  { label: '已取消', value: ORDER_STATUS.CANCELLED }
+]
+
+/**
+ * 订单明细状态选项数据
+ * @readonly
+ * @type {ReadonlyArray<{readonly label: string, readonly value: 0 | 1 | 2 | 3}>}
+ */
+export const ORDER_ITEM_STATUS_OPTIONS = [
+  { label: '未确认', value: ORDER_ITEM_STATUS.UNCONFIRMED },
+  { label: '已确认', value: ORDER_ITEM_STATUS.CONFIRMED },
+  { label: '部分发货', value: ORDER_ITEM_STATUS.PARTIAL_SHIPPED },
+  { label: '已完成', value: ORDER_ITEM_STATUS.COMPLETED }
+]
+
+// ==================== 工具函数 ====================
+
+/**
+ * 获取订单类型标签
+ * @param {1} orderType - 订单类型值
+ * @returns {'普通订单' | '未知类型'} 订单类型标签
+ */
+export function getOrderTypeLabel(orderType) {
+  const config = ORDER_TYPE_CONFIG[orderType]
+  return config ? config.label : '未知类型'
+}
+
+/**
+ * 获取订单类型Element UI标签类型
+ * @param {1} orderType - 订单类型值
+ * @returns {'primary' | 'info'} Element UI标签类型
+ */
+export function getOrderTypeTagType(orderType) {
+  const config = ORDER_TYPE_CONFIG[orderType]
+  return config ? config.type : 'info'
+}
+
+/**
+ * 获取订单类型颜色
+ * @param {1} orderType - 订单类型值
+ * @returns {string} 十六进制颜色值
+ */
+export function getOrderTypeColor(orderType) {
+  const config = ORDER_TYPE_CONFIG[orderType]
+  return config ? config.color : '#909399'
+}
+
+/**
+ * 获取订单状态标签
+ * @param {0 | 1 | 2 | 3 | 4 | 5} status - 订单状态值
+ * @returns {string} 订单状态标签
+ */
+export function getOrderStatusLabel(status) {
+  const config = ORDER_STATUS_CONFIG[status]
+  return config ? config.label : '未知状态'
+}
+
+/**
+ * 获取订单状态Element UI标签类型
+ * @param {0 | 1 | 2 | 3 | 4 | 5} status - 订单状态值
+ * @returns {'info' | 'warning' | 'primary' | 'success' | 'danger'} Element UI标签类型
+ */
+export function getOrderStatusTagType(status) {
+  const config = ORDER_STATUS_CONFIG[status]
+  return config ? config.type : 'info'
+}
+
+/**
+ * 获取订单状态颜色
+ * @param {0 | 1 | 2 | 3 | 4 | 5} status - 订单状态值
+ * @returns {string} 十六进制颜色值
+ */
+export function getOrderStatusColor(status) {
+  const config = ORDER_STATUS_CONFIG[status]
+  return config ? config.color : '#909399'
+}
+
+/**
+ * 获取订单明细状态标签
+ * @param {0 | 1 | 2 | 3} itemStatus - 订单明细状态值
+ * @returns {string} 订单明细状态标签
+ */
+export function getOrderItemStatusLabel(itemStatus) {
+  const config = ORDER_ITEM_STATUS_CONFIG[itemStatus]
+  return config ? config.label : '未知状态'
+}
+
+/**
+ * 获取订单明细状态Element UI标签类型
+ * @param {0 | 1 | 2 | 3} itemStatus - 订单明细状态值
+ * @returns {'warning' | 'primary' | 'success' | 'info'} Element UI标签类型
+ */
+export function getOrderItemStatusTagType(itemStatus) {
+  const config = ORDER_ITEM_STATUS_CONFIG[itemStatus]
+  return config ? config.type : 'info'
+}
+
+/**
+ * 获取订单明细状态颜色
+ * @param {0 | 1 | 2 | 3} itemStatus - 订单明细状态值
+ * @returns {string} 十六进制颜色值
+ */
+export function getOrderItemStatusColor(itemStatus) {
+  const config = ORDER_ITEM_STATUS_CONFIG[itemStatus]
+  return config ? config.color : '#909399'
+}
+
+/**
+ * 检查订单是否可以编辑
+ * @param {0 | 1 | 2 | 3 | 4 | 5} status - 订单状态值
+ * @returns {boolean} 是否可以编辑
+ */
+export function isOrderEditable(status) {
+  return status === ORDER_STATUS.DRAFT || status === ORDER_STATUS.SUBMITTED
+}
+
+/**
+ * 检查订单是否可以取消
+ * @param {0 | 1 | 2 | 3 | 4 | 5} status - 订单状态值
+ * @returns {boolean} 是否可以取消
+ */
+export function isOrderCancellable(status) {
+  return status !== ORDER_STATUS.COMPLETED && status !== ORDER_STATUS.CANCELLED
+}
+
+/**
+ * 检查订单明细是否可以编辑
+ * @param {0 | 1 | 2 | 3} itemStatus - 订单明细状态值
+ * @returns {boolean} 是否可以编辑
+ */
+export function isOrderItemEditable(itemStatus) {
+  return itemStatus === ORDER_ITEM_STATUS.UNCONFIRMED || itemStatus === ORDER_ITEM_STATUS.CONFIRMED
+}
+
+/**
+ * 检查订单明细是否可以取消
+ * @param {0 | 1 | 2 | 3} itemStatus - 订单明细状态值
+ * @returns {boolean} 是否可以取消
+ */
+export function isOrderItemCancellable(itemStatus) {
+  return itemStatus !== ORDER_ITEM_STATUS.COMPLETED
+}

+ 2 - 2
src/mixins/order/customerManagementMixin.js

@@ -25,7 +25,7 @@ import { getCustomerAddressList } from '@/api/order/order'
  * @property {string} receiverPhone - 收货人电话
  * @property {string} receiverAddress - 收货详细地址
  * @property {string} receiverRegion - 收货地区
- * @property {number} isDefault - 是否默认地址 0-否 1-是
+ * @property {0|1} isDefault - 是否默认地址 0-否 1-是
  */
 
 export default {
@@ -51,7 +51,7 @@ export default {
 
       /**
        * 客户搜索定时器
-       * @type {number|null}
+       * @type {NodeJS.Timeout|null}
        */
       customerSearchTimer: null,
 

+ 5 - 3
src/mixins/order/orderDataMixin.js

@@ -3,6 +3,8 @@
  * 负责管理表格数据、分页信息、选择状态等数据相关逻辑
  */
 
+import { ORDER_TYPES, ORDER_STATUS } from '@/constants'
+
 /**
  * 订单列表项类型定义
  * @typedef {Object} OrderItem
@@ -12,8 +14,8 @@
  * @property {string} createTime - 创建时间
  * @property {string} updateUser - 更新用户ID
  * @property {string} updateTime - 更新时间
- * @property {number} status - 订单状态 0-草稿 1-已提交 2-已确认 3-部分发货 4-已完成 5-已取消
- * @property {number} isDeleted - 是否删除 0-未删除 1-已删除
+ * @property {keyof typeof ORDER_STATUS} status - 订单状态
+ * @property {0|1} isDeleted - 是否删除 0-未删除 1-已删除
  * @property {string} orderCode - 订单编码
  * @property {number} orgId - 组织ID
  * @property {string} orgCode - 组织编码
@@ -21,7 +23,7 @@
  * @property {number} customerId - 客户ID
  * @property {string} customerCode - 客户编码
  * @property {string} customerName - 客户名称
- * @property {number} orderType - 订单类型 1-普通订单
+ * @property {keyof typeof ORDER_TYPES} orderType - 订单类型
  * @property {string} totalAmount - 订单总金额
  * @property {string} totalQuantity - 订单总数量
  * @property {number} addressId - 收货地址ID

+ 3 - 3
src/mixins/order/orderFormMixin.js

@@ -8,7 +8,7 @@ import {
   ORDER_STATUS,
   ORDER_TYPE_OPTIONS,
   ORDER_STATUS_OPTIONS
-} from '@/views/order/order/constants'
+} from '@/constants'
 
 /**
  * 订单表单数据类型定义
@@ -21,7 +21,7 @@ import {
  * @property {string|number} customerId - 客户ID
  * @property {string} customerCode - 客户编码
  * @property {string} customerName - 客户名称
- * @property {number} orderType - 订单类型
+ * @property {keyof typeof ORDER_TYPES} orderType - 订单类型
  * @property {number|string} totalAmount - 订单总金额
  * @property {number|string} totalQuantity - 订单总数量
  * @property {string|number} addressId - 收货地址ID
@@ -29,7 +29,7 @@ import {
  * @property {string} receiverPhone - 收货人电话
  * @property {string} receiverAddress - 收货详细地址
  * @property {string} receiverRegion - 收货地区
- * @property {number} status - 订单状态
+ * @property {keyof typeof ORDER_STATUS} status - 订单状态
  * @property {string} createTime - 创建时间
  * @property {string} updateTime - 更新时间
  * @property {string} submitTime - 提交时间

+ 4 - 2
src/mixins/order/orderSearchMixin.js

@@ -3,6 +3,8 @@
  * 负责管理搜索表单、搜索逻辑、重置等功能
  */
 
+import { ORDER_TYPES, ORDER_STATUS } from '@/constants'
+
 /**
  * 订单查询参数类型定义
  * @typedef {Object} OrderQueryParams
@@ -11,8 +13,8 @@
  * @property {string} [orgName] - 组织名称
  * @property {string} [customerCode] - 客户编码
  * @property {string} [customerName] - 客户名称
- * @property {number} [orderType] - 订单类型
- * @property {number} [status] - 订单状态
+ * @property {keyof typeof ORDER_TYPES} [orderType] - 订单类型
+ * @property {keyof typeof ORDER_STATUS} [status] - 订单状态
  * @property {string} [receiverName] - 收货人姓名
  * @property {string} [receiverPhone] - 收货人电话
  * @property {string} [createTimeStart] - 创建时间开始

+ 1 - 1
src/mixins/order/orderUtilsMixin.js

@@ -8,7 +8,7 @@ import {
   getOrderTypeTagType,
   getOrderStatusLabel,
   getOrderStatusTagType
-} from '@/views/order/order/constants'
+} from '@/constants'
 
 export default {
   methods: {

+ 50 - 64
src/views/order/order/constants.js

@@ -1,127 +1,113 @@
+// 导入统一的订单常量定义
+import {
+  ORDER_TYPE,
+  ORDER_STATUS,
+  ORDER_TYPE_CONFIG,
+  ORDER_STATUS_CONFIG,
+  ORDER_TYPE_OPTIONS,
+  ORDER_STATUS_OPTIONS,
+  getOrderTypeLabel as getOrderTypeLabelFromConstants,
+  getOrderTypeTagType as getOrderTypeTagTypeFromConstants,
+  getOrderStatusLabel as getOrderStatusLabelFromConstants,
+  getOrderStatusTagType as getOrderStatusTagTypeFromConstants
+} from '@/constants'
+
 /**
- * 订单类型枚举
+ * 订单类型枚举(兼容性别名)
  * @readonly
  * @enum {number}
+ * @deprecated 请使用 @/constants 中的 ORDER_TYPE
  */
-export const ORDER_TYPES = {
-    NORMAL: 1  // 普通订单
-};
+export const ORDER_TYPES = ORDER_TYPE
 
 /**
- * 订单状态枚举
+ * 订单状态枚举(兼容性别名)
  * @readonly
  * @enum {number}
+ * @deprecated 请使用 @/constants 中的 ORDER_STATUS
  */
-export const ORDER_STATUS = {
-    DRAFT: 0,           // 草稿
-    SUBMITTED: 1,       // 已提交
-    CONFIRMED: 2,       // 已确认
-    PARTIAL_SHIPPED: 3, // 部分发货
-    COMPLETED: 4,       // 已完成
-    CANCELLED: 5        // 已取消
-};
+export { ORDER_STATUS }
 
 /**
- * 订单类型标签映射
+ * 订单类型标签映射(兼容性别名)
  * @readonly
  * @type {Record<number, string>}
+ * @deprecated 请使用 @/constants 中的 getOrderTypeLabel 函数
  */
-export const ORDER_TYPE_LABELS = {
-    [ORDER_TYPES.NORMAL]: '普通订单'
-};
+export const ORDER_TYPE_LABELS = Object.fromEntries(
+  Object.entries(ORDER_TYPE_CONFIG).map(([key, config]) => [key, config.label])
+)
 
 /**
- * 订单状态标签映射
+ * 订单状态标签映射(兼容性别名)
  * @readonly
  * @type {Record<number, string>}
+ * @deprecated 请使用 @/constants 中的 getOrderStatusLabel 函数
  */
-export const ORDER_STATUS_LABELS = {
-    [ORDER_STATUS.DRAFT]: '草稿',
-    [ORDER_STATUS.SUBMITTED]: '已提交',
-    [ORDER_STATUS.CONFIRMED]: '已确认',
-    [ORDER_STATUS.PARTIAL_SHIPPED]: '部分发货',
-    [ORDER_STATUS.COMPLETED]: '已完成',
-    [ORDER_STATUS.CANCELLED]: '已取消'
-};
+export const ORDER_STATUS_LABELS = Object.fromEntries(
+  Object.entries(ORDER_STATUS_CONFIG).map(([key, config]) => [key, config.label])
+)
 
 /**
- * 订单类型标签类型映射(用于Element UI的tag组件
+ * 订单类型标签类型映射(兼容性别名)
  * @readonly
  * @type {Record<number, string>}
+ * @deprecated 请使用 @/constants 中的 getOrderTypeTagType 函数
  */
-export const ORDER_TYPE_TAG_TYPES = {
-    [ORDER_TYPES.NORMAL]: 'success'
-};
+export const ORDER_TYPE_TAG_TYPES = Object.fromEntries(
+  Object.entries(ORDER_TYPE_CONFIG).map(([key, config]) => [key, config.type])
+)
 
 /**
- * 订单状态标签类型映射(用于Element UI的tag组件
+ * 订单状态标签类型映射(兼容性别名
  * @readonly
  * @type {Record<number, string>}
+ * @deprecated 请使用 @/constants 中的 getOrderStatusTagType 函数
  */
-export const ORDER_STATUS_TAG_TYPES = {
-    [ORDER_STATUS.DRAFT]: 'info',
-    [ORDER_STATUS.SUBMITTED]: 'warning',
-    [ORDER_STATUS.CONFIRMED]: 'primary',
-    [ORDER_STATUS.PARTIAL_SHIPPED]: '',
-    [ORDER_STATUS.COMPLETED]: 'success',
-    [ORDER_STATUS.CANCELLED]: 'danger'
-};
+export const ORDER_STATUS_TAG_TYPES = Object.fromEntries(
+  Object.entries(ORDER_STATUS_CONFIG).map(([key, config]) => [key, config.type])
+)
 
 /**
- * 订单类型选项数组(用于下拉选择
+ * 订单类型选项数组(兼容性别名)
  * @readonly
  * @type {Array<{label: string, value: number}>}
+ * @deprecated 请使用 @/constants 中的 ORDER_TYPE_OPTIONS
  */
-export const ORDER_TYPE_OPTIONS = [
-    { label: ORDER_TYPE_LABELS[ORDER_TYPES.NORMAL], value: ORDER_TYPES.NORMAL }
-];
+export { ORDER_TYPE_OPTIONS }
 
 /**
- * 订单状态选项数组(用于下拉选择
+ * 订单状态选项数组(兼容性别名
  * @readonly
  * @type {Array<{label: string, value: number}>}
+ * @deprecated 请使用 @/constants 中的 ORDER_STATUS_OPTIONS
  */
-export const ORDER_STATUS_OPTIONS = [
-    { label: ORDER_STATUS_LABELS[ORDER_STATUS.DRAFT], value: ORDER_STATUS.DRAFT },
-    { label: ORDER_STATUS_LABELS[ORDER_STATUS.SUBMITTED], value: ORDER_STATUS.SUBMITTED },
-    { label: ORDER_STATUS_LABELS[ORDER_STATUS.CONFIRMED], value: ORDER_STATUS.CONFIRMED },
-    { label: ORDER_STATUS_LABELS[ORDER_STATUS.PARTIAL_SHIPPED], value: ORDER_STATUS.PARTIAL_SHIPPED },
-    { label: ORDER_STATUS_LABELS[ORDER_STATUS.COMPLETED], value: ORDER_STATUS.COMPLETED },
-    { label: ORDER_STATUS_LABELS[ORDER_STATUS.CANCELLED], value: ORDER_STATUS.CANCELLED }
-];
+export { ORDER_STATUS_OPTIONS }
 
 /**
  * 获取订单类型标签
  * @param {number} orderType - 订单类型值
  * @returns {string} 订单类型标签
  */
-export const getOrderTypeLabel = (orderType) => {
-    return ORDER_TYPE_LABELS[orderType] || '未知类型';
-};
+export const getOrderTypeLabel = getOrderTypeLabelFromConstants
 
 /**
  * 获取订单类型标签类型
  * @param {number} orderType - 订单类型值
  * @returns {string} 标签类型
  */
-export const getOrderTypeTagType = (orderType) => {
-    return ORDER_TYPE_TAG_TYPES[orderType] || '';
-};
+export const getOrderTypeTagType = getOrderTypeTagTypeFromConstants
 
 /**
  * 获取订单状态标签
  * @param {number} status - 订单状态值
  * @returns {string} 订单状态标签
  */
-export const getOrderStatusLabel = (status) => {
-    return ORDER_STATUS_LABELS[status] || '未知状态';
-};
+export const getOrderStatusLabel = getOrderStatusLabelFromConstants
 
 /**
  * 获取订单状态标签类型
  * @param {number} status - 订单状态值
  * @returns {string} 标签类型
  */
-export const getOrderStatusTagType = (status) => {
-    return ORDER_STATUS_TAG_TYPES[status] || 'info';
-};
+export const getOrderStatusTagType = getOrderStatusTagTypeFromConstants

+ 5 - 7
src/views/order/order/index-avue.vue

@@ -138,15 +138,13 @@
 import { option } from './option'
 import { getList, add, update, remove, getDetail } from '@/api/order/order'
 import {
-  ORDER_TYPE_LABELS,
-  ORDER_STATUS_LABELS,
-  ORDER_TYPE_TAG_TYPES,
-  ORDER_STATUS_TAG_TYPES,
+  ORDER_TYPES,
+  ORDER_STATUS,
   getOrderTypeLabel,
   getOrderTypeTagType,
   getOrderStatusLabel,
   getOrderStatusTagType
-} from './constants'
+} from '@/constants'
 import OrderItemManagement from '@/components/order-item-management'
 import OrderItemTable from '@/components/order-item-table'
 import { mapGetters } from 'vuex'
@@ -227,8 +225,8 @@ export default {
     beforeOpen(done, type) {
       if (type === 'add') {
         this.form = {
-          orderType: 1,
-          status: 0
+          orderType: ORDER_TYPES.NORMAL,
+          status: ORDER_STATUS.DRAFT
         }
       }
       done()

+ 13 - 1
src/views/order/order/option.js

@@ -1,4 +1,4 @@
-import { ORDER_TYPE_OPTIONS, ORDER_STATUS_OPTIONS } from './constants'
+import { ORDER_TYPE_OPTIONS, ORDER_STATUS_OPTIONS, ORDER_ITEM_STATUS_OPTIONS } from '@/constants'
 
 /**
  * 订单模块 Avue.js 配置
@@ -287,6 +287,18 @@ export const orderItemOption = {
       addDisplay: false
     },
     {
+      label: '明细状态',
+      prop: 'itemStatus',
+      type: 'select',
+      dicData: ORDER_ITEM_STATUS_OPTIONS,
+      search: true,
+      minWidth: 100,
+      align: 'center',
+      slot: true,
+      editDisabled: true,
+      addDisplay: false
+    },
+    {
       label: '备注',
       prop: 'remark',
       type: 'textarea',