Просмотр исходного кода

refactor(常量): 集中管理订单和物料相关常量

yz 2 недель назад
Родитель
Сommit
7c6639c525

+ 29 - 252
src/components/order-form/constants.js

@@ -1,263 +1,40 @@
 /**
- * @fileoverview 订单表单相关常量定义和类型定义
- * @description 定义订单表单组件使用的枚举值、常量和TypeScript类型注释
+ * 订单表单相关常量定义
+ * @fileoverview 从统一的常量文件导入订单相关枚举和配置
  */
 
-// 导入明细管理中的状态定义和工具函数
-import {
-  ORDER_ITEM_STATUS,
-  getOrderItemStatusLabel,
-  getOrderItemStatusTagType,
-  getOrderItemStatusColor
-} from '@/constants/order'
-
-/**
- * 订单类型枚举
- * @readonly
- * @enum {number}
- */
-export const OrderType = {
-  /** 普通订单 */
-  NORMAL: 1,
-  /** 紧急订单 */
-  URGENT: 2,
-  /** 预订订单 */
-  RESERVATION: 3
-}
-
-/**
- * 订单状态枚举
- * @readonly
- * @enum {number}
- */
-export const OrderStatus = {
-  /** 草稿 */
-  DRAFT: 0,
-  /** 待审核 */
-  PENDING: 1,
-  /** 已审核 */
-  APPROVED: 2,
-  /** 已发货 */
-  SHIPPED: 3,
-  /** 已完成 */
-  COMPLETED: 4,
-  /** 已取消 */
-  CANCELLED: 5
-}
-
-/**
- * 物料明细数据来源枚举
- * @readonly
- * @enum {string}
- */
-export const MaterialDetailDataSource = {
-  /** 远程加载的数据(从订单获取) */
-  REMOTE: 'REMOTE',
-  /** 用户导入的数据 */
-  IMPORTED: 'IMPORTED'
-}
-
-/**
- * 物料明细状态枚举
- * @description 对应数据库item_status字段:0未确认 1已确认 2部分发货 3已完成
- * @readonly
- * @enum {0|1|2|3}
- */
-export const MaterialDetailStatus = {
-  /** 未确认 */
-  UNCONFIRMED: 0,
-  /** 已确认 */
-  CONFIRMED: 1,
-  /** 部分发货 */
-  PARTIAL_SHIPPED: 2,
-  /** 已完成 */
-  COMPLETED: 3
-}
-
-/**
- * 订单类型选项列表
- * @type {ReadonlyArray<{readonly label: string, readonly value: 1|2|3}>}
- */
-export const ORDER_TYPE_OPTIONS = [
-  { label: '普通订单', value: OrderType.NORMAL },
-  { label: '紧急订单', value: OrderType.URGENT },
-  { label: '预订订单', value: OrderType.RESERVATION }
-]
-
-/**
- * 订单状态选项列表
- * @type {ReadonlyArray<{readonly label: string, readonly value: 0|1|2|3|4|5}>}
- */
-export const ORDER_STATUS_OPTIONS = [
-  { label: '草稿', value: OrderStatus.DRAFT },
-  { label: '待审核', value: OrderStatus.PENDING },
-  { label: '已审核', value: OrderStatus.APPROVED },
-  { label: '已发货', value: OrderStatus.SHIPPED },
-  { label: '已完成', value: OrderStatus.COMPLETED },
-  { label: '已取消', value: OrderStatus.CANCELLED }
-]
-
-/**
- * 默认分页配置
- * @description 通用的AvueJS分页配置,可在多个组件中复用
- * @type {Readonly<{pageSize: 10, pageSizes: ReadonlyArray<5|10|20|50>, layout: string}>}
- */
-export const DEFAULT_PAGINATION_CONFIG = {
-  pageSize: 10,
-  pageSizes: [5, 10, 20, 50],
-  layout: 'total, sizes, prev, pager, next, jumper'
-}
-
-/**
- * 物料明细状态选项列表
- * @type {ReadonlyArray<{readonly label: string, readonly value: 0|1|2|3}>}
- */
-export const MATERIAL_DETAIL_STATUS_OPTIONS = [
-  { label: '未确认', value: MaterialDetailStatus.UNCONFIRMED },
-  { label: '已确认', value: MaterialDetailStatus.CONFIRMED },
-  { label: '部分发货', value: MaterialDetailStatus.PARTIAL_SHIPPED },
-  { label: '已完成', value: MaterialDetailStatus.COMPLETED }
-]
+// ==================== 导入常量 ====================
 
