Pārlūkot izejas kodu

refactor(types): 将销售预测类型定义迁移到类型声明文件

yz 1 mēnesi atpakaļ
vecāks
revīzija
e600985c5e
2 mainītis faili ar 107 papildinājumiem un 52 dzēšanām
  1. 106 0
      src/api/types/forecast.d.ts
  2. 1 52
      src/constants/forecast.js

+ 106 - 0
src/api/types/forecast.d.ts

@@ -320,3 +320,109 @@ export type ForecastBatchOperationResponse = AxiosResponse<ApiResponse<boolean>>
  * 销售预测汇总批量操作响应接口
  */
 export type ForecastSummaryBatchOperationResponse = AxiosResponse<ApiResponse<boolean>>;
+
+/**
+ * 下拉选择器选项接口
+ */
+export interface SelectOption<T = any> {
+  /** 显示标签 */
+  label: string;
+  /** 选项值 */
+  value: T;
+  /** 是否禁用 */
+  disabled?: boolean;
+  /** 选项描述 */
+  description?: string;
+}
+
+/**
+ * 月份选项类型
+ */
+export type MonthOption = SelectOption<number>;
+
+/**
+ * 销售预测汇总数据项接口
+ * @description 对应数据库中的销售预测汇总记录结构
+ */
+export interface ForecastSummaryItem extends BaseEntity {
+  /** 年份 */
+  year: number;
+  /** 月份 */
+  month: number;
+  /** 客户ID */
+  customerId: number;
+  /** 客户编码 */
+  customerCode: string;
+  /** 客户名称 */
+  customerName: string;
+  /** 品牌ID */
+  brandId: number;
+  /** 品牌编码 */
+  brandCode: string;
+  /** 品牌名称 */
+  brandName: string;
+  /** 物料ID */
+  itemId: number;
+  /** 物料编码 */
+  itemCode: string;
+  /** 物料名称 */
+  itemName: string;
+  /** 规格 */
+  specs: string;
+  /** 花纹 */
+  pattern: string;
+  /** 预测数量 */
+  forecastQuantity: string;
+  /** 审批状态 */
+  approvalStatus: ApprovalStatus;
+  /** 审批人ID */
+  approvedBy?: number;
+  /** 审批人姓名 */
+  approvedName?: string;
+  /** 审批时间 */
+  approvedTime?: string;
+  /** 状态 */
+  status: number;
+  /** 是否删除 */
+  isDeleted: number;
+}
+
+/**
+ * 销售预测工具函数类型定义
+ * @description 为销售预测相关的工具函数提供类型支持
+ */
+export interface ForecastUtilityFunctions {
+  /** 获取月份标签 */
+  getMonthLabel: (month: number) => string;
+  /** 格式化日期时间显示 */
+  formatDateTime: (dateTime: string | null | undefined) => string;
+  /** 格式化年月显示 */
+  formatYearMonth: (year: number, month: number) => string;
+  /** 判断是否为只读模式 */
+  isReadOnlyMode: () => boolean;
+}
+
+/**
+ * 销售预测表单验证规则类型
+ */
+export interface ValidationRule {
+  /** 是否必填 */
+  required?: boolean;
+  /** 验证失败提示信息 */
+  message?: string;
+  /** 触发验证的事件类型 */
+  trigger?: 'blur' | 'change' | 'submit';
+  /** 数据类型 */
+  type?: 'string' | 'number' | 'boolean' | 'array' | 'object' | 'date';
+  /** 最小值(数字类型) */
+  min?: number;
+  /** 最大值(数字类型) */
+  max?: number;
+  /** 自定义验证函数 */
+  validator?: (rule: ValidationRule, value: any, callback: (error?: Error) => void) => void;
+}
+
+/**
+ * 销售预测表单验证规则集合类型
+ */
+export type ForecastFormRules = Record<string, ValidationRule[]>;

+ 1 - 52
src/constants/forecast.js

@@ -355,60 +355,11 @@ export function formatCurrency(value) {
 
 // ==================== 汇总模块相关常量 ====================
 
-/**
- * 预测汇总查询参数类型定义
- * @typedef {Object} ForecastSummaryQueryParams
- * @property {number} [current=1] - 当前页码
- * @property {number} [size=10] - 每页数量
- * @property {number} [year] - 年份
- * @property {number} [month] - 月份
- * @property {number} [customerId] - 客户ID
- * @property {string} [customerCode] - 客户编码
- * @property {string} [customerName] - 客户名称
- * @property {number} [brandId] - 品牌ID
- * @property {string} [brandCode] - 品牌编码
- * @property {string} [brandName] - 品牌名称
- * @property {number} [itemId] - 物料ID
- * @property {string} [itemCode] - 物料编码
- * @property {string} [itemName] - 物料名称
- * @property {typeof APPROVAL_STATUS[keyof typeof APPROVAL_STATUS]} [approvalStatus] - 审批状态
- */
-
-/**
- * 预测汇总数据项类型定义
- * @typedef {Object} ForecastSummaryItem
- * @property {string} id - 汇总记录ID
- * @property {string} createUser - 创建用户ID
- * @property {string} createDept - 创建部门ID
- * @property {string} createTime - 创建时间
- * @property {string} updateUser - 更新用户ID
- * @property {string} updateTime - 更新时间
- * @property {number} status - 状态
- * @property {number} isDeleted - 是否删除
- * @property {number} year - 年份
- * @property {number} month - 月份
- * @property {number} customerId - 客户ID
- * @property {string} customerCode - 客户编码
- * @property {string} customerName - 客户名称
- * @property {number} brandId - 品牌ID
- * @property {string} brandCode - 品牌编码
- * @property {string} brandName - 品牌名称
- * @property {number} itemId - 物料ID
- * @property {string} itemCode - 物料编码
- * @property {string} itemName - 物料名称
- * @property {string} specs - 规格
- * @property {string} pattern - 花纹
- * @property {string} forecastQuantity - 预测数量
- * @property {typeof APPROVAL_STATUS[keyof typeof APPROVAL_STATUS]} approvalStatus - 审批状态 0未审批 1已通过 2已拒绝
- * @property {number|null} approvedBy - 审批人ID
- * @property {string|null} approvedName - 审批人姓名
- * @property {string|null} approvedTime - 审批时间
- */
+// 类型定义已迁移到 @/api/types/forecast.d.ts
 
 /**
  * 预测汇总默认查询参数
  * @readonly
- * @type {ForecastSummaryQueryParams}
  */
 export const DEFAULT_FORECAST_SUMMARY_QUERY = {
   current: 1,
@@ -430,7 +381,6 @@ export const DEFAULT_FORECAST_SUMMARY_QUERY = {
 /**
  * 月份选项数组
  * @readonly
- * @type {Array<{label: string, value: number}>}
  */
 export const MONTH_OPTIONS = [
   { label: '1月', value: 1 },
@@ -542,7 +492,6 @@ export const FORECAST_SUMMARY_FORM_RULES = {
 /**
  * 销售预测汇总默认表单数据
  * @readonly
- * @type {Object}
  */
 export const DEFAULT_FORECAST_SUMMARY_FORM = {
   id: null,