浏览代码

Merge remote-tracking branch 'origin/dev' into dev

# Conflicts:
#	src/views/forecast/forecastIndex.js
yz 2 周之前
父节点
当前提交
4b26e3a40b
共有 4 个文件被更改,包括 127 次插入73 次删除
  1. 106 0
      src/api/types/forecast.d.ts
  2. 19 71
      src/constants/forecast.js
  3. 1 1
      src/views/forecast-summary/summaryIndex.js
  4. 1 1
      src/views/forecast/forecastIndex.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[]>;

+ 19 - 71
src/constants/forecast.js

@@ -18,10 +18,9 @@ export const APPROVAL_STATUS = Object.freeze({
 
 /**
  * 审批状态配置映射
- * @readonly
- * @type {Record<number, {label: string, type: string, color: string}>}
+ * @enum {Record<typeof APPROVAL_STATUS[keyof typeof APPROVAL_STATUS], {label: string, type: string, color: string}>}
  */
-export const APPROVAL_STATUS_CONFIG = {
+export const APPROVAL_STATUS_CONFIG = Object.freeze({
   [APPROVAL_STATUS.PENDING]: {
     label: '未审批',
     type: 'warning',
@@ -37,7 +36,7 @@ export const APPROVAL_STATUS_CONFIG = {
     type: 'danger',
     color: '#F56C6C'
   }
-}
+})
 
 /**
  * 审批状态选项数组
@@ -52,7 +51,7 @@ export const APPROVAL_STATUS_OPTIONS = [
 
 /**
  * 获取审批状态标签
- * @param {number} status - 审批状态值
+ * @param {typeof APPROVAL_STATUS[keyof typeof APPROVAL_STATUS]} status - 审批状态值
  * @returns {string} 状态标签文本
  */
 export function getApprovalStatusLabel(status) {
@@ -61,7 +60,7 @@ export function getApprovalStatusLabel(status) {
 
 /**
  * 获取审批状态类型
- * @param {number} status - 审批状态值
+ * @param {typeof APPROVAL_STATUS[keyof typeof APPROVAL_STATUS]} status - 审批状态值
  * @returns {string} 状态类型
  */
 export function getApprovalStatusType(status) {
@@ -70,7 +69,7 @@ export function getApprovalStatusType(status) {
 
 /**
  * 获取审批状态颜色
- * @param {number} status - 审批状态值
+ * @param {typeof APPROVAL_STATUS[keyof typeof APPROVAL_STATUS]} status - 审批状态值
  * @returns {string} 状态颜色
  */
 export function getApprovalStatusColor(status) {
@@ -79,7 +78,7 @@ export function getApprovalStatusColor(status) {
 
 /**
  * 验证审批状态是否有效
- * @param {number} status - 审批状态值
+ * @param {typeof APPROVAL_STATUS[keyof typeof APPROVAL_STATUS]} status - 审批状态值
  * @returns {boolean} 是否为有效状态
  */
 export function isValidApprovalStatus(status) {
@@ -88,7 +87,7 @@ export function isValidApprovalStatus(status) {
 
 /**
  * 判断是否可以编辑
- * @param {number} approvalStatus - 审批状态
+ * @param {typeof APPROVAL_STATUS[keyof typeof APPROVAL_STATUS]} approvalStatus - 审批状态
  * @returns {boolean} 是否可以编辑
  */
 export function canEdit(approvalStatus) {
@@ -97,7 +96,7 @@ export function canEdit(approvalStatus) {
 
 /**
  * 判断是否可以审批
- * @param {number} approvalStatus - 审批状态
+ * @param {typeof APPROVAL_STATUS[keyof typeof APPROVAL_STATUS]} approvalStatus - 审批状态
  * @returns {boolean} 是否可以审批
  */
 export function canApprove(approvalStatus) {
@@ -106,7 +105,7 @@ export function canApprove(approvalStatus) {
 
 /**
  * 判断是否可以拒绝
- * @param {number} approvalStatus - 审批状态
+ * @param {typeof APPROVAL_STATUS[keyof typeof APPROVAL_STATUS]} approvalStatus - 审批状态
  * @returns {boolean} 是否可以拒绝
  */
 export function canReject(approvalStatus) {
@@ -115,7 +114,7 @@ export function canReject(approvalStatus) {
 
 /**
  * 判断是否已审批完成
- * @param {number} approvalStatus - 审批状态
+ * @param {typeof APPROVAL_STATUS[keyof typeof APPROVAL_STATUS]} approvalStatus - 审批状态
  * @returns {boolean} 是否已审批完成
  */
 export function isApprovalCompleted(approvalStatus) {
@@ -124,7 +123,7 @@ export function isApprovalCompleted(approvalStatus) {
 
 /**
  * 判断是否审批通过
- * @param {number} approvalStatus - 审批状态
+ * @param {typeof APPROVAL_STATUS[keyof typeof APPROVAL_STATUS]} approvalStatus - 审批状态
  * @returns {boolean} 是否审批通过
  */
 export function isApproved(approvalStatus) {
@@ -133,7 +132,7 @@ export function isApproved(approvalStatus) {
 
 /**
  * 判断是否审批拒绝
- * @param {number} approvalStatus - 审批状态
+ * @param {typeof APPROVAL_STATUS[keyof typeof APPROVAL_STATUS]} approvalStatus - 审批状态
  * @returns {boolean} 是否审批拒绝
  */
 export function isRejected(approvalStatus) {
@@ -142,7 +141,7 @@ export function isRejected(approvalStatus) {
 
 /**
  * 获取所有审批状态值
- * @returns {Array<number>} 所有审批状态值数组
+ * @returns {(typeof APPROVAL_STATUS[keyof typeof APPROVAL_STATUS])[]} 所有审批状态值数组
  */
 export function getAllApprovalStatusValues() {
   return Object.values(APPROVAL_STATUS)
@@ -165,7 +164,7 @@ export const AUDIT_ACTION_TYPE = {
 /**
  * 审核操作配置映射
  * @readonly
- * @type {Record<string, {label: string, type: string, icon: string}>}
+ * @type {Record<(typeof AUDIT_ACTION_TYPE[keyof typeof AUDIT_ACTION_TYPE]), {label: string, type: string, icon: string}>}
  */
 export const AUDIT_ACTION_CONFIG = {
   [AUDIT_ACTION_TYPE.APPROVE]: {
@@ -187,8 +186,8 @@ export const AUDIT_ACTION_CONFIG = {
 
 /**
  * 获取可执行的审核操作
- * @param {number} approvalStatus - 审批状态
- * @returns {Array<string>} 可执行的操作类型数组
+ * @param {typeof APPROVAL_STATUS[keyof typeof APPROVAL_STATUS]} approvalStatus - 审批状态
+ * @returns {(typeof AUDIT_ACTION_TYPE[keyof typeof AUDIT_ACTION_TYPE])[]} 可执行的操作类型数组
  */
 export function getAvailableAuditActions(approvalStatus) {
   const actions = [AUDIT_ACTION_TYPE.VIEW]
@@ -326,7 +325,7 @@ export const NUMBER_FORMAT_OPTIONS = {
 /**
  * 格式化数字显示
  * @param {number|null|undefined} value - 数值
- * @param {Object} options - 格式化选项
+ * @param {typeof NUMBER_FORMAT_OPTIONS[keyof typeof NUMBER_FORMAT_OPTIONS]} options - 格式化选项
  * @returns {string} 格式化后的字符串
  */
 export function formatNumber(value, options = NUMBER_FORMAT_OPTIONS.quantity) {
@@ -356,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 {number} [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 {number} 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,
@@ -431,7 +381,6 @@ export const DEFAULT_FORECAST_SUMMARY_QUERY = {
 /**
  * 月份选项数组
  * @readonly
- * @type {Array<{label: string, value: number}>}
  */
 export const MONTH_OPTIONS = [
   { label: '1月', value: 1 },
@@ -543,7 +492,6 @@ export const FORECAST_SUMMARY_FORM_RULES = {
 /**
  * 销售预测汇总默认表单数据
  * @readonly
- * @type {Object}
  */
 export const DEFAULT_FORECAST_SUMMARY_FORM = {
   id: null,

+ 1 - 1
src/views/forecast-summary/summaryIndex.js

@@ -37,7 +37,7 @@ export default {
 
       /**
        * 查询参数
-       * @type {Object}
+       * @type {typeof DEFAULT_FORECAST_SUMMARY_QUERY}
        */
       query: { ...DEFAULT_FORECAST_SUMMARY_QUERY },
 

+ 1 - 1
src/views/forecast/forecastIndex.js

@@ -223,7 +223,7 @@ export default {
           }
         ]
       },
-      /** @type {Object} 表单验证规则 */
+      /** @type {typeof FORECAST_FORM_RULES} 表单验证规则 */
       formRules: FORECAST_FORM_RULES
     }
   },