Ver Fonte

refactor(类型定义): 优化类型注释使用typeof引用常量类型

yz há 2 semanas atrás
pai
commit
2ba8eb5737

+ 3 - 3
src/constants/forecast.js

@@ -164,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,7 +187,7 @@ export const AUDIT_ACTION_CONFIG = {
 /**
  * 获取可执行的审核操作
  * @param {typeof APPROVAL_STATUS[keyof typeof APPROVAL_STATUS]} approvalStatus - 审批状态
- * @returns {Array<string>} 可执行的操作类型数组
+ * @returns {(typeof AUDIT_ACTION_TYPE[keyof typeof AUDIT_ACTION_TYPE])[]} 可执行的操作类型数组
  */
 export function getAvailableAuditActions(approvalStatus) {
   const actions = [AUDIT_ACTION_TYPE.VIEW]
@@ -325,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) {

+ 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 },
 

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

@@ -214,7 +214,7 @@ export default {
           }
         ]
       },
-      /** @type {Object} 表单验证规则 */
+      /** @type {typeof FORECAST_FORM_RULES} 表单验证规则 */
       formRules: FORECAST_FORM_RULES
     }
   },
@@ -523,7 +523,7 @@ export default {
       }
 
       this.isEdit = true
-      this.form = { 
+      this.form = {
         ...row,
         // 确保年份字段为字符串类型,以匹配el-date-picker的value-format="yyyy"
         year: row.year ? row.year.toString() : new Date().getFullYear().toString(),