-// 导出明细状态工具函数供其他组件使用
+// 从统一的订单常量文件导入
 export {
+  // 枚举定义
+  OrderType,
+  OrderStatus,
+  MaterialDetailDataSource,
+  MaterialDetailStatus,
+  
+  // 选项列表
+  ORDER_TYPE_OPTIONS,
+  ORDER_STATUS_OPTIONS,
+  MATERIAL_DETAIL_STATUS_OPTIONS,
+  
+  // 默认配置
+  DEFAULT_PAGINATION_CONFIG,
+  
+  // 工具函数
+  getOrderTypeLabel,
+  getOrderTypeTagType,
+  getOrderTypeColor,
+  getOrderStatusLabel,
+  getOrderStatusTagType,
+  getOrderStatusColor,
   getOrderItemStatusLabel as getMaterialDetailStatusLabel,
   getOrderItemStatusTagType as getMaterialDetailStatusTagType,
   getOrderItemStatusColor as getMaterialDetailStatusColor
-}
-
-// ==================== JSDoc 类型定义 ====================
-
-/**
- * 物料明细记录
- * @typedef {Object} MaterialDetailRecord
- * @property {string} id - 记录ID
- * @property {string} itemId - 物料ID
- * @property {string} itemCode - 物料编码
- * @property {string} itemName - 物料名称
- * @property {string} specs - 规格型号
- * @property {string} unit - 单位
- * @property {number} availableQuantity - 可用数量(4位浮点型)
- * @property {number} orderQuantity - 订单数量(整数)
- * @property {number} confirmQuantity - 确认数量(整数)
- * @property {number} unitPrice - 单价(4位浮点型)
- * @property {number} taxRate - 税率百分比(4位浮点型)(%)
- * @property {number} taxAmount - 税额(2位小数)
- * @property {number} totalAmount - 总金额(2位小数)
- * @property {string} remark - 备注
- * @property {0|1|2|3} status - 明细状态(0未确认 1已确认 2部分发货 3已完成)
- * @property {keyof typeof MaterialDetailDataSource} dataSource - 数据来源 (REMOTE|IMPORTED)
- * @property {boolean} isDeletable - 是否可删除
- * @property {string} mainCategoryId - 主物料分类ID
- * @property {string} mainItemCategoryName - 主物料分类名称
- * @property {string} warehouseId - 仓库ID
- * @property {string} warehouseName - 仓库名称
- * @property {Date} createTime - 创建时间(ISO字符串)
- * @property {Date} updateTime - 更新时间(ISO字符串)
- */
-
-/**
- * 订单表单模型
- * @typedef {Object} OrderFormModel
- * @property {string} id - 订单ID
- * @property {string} orderNumber - 订单编号
- * @property {keyof typeof OrderType} orderType - 订单类型
- * @property {keyof typeof OrderStatus} status - 订单状态
- * @property {string} customerCode - 客户编码
- * @property {string} customerName - 客户名称
- * @property {string} customerContact - 客户联系人
- * @property {string} contactPhone - 联系电话
- * @property {string} deliveryAddress - 交货地址
- * @property {Date} orderDate - 订单日期
- * @property {Date} deliveryDate - 预期交货日期
- * @property {number} totalQuantity - 总数量
- * @property {number} totalAmount - 订单总金额
- * @property {string} remark - 备注
- * @property {MaterialDetailRecord[]} materialDetails - 物料明细列表
- * @property {Date} createTime - 创建时间
- * @property {Date} updateTime - 更新时间
- * @property {string} createdBy - 创建人
- * @property {string} updatedBy - 更新人
- */
-
-/**
- * 物料查询参数
- * @typedef {Object} MaterialQueryParams
- * @property {string} [itemCode] - 物料编码
- * @property {string} [itemName] - 物料名称
- * @property {string} [mainItemCategoryId] - 主物料分类ID
- * @property {string} [subItemCategoryId] - 子物料分类ID
- * @property {string} [brandId] - 品牌ID
- * @property {string} [warehouseId] - 仓库ID
- * @property {number} [pageNum] - 页码
- * @property {number} [pageSize] - 每页大小
- */
-
-/**
- * 物料删除事件数据
- * @typedef {Object} MaterialDeleteEventData
- * @property {MaterialDetailRecord} row - 要删除的物料明细记录
- * @property {number} index - 在列表中的索引
- */
-
-/**
- * 验证规则
- * @typedef {Object} ValidationRule
- * @property {boolean} required - 是否必填
- * @property {string} message - 验证失败消息
- * @property {string} [trigger] - 触发方式
- * @property {string} [type] - 验证类型
- * @property {number} [min] - 最小值
- * @property {number} [max] - 最大值
- * @property {Function} [validator] - 自定义验证函数
- */
-
-/**
- * API响应数据结构
- * @template T
- * @typedef {Object} ApiResponse
- * @property {number} code - 响应状态码
- * @property {string} message - 响应消息
- * @property {T} data - 响应数据
- * @property {boolean} success - 是否成功
- * @property {number} timestamp - 时间戳
- */
-
-/**
- * 分页响应数据结构
- * @template T
- * @typedef {Object} PaginatedResponse
- * @property {T[]} records - 数据记录列表
- * @property {number} total - 总记录数
- * @property {number} size - 每页大小
- * @property {number} current - 当前页码
- * @property {number} pages - 总页数
- * @property {boolean} hasNext - 是否有下一页
- * @property {boolean} hasPrevious - 是否有上一页
- */
-
-/**
- * 数字验证结果
- * @typedef {Object} NumberValidationResult
- * @property {boolean} isValid - 是否为有效数字
- * @property {number} value - 转换后的数字值
- * @property {string} [error] - 错误信息(验证失败时)
- */
+} from '@/constants/order'
 
