Explorar el Código

refactor(claim): 使用常量替换审核结果的硬编码值

yz hace 6 días
padre
commit
dc7a22208b
Se han modificado 3 ficheros con 20 adiciones y 17 borrados
  1. 9 13
      src/views/claim/claimMixin.js
  2. 9 2
      src/views/claim/index.vue
  3. 2 2
      src/views/claim/types.d.ts

+ 9 - 13
src/views/claim/claimMixin.js

@@ -9,12 +9,9 @@
  * @typedef {import('@/api/claim/index').ClaimQueryParams} ClaimQueryParams - 理赔查询参数
  * @typedef {import('@/api/claim/index').ClaimAuditItem} ClaimAuditItem - 审核记录数据项
  * @typedef {import('@/api/claim/index').ClaimAttachmentItem} ClaimAttachmentItem - 附件信息
- * @typedef {import('@/api/claim/index').ApiResponse} ApiResponse - API响应数据
- * @typedef {import('@/api/claim/index').PageResult} PageResult - 分页结果
  */
 
 /**
- * @typedef {import('@/constants/claim').AUDIT_STATUS} AUDIT_STATUS - 审核状态枚举
  * @typedef {import('@/constants/claim').CLAIM_SOURCE_TYPE} CLAIM_SOURCE_TYPE - 理赔来源类型枚举
  * @typedef {import('@/constants/claim').ATTACHMENT_FILE_TYPE} ATTACHMENT_FILE_TYPE - 附件文件类型枚举
  */
@@ -33,7 +30,7 @@
  * @property {string|null} id - 审核记录ID(编辑时必需)
  * @property {number|null} claimId - 理赔ID
  * @property {string} claimNo - 理赔编号
- * @property {number|null} auditResult - 审核结果 1-通过 2-拒绝
+ * @property {number|null} auditResult - 审核结果,使用 AUDIT_STATUS.APPROVED / AUDIT_STATUS.REJECTED
  * @property {number} auditAmount - 审核金额
  * @property {string} reasonDetail - 审核说明
  * @property {number|null} auditorId - 审核人ID
@@ -77,7 +74,8 @@ import {
   getClaimSourceTypeLabel,
   getClaimSourceTypeType,
   isValidAuditStatus,
-  isValidClaimSourceType
+  isValidClaimSourceType,
+  AUDIT_STATUS
 } from '@/constants/claim'
 
 export default {
@@ -648,14 +646,13 @@ export default {
 
     /**
      * 获取审核结果类型
-     * @this {Vue & import('./types').ClaimComponent}
-     * @param {number} result - 审核结果 1-通过 2-拒绝
+     * @param {number} result - 审核结果,使用 AUDIT_STATUS
      * @returns {string} 结果类型 'success' | 'danger' | 'info'
      */
     getAuditResultType(result) {
       const typeMap = {
-        1: 'success',
-        2: 'danger'
+        [AUDIT_STATUS.APPROVED]: 'success',
+        [AUDIT_STATUS.REJECTED]: 'danger'
       }
       return typeMap[result] || 'info'
     },
@@ -695,14 +692,13 @@ export default {
 
     /**
      * 获取审核结果文本
-     * @this {Vue & import('./types').ClaimComponent}
-     * @param {number} result - 审核结果 1-通过 2-拒绝
+     * @param {number} result - 审核结果,使用 AUDIT_STATUS
      * @returns {string} 结果文本 '通过' | '拒绝' | '未知'
      */
     getAuditResultText(result) {
       const textMap = {
-        1: '通过',
-        2: '拒绝'
+        [AUDIT_STATUS.APPROVED]: '通过',
+        [AUDIT_STATUS.REJECTED]: '拒绝'
       }
       return textMap[result] || '未知'
     }

+ 9 - 2
src/views/claim/index.vue

@@ -343,8 +343,8 @@
       <el-form :model="auditForm" :rules="auditFormRules" ref="auditFormRef" label-width="120px">
         <el-form-item label="审核结果" prop="auditResult">
           <el-select v-model="auditForm.auditResult" placeholder="请选择审核结果" style="width: 100%;">
-            <el-option label="通过" :value="1"></el-option>
-            <el-option label="拒绝" :value="2"></el-option>
+            <el-option :label="AUDIT_STATUS_OPTIONS.find(o => o.value === AUDIT_STATUS.APPROVED)?.label || '通过'" :value="AUDIT_STATUS.APPROVED" />
+            <el-option :label="AUDIT_STATUS_OPTIONS.find(o => o.value === AUDIT_STATUS.REJECTED)?.label || '拒绝'" :value="AUDIT_STATUS.REJECTED" />
           </el-select>
         </el-form-item>
         <el-form-item label="审核金额" prop="auditAmount">
@@ -396,10 +396,17 @@
 
 <script>
 import claimMixin from './claimMixin';
+import { AUDIT_STATUS, AUDIT_STATUS_OPTIONS } from '@/constants/claim';
 
 export default {
   name: 'Claim',
   mixins: [claimMixin],
+  data() {
+    return {
+      AUDIT_STATUS,
+      AUDIT_STATUS_OPTIONS
+    };
+  }
 }
 </script>
 

+ 2 - 2
src/views/claim/types.d.ts

@@ -50,7 +50,7 @@ export interface ClaimAuditItem {
   id?: string; // 审核记录ID(编辑时必需)
   claimId: number; // 理赔ID
   claimNo: string; // 理赔编号
-  auditResult: number; // 审核结果 1-通过 2-拒绝
+  auditResult: number; // 审核结果,使用 AUDIT_STATUS.APPROVED / AUDIT_STATUS.REJECTED
   auditAmount: number; // 审核金额
   reasonDetail: string; // 审核说明
   auditorId: number; // 审核人ID
@@ -206,7 +206,7 @@ export interface AuditFormData {
   id: string | null;
   claimId: number | string | null;
   claimNo: string;
-  auditResult: number | null; // 1-通过 2-拒绝
+  auditResult: number | null; // 审核结果,使用 AUDIT_STATUS.APPROVED / AUDIT_STATUS.REJECTED
   auditAmount: number;
   reasonDetail: string;
   auditorId: number | null;