-/**
- * 数字格式化配置
- * @typedef {Object} NumberFormatConfig
- * @property {number} decimalPlaces - 小数位数
- * @property {boolean} [showThousandsSeparator] - 是否显示千分位分隔符
- * @property {string} [prefix] - 前缀(如货币符号)
- * @property {string} [suffix] - 后缀(如百分号)
- */
+// ==================== 类型定义导入 ====================
 
-/**
- * 订单表单混入数据
- * @typedef {Object} OrderFormMixinData
- * @property {OrderFormModel} formData - 表单数据
- * @property {boolean} saveLoading - 保存加载状态
- * @property {MaterialDetailRecord[]} materialDetails - 物料明细列表
- */
+// 从物料常量文件导入类型定义
+import '@/constants/material'
 

+ 1 - 1
src/components/order-form/form-option.js

@@ -1,4 +1,4 @@
-import { ORDER_TYPE_OPTIONS, ORDER_STATUS_OPTIONS } from './constants'
+import { ORDER_TYPE_OPTIONS, ORDER_STATUS_OPTIONS } from '@/constants/order'
 
 /**
  * AvueJS 表单字段配置接口

+ 3 - 5
src/components/order-form/material-detail-option.js

@@ -7,11 +7,9 @@
 import {
   MaterialDetailStatus,
   DEFAULT_PAGINATION_CONFIG,
-  MATERIAL_DETAIL_STATUS_OPTIONS
-} from './constants'
-
-// 从types.js导入类型定义
-import { MaterialDetailDataSource } from './constants'
+  MATERIAL_DETAIL_STATUS_OPTIONS,
+  MaterialDetailDataSource
+} from '@/constants/order'
 
 // 重新导出常量供其他模块使用
 export { MaterialDetailStatus, DEFAULT_PAGINATION_CONFIG, MATERIAL_DETAIL_STATUS_OPTIONS }

+ 7 - 7
src/components/order-form/material-detail-table.vue

@@ -145,11 +145,11 @@
     </div>
 
     <!-- 物料导入弹窗 -->
-    <material-import-dialog
+    <MaterialImportDialog
       ref="materialImportDialog"
       :visible.sync="importDialogVisible"
       @confirm="handleImportConfirm"
-        @cancel="handleImportCancel"
+      @cancel="handleImportCancel"
     />
 
 
@@ -165,10 +165,11 @@
 import { getMaterialDetailOption, DEFAULT_PAGINATION_CONFIG } from './material-detail-option'
 import {
   MaterialDetailStatus,
-  getMaterialDetailStatusLabel,
-  getMaterialDetailStatusTagType,
-  getMaterialDetailStatusColor
-} from './constants'
+  getOrderItemStatusLabel as getMaterialDetailStatusLabel,
+  getOrderItemStatusTagType as getMaterialDetailStatusTagType,
+  getOrderItemStatusColor as getMaterialDetailStatusColor,
+  MaterialDetailDataSource
+} from '@/constants/order'
 import { MATERIAL_DETAIL_EVENTS, DIALOG_EVENTS } from './events'
 import MaterialImportDialog from './material-import-dialog.vue'
 import {
@@ -183,7 +184,6 @@ import {
   validateNumber,
   NUMBER_TYPES
 } from './number-format-utils'
-import { MaterialDetailDataSource } from './constants'
 
 /**
  * @typedef {import('./types').MaterialDetailRecord} MaterialDetailRecord

+ 1 - 1
src/components/order-form/material-import-dialog.vue

@@ -144,7 +144,7 @@
 
 <script>
 import { getMaterialImportOption, DEFAULT_QUERY_PARAMS } from './material-detail-option'
-import { MaterialDetailStatus } from './constants'
+import { MaterialDetailStatus } from '@/constants/order'
 import { getItemList } from '@/api/common'
 import { generateUniqueId } from './utils'
 import {

+ 1 - 1
src/components/order-form/order-form-mixin.js

@@ -19,7 +19,7 @@ import {
 // 本地常量定义导入
 import {
   MaterialDetailDataSource
-} from './constants'
+} from '@/constants/order'
 import { ORDER_FORM_EVENTS } from './events'
 
 // 数字格式化工具导入

+ 66 - 0
src/constants/material.js

@@ -0,0 +1,66 @@
+/**
+ * 物料相关常量定义
+ * @fileoverview 物料明细记录、查询参数等类型定义
+ */
+
+// ==================== JSDoc 类型定义 ====================
+
+/**
+ * 物料明细记录
+ * @typedef {Object} MaterialDetailRecord
+ * @property {string} id - 物料ID
+ * @property {string} materialCode - 物料编码
+ * @property {string} materialName - 物料名称
+ * @property {string} specification - 规格
+ * @property {string} unit - 单位
+ * @property {number} quantity - 数量
+ * @property {number} unitPrice - 单价
+ * @property {number} totalPrice - 总价
+ * @property {number} itemStatus - 明细状态:0未确认 1已确认 2部分发货 3已完成
+ * @property {string} dataSource - 数据来源:REMOTE远程 IMPORTED导入
+ * @property {boolean} isDeletable - 是否可删除
+ * @property {string} [remark] - 备注
+ * @property {string} [createTime] - 创建时间
+ * @property {string} [updateTime] - 更新时间
+ */
+
+/**
+ * 订单表单模型
+ * @typedef {Object} OrderFormModel
+ * @property {string} id - 订单ID
+ * @property {string} orderNo - 订单编号
+ * @property {number} orderType - 订单类型:1普通 2紧急 3预订
+ * @property {number} orderStatus - 订单状态:0草稿 1待审核 2已审核 3已发货 4已完成 5已取消
+ * @property {string} customerName - 客户名称
+ * @property {string} customerContact - 客户联系方式
+ * @property {string} deliveryAddress - 交货地址
+ * @property {string} [deliveryDate] - 交货日期
+ * @property {number} totalAmount - 订单总金额
+ * @property {string} [remark] - 备注
+ * @property {Array<MaterialDetailRecord>} materials - 物料明细列表
+ * @property {string} [createTime] - 创建时间
+ * @property {string} [updateTime] - 更新时间
+ */
+
+/**
+ * 物料查询参数
+ * @typedef {Object} MaterialQueryParams
+ * @property {string} [materialCode] - 物料编码
+ * @property {string} [materialName] - 物料名称
+ * @property {string} [specification] - 规格
+ * @property {number} [itemStatus] - 明细状态
+ * @property {string} [dataSource] - 数据来源
+ * @property {number} [current] - 当前页码
+ * @property {number} [pageSize] - 每页条数
+ */
+
+/**
+ * 物料删除事件数据
+ * @typedef {Object} MaterialDeleteEventData
+ * @property {string} id - 物料ID
+ * @property {string} materialCode - 物料编码
+ * @property {string} materialName - 物料名称
+ * @property {number} itemStatus - 明细状态
+ */
+
+export {}

+ 247 - 15
src/constants/order.js

@@ -1,31 +1,42 @@
 /**
- * 订单管理相关常量定义
- * @fileoverview 订单类型、订单状态、订单明细状态等枚举值和工具函数
+ * @fileoverview 订单管理相关常量定义和类型定义
+ * @description 定义订单类型、订单状态、订单明细状态等枚举值、常量和工具函数
  */
 
 /**
  * 订单类型枚举
  * @readonly
- * @enum {1}
+ * @enum {number}
  */
 export const ORDER_TYPES = {
   /** 普通订单 */
-  NORMAL: 1
+  NORMAL: 1,
+  /** 紧急订单 */
+  URGENT: 2,
+  /** 预订订单 */
+  RESERVATION: 3
 }
 
 /**
+ * 订单类型枚举(订单表单模块兼容性别名)
+ * @readonly
+ * @enum {number}
+ */
+export const OrderType = ORDER_TYPES
+
+/**
  * 订单状态枚举
  * @readonly
- * @enum {0 | 1 | 2 | 3 | 4 | 5}
+ * @enum {number}
  */
 export const ORDER_STATUS = {
   /** 草稿 */
   DRAFT: 0,
-  /** 已提交 */
+  /** 已提交/待审核 */
   SUBMITTED: 1,
-  /** 已确认 */
+  /** 已确认/已审核 */
   CONFIRMED: 2,
-  /** 部分发货 */
+  /** 部分发货/已发货 */
   PARTIAL_SHIPPED: 3,
   /** 已完成 */
   COMPLETED: 4,
@@ -34,9 +45,29 @@ export const ORDER_STATUS = {
 }
 
 /**
+ * 订单状态枚举(订单表单模块兼容性别名)
+ * @readonly
+ * @enum {number}
+ */
+export const OrderStatus = {
+  /** 草稿 */
+  DRAFT: ORDER_STATUS.DRAFT,
+  /** 待审核 */
+  PENDING: ORDER_STATUS.SUBMITTED,
+  /** 已审核 */
+  APPROVED: ORDER_STATUS.CONFIRMED,
+  /** 已发货 */
+  SHIPPED: ORDER_STATUS.PARTIAL_SHIPPED,
+  /** 已完成 */
+  COMPLETED: ORDER_STATUS.COMPLETED,
+  /** 已取消 */
+  CANCELLED: ORDER_STATUS.CANCELLED
+}
+
+/**
  * 订单明细状态枚举
  * @readonly
- * @enum {0 | 1 | 2 | 3}
+ * @enum {number}
  */
 export const ORDER_ITEM_STATUS = {
   /** 未确认 */
@@ -50,22 +81,52 @@ export const ORDER_ITEM_STATUS = {
 }
 
 /**
+ * 物料明细状态枚举(订单表单模块兼容性别名)
+ * @description 对应数据库item_status字段:0未确认 1已确认 2部分发货 3已完成
+ * @readonly
+ * @enum {number}
+ */
+export const MaterialDetailStatus = ORDER_ITEM_STATUS
+
+/**
+ * 物料明细数据来源枚举
+ * @readonly
+ * @enum {string}
+ */
+export const MaterialDetailDataSource = {
+  /** 远程加载的数据(从订单获取) */
+  REMOTE: 'REMOTE',
+  /** 用户导入的数据 */
+  IMPORTED: 'IMPORTED'
+}
+
+/**
  * 订单类型配置映射
  * @readonly
- * @type {Record<1, {readonly label: '普通订单', readonly type: 'primary', readonly color: '#409EFF'}>}
+ * @type {Record<number, {readonly label: string, readonly type: string, readonly color: string}>}
  */
 export const ORDER_TYPE_CONFIG = {
   [ORDER_TYPES.NORMAL]: {
     label: '普通订单',
     type: 'primary',
     color: '#409EFF'
+  },
+  [ORDER_TYPES.URGENT]: {
+    label: '紧急订单',
+    type: 'danger',
+    color: '#F56C6C'
+  },
+  [ORDER_TYPES.RESERVATION]: {
+    label: '预订订单',
+    type: 'warning',
+    color: '#E6A23C'
   }
 }
 
 /**
  * 订单状态配置映射
  * @readonly
- * @type {Record<0 | 1 | 2 | 3 | 4 | 5, {readonly label: string, readonly type: 'info' | 'warning' | 'primary' | 'success' | 'danger', readonly color: string}>}
+ * @type {Record<number, {readonly label: string, readonly type: string, readonly color: string}>}
  */
 export const ORDER_STATUS_CONFIG = {
   [ORDER_STATUS.DRAFT]: {
@@ -74,17 +135,17 @@ export const ORDER_STATUS_CONFIG = {
     color: '#909399'
   },
   [ORDER_STATUS.SUBMITTED]: {
-    label: '已提交',
+    label: '待审核',
     type: 'warning',
     color: '#E6A23C'
   },
   [ORDER_STATUS.CONFIRMED]: {
-    label: '已确认',
+    label: '已审核',
     type: 'primary',
     color: '#409EFF'
   },
   [ORDER_STATUS.PARTIAL_SHIPPED]: {
-    label: '部分发货',
+    label: '发货',
     type: 'warning',
     color: '#E6A23C'
   },
@@ -103,7 +164,7 @@ export const ORDER_STATUS_CONFIG = {
 /**
  * 订单明细状态配置映射
  * @readonly
- * @type {Record<0 | 1 | 2 | 3, {readonly label: string, readonly type: 'warning' | 'primary' | 'success', readonly color: string}>}
+ * @type {Record<number, {readonly label: string, readonly type: string, readonly color: string}>}
  */
 export const ORDER_ITEM_STATUS_CONFIG = {
   [ORDER_ITEM_STATUS.UNCONFIRMED]: {
@@ -163,6 +224,27 @@ export const ORDER_ITEM_STATUS_OPTIONS = [
   { label: '已完成', value: ORDER_ITEM_STATUS.COMPLETED }
 ]
 
+/**
+ * 物料明细状态选项列表(订单表单模块兼容性别名)
+ * @readonly
+ * @type {Array<{readonly value: number, readonly label: string}>}
+ */
+export const MATERIAL_DETAIL_STATUS_OPTIONS = ORDER_ITEM_STATUS_OPTIONS
+
+/**
+ * 默认分页配置
+ * @readonly
+ * @type {{readonly current: number, readonly pageSize: number, readonly total: number, readonly showSizeChanger: boolean, readonly showQuickJumper: boolean, readonly showTotal: (total: number, range: [number, number]) => string}}
+ */
+export const DEFAULT_PAGINATION_CONFIG = {
+  current: 1,
+  pageSize: 10,
+  total: 0,
+  showSizeChanger: true,
+  showQuickJumper: true,
+  showTotal: (total, range) => `第 ${range[0]}-${range[1]} 条/共 ${total} 条`
+}
+
 // ==================== 工具函数 ====================
 
 /**
@@ -290,3 +372,153 @@ export function isOrderItemEditable(itemStatus) {
 export function isOrderItemCancellable(itemStatus) {
   return itemStatus !== ORDER_ITEM_STATUS.COMPLETED
 }
+
+// ==================== 发票相关常量 ====================
+
+/**
+ * 发票类型枚举
+ * @readonly
+ * @enum {string}
+ */
+export const INVOICE_TYPES = {
+  /** 普通发票 */
+  NORMAL: 'NORMAL',
+  /** 专用发票 */
+  SPECIAL: 'SPECIAL'
+}
+
+/**
+ * 发票状态枚举
+ * @readonly
+ * @enum {number}
+ */
+export const INVOICE_STATUS = {
+  /** 待开票 */
+  PENDING: 0,
+  /** 已开票 */
+  INVOICED: 1,
+  /** 已红冲 */
+  RED_FLUSHED: 2,
+  /** 已作废 */
+  VOIDED: 3
+}
+
+/**
+ * 发票类型标签映射
+ * @readonly
+ * @type {Record<string, string>}
+ */
+export const INVOICE_TYPE_LABELS = {
+  [INVOICE_TYPES.NORMAL]: '普通发票',
+  [INVOICE_TYPES.SPECIAL]: '专用发票'
+}
+
+/**
+ * 发票状态标签映射
+ * @readonly
+ * @type {Record<number, string>}
+ */
+export const INVOICE_STATUS_LABELS = {
+  [INVOICE_STATUS.PENDING]: '待开票',
+  [INVOICE_STATUS.INVOICED]: '已开票',
+  [INVOICE_STATUS.RED_FLUSHED]: '已红冲',
+  [INVOICE_STATUS.VOIDED]: '已作废'
+}
+
+/**
+ * 发票类型标签类型映射(用于Element UI标签样式)
+ * @readonly
+ * @type {Record<string, string>}
+ */
+export const INVOICE_TYPE_TAG_TYPES = {
+  [INVOICE_TYPES.NORMAL]: 'info',
+  [INVOICE_TYPES.SPECIAL]: 'success'
+}
+
+/**
+ * 发票状态标签类型映射(用于Element UI标签样式)
+ * @readonly
+ * @type {Record<number, string>}
+ */
+export const INVOICE_STATUS_TAG_TYPES = {
+  [INVOICE_STATUS.PENDING]: 'warning',
+  [INVOICE_STATUS.INVOICED]: 'success',
+  [INVOICE_STATUS.RED_FLUSHED]: 'danger',
+  [INVOICE_STATUS.VOIDED]: 'info'
+}
+
+/**
+ * 发票类型选项数组(用于下拉选择)
+ * @readonly
+ * @type {Array<{label: string, value: string}>}
+ */
+export const INVOICE_TYPE_OPTIONS = [
+  { label: INVOICE_TYPE_LABELS[INVOICE_TYPES.NORMAL], value: INVOICE_TYPES.NORMAL },
+  { label: INVOICE_TYPE_LABELS[INVOICE_TYPES.SPECIAL], value: INVOICE_TYPES.SPECIAL }
+]
+
+/**
+ * 发票状态选项数组(用于下拉选择)
+ * @readonly
+ * @type {Array<{label: string, value: number}>}
+ */
+export const INVOICE_STATUS_OPTIONS = [
+  { label: INVOICE_STATUS_LABELS[INVOICE_STATUS.PENDING], value: INVOICE_STATUS.PENDING },
+  { label: INVOICE_STATUS_LABELS[INVOICE_STATUS.INVOICED], value: INVOICE_STATUS.INVOICED },
+  { label: INVOICE_STATUS_LABELS[INVOICE_STATUS.RED_FLUSHED], value: INVOICE_STATUS.RED_FLUSHED },
+  { label: INVOICE_STATUS_LABELS[INVOICE_STATUS.VOIDED], value: INVOICE_STATUS.VOIDED }
+]
+
+/**
+ * 获取发票类型标签文本
+ * @param {string} type - 发票类型
+ * @returns {string} 标签文本
+ */
+export const getInvoiceTypeLabel = (type) => {
+  return INVOICE_TYPE_LABELS[type] || '未知类型'
+}
+
+/**
+ * 获取发票类型标签样式
+ * @param {string} type - 发票类型
+ * @returns {string} 标签样式类型
+ */
+export const getInvoiceTypeTagType = (type) => {
+  return INVOICE_TYPE_TAG_TYPES[type] || 'info'
+}
+
+/**
+ * 获取发票状态标签文本
+ * @param {number} status - 发票状态
+ * @returns {string} 标签文本
+ */
+export const getInvoiceStatusLabel = (status) => {
+  return INVOICE_STATUS_LABELS[status] || '未知状态'
+}
+
+/**
+ * 获取发票状态标签样式
+ * @param {number} status - 发票状态
+ * @returns {string} 标签样式类型
+ */
+export const getInvoiceStatusTagType = (status) => {
+  return INVOICE_STATUS_TAG_TYPES[status] || 'info'
+}
+
+/**
+ * 验证发票类型是否有效
+ * @param {string} type - 发票类型
+ * @returns {boolean} 是否有效
+ */
+export const isValidInvoiceType = (type) => {
+  return Object.values(INVOICE_TYPES).includes(type)
+}
+
+/**
+ * 验证发票状态是否有效
+ * @param {number} status - 发票状态
+ * @returns {boolean} 是否有效
+ */
+export const isValidInvoiceStatus = (status) => {
+  return Object.values(INVOICE_STATUS).includes(status)
+}

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

@@ -9,7 +9,7 @@ import {
   getInvoiceTypeTagType,
   getInvoiceStatusLabel,
   getInvoiceStatusTagType
-} from '@/views/order/invoice/constants'
+} from '@/constants'
 
 /**
  * 发票查询参数类型定义

+ 0 - 147
src/views/order/invoice/constants.js

@@ -1,147 +0,0 @@
-/**
- * 发票类型枚举
- * @readonly
- * @enum {string}
- */
-export const INVOICE_TYPES = {
-  /** 普通发票 */
-  NORMAL: 'NORMAL',
-  /** 专用发票 */
-  SPECIAL: 'SPECIAL'
-}
-
-/**
- * 发票状态枚举
- * @readonly
- * @enum {number}
- */
-export const INVOICE_STATUS = {
-  /** 待开票 */
-  PENDING: 0,
-  /** 已开票 */
-  INVOICED: 1,
-  /** 已红冲 */
-  RED_FLUSHED: 2,
-  /** 已作废 */
-  VOIDED: 3
-}
-
-/**
- * 发票类型标签映射
- * @readonly
- * @type {Record<string, string>}
- */
-export const INVOICE_TYPE_LABELS = {
-  [INVOICE_TYPES.NORMAL]: '普通发票',
-  [INVOICE_TYPES.SPECIAL]: '专用发票'
-}
-
-/**
- * 发票状态标签映射
- * @readonly
- * @type {Record<number, string>}
- */
-export const INVOICE_STATUS_LABELS = {
-  [INVOICE_STATUS.PENDING]: '待开票',
-  [INVOICE_STATUS.INVOICED]: '已开票',
-  [INVOICE_STATUS.RED_FLUSHED]: '已红冲',
-  [INVOICE_STATUS.VOIDED]: '已作废'
-}
-
-/**
- * 发票类型标签类型映射(用于Element UI标签样式)
- * @readonly
- * @type {Record<string, string>}
- */
-export const INVOICE_TYPE_TAG_TYPES = {
-  [INVOICE_TYPES.NORMAL]: 'info',
-  [INVOICE_TYPES.SPECIAL]: 'success'
-}
-
-/**
- * 发票状态标签类型映射(用于Element UI标签样式)
- * @readonly
- * @type {Record<number, string>}
- */
-export const INVOICE_STATUS_TAG_TYPES = {
-  [INVOICE_STATUS.PENDING]: 'warning',
-  [INVOICE_STATUS.INVOICED]: 'success',
-  [INVOICE_STATUS.RED_FLUSHED]: 'danger',
-  [INVOICE_STATUS.VOIDED]: 'info'
-}
-
-/**
- * 发票类型选项数组(用于下拉选择)
- * @readonly
- * @type {Array<{label: string, value: string}>}
- */
-export const INVOICE_TYPE_OPTIONS = [
-  { label: INVOICE_TYPE_LABELS[INVOICE_TYPES.NORMAL], value: INVOICE_TYPES.NORMAL },
-  { label: INVOICE_TYPE_LABELS[INVOICE_TYPES.SPECIAL], value: INVOICE_TYPES.SPECIAL }
-]
-
-/**
- * 发票状态选项数组(用于下拉选择)
- * @readonly
- * @type {Array<{label: string, value: number}>}
- */
-export const INVOICE_STATUS_OPTIONS = [
-  { label: INVOICE_STATUS_LABELS[INVOICE_STATUS.PENDING], value: INVOICE_STATUS.PENDING },
-  { label: INVOICE_STATUS_LABELS[INVOICE_STATUS.INVOICED], value: INVOICE_STATUS.INVOICED },
-  { label: INVOICE_STATUS_LABELS[INVOICE_STATUS.RED_FLUSHED], value: INVOICE_STATUS.RED_FLUSHED },
-  { label: INVOICE_STATUS_LABELS[INVOICE_STATUS.VOIDED], value: INVOICE_STATUS.VOIDED }
-]
-
-/**
- * 获取发票类型标签文本
- * @param {string} type - 发票类型
- * @returns {string} 标签文本
- */
-export const getInvoiceTypeLabel = (type) => {
-  return INVOICE_TYPE_LABELS[type] || '未知类型'
-}
-
-/**
- * 获取发票类型标签样式
- * @param {string} type - 发票类型
- * @returns {string} 标签样式类型
- */
-export const getInvoiceTypeTagType = (type) => {
-  return INVOICE_TYPE_TAG_TYPES[type] || 'info'
-}
-
-/**
- * 获取发票状态标签文本
- * @param {number} status - 发票状态
- * @returns {string} 标签文本
- */
-export const getInvoiceStatusLabel = (status) => {
-  return INVOICE_STATUS_LABELS[status] || '未知状态'
-}
-
-/**
- * 获取发票状态标签样式
- * @param {number} status - 发票状态
- * @returns {string} 标签样式类型
- */
-export const getInvoiceStatusTagType = (status) => {
-  return INVOICE_STATUS_TAG_TYPES[status] || 'info'
-}
-
-/**
- * 验证发票类型是否有效
- * @param {string} type - 发票类型
- * @returns {boolean} 是否有效
- */
-export const isValidInvoiceType = (type) => {
-  return Object.values(INVOICE_TYPES).includes(type)
-}
-
-/**
- * 验证发票状态是否有效
- * @param {number} status - 发票状态
- * @returns {boolean} 是否有效
- */
-export const isValidInvoiceStatus = (status) => {
-  return Object.values(INVOICE_STATUS).includes(status)
-}

+ 3 - 3
src/views/order/order/constants.js

@@ -1,6 +1,6 @@
 // 导入统一的订单常量定义
 import {
-  ORDER_TYPE,
+  ORDER_TYPES,
   ORDER_STATUS,
   ORDER_TYPE_CONFIG,
   ORDER_STATUS_CONFIG,
@@ -16,9 +16,9 @@ import {
  * 订单类型枚举(兼容性别名)
  * @readonly
  * @enum {number}
- * @deprecated 请使用 @/constants 中的 ORDER_TYPE
+ * @deprecated 请使用 @/constants 中的 ORDER_TYPES
  */
-export const ORDER_TYPES = ORDER_TYPE
+export { ORDER_TYPES }
 
 /**
  * 订单状态枚举(兼容性别名)