Browse Source

refactor(claim): 优化理赔模块代码结构和接口适配

yz 3 weeks ago
parent
commit
d5d07146f4

+ 8 - 1
src/utils/content-disposition.js

@@ -20,7 +20,14 @@ export const getFilenameFromContentDisposition = (contentDisposition, fallbackFi
     const plusFixed = raw.includes('+') ? raw.replace(/\+/g, '%20') : raw
 
     try {
-      return decodeURIComponent(plusFixed)
+      // 部分服务端可能会重复 encode(例如 %25E7%2589...),这里最多解码 3 次
+      let decoded = plusFixed
+      for (let i = 0; i < 3; i += 1) {
+        const next = decodeURIComponent(decoded)
+        if (next === decoded) break
+        decoded = next
+      }
+      return decoded
     } catch (e) {
       // 可能包含非法 % 序列,回退原值
       return raw

+ 44 - 12
src/views/claim/claimMixin.js

@@ -5,8 +5,8 @@
  */
 
 /**
- * @typedef {import('@/api/claim/index').ClaimItem} ClaimItem - 理赔申请数据项
- * @typedef {import('@/api/claim/index').ClaimQueryParams} ClaimQueryParams - 理赔查询参数
+ * @typedef {import('@/api/types/claim-search').ClaimMainRecord} ClaimItem - 理赔申请数据项(综合查询主表)
+ * @typedef {import('@/api/types/claim-search').ClaimSearchComprehensiveParams} ClaimQueryParams - 理赔查询参数(以综合查询接口为准)
  * @typedef {import('@/api/claim/index').ClaimAuditItem} ClaimAuditItem - 审核记录数据项
  * @typedef {import('@/api/claim/index').ClaimAttachmentItem} ClaimAttachmentItem - 附件信息
  */
@@ -63,7 +63,8 @@
  * @property {Array<Object>} column - 列配置
  */
 
-import { getClaimList, getClaimDetail, getClaimAttachments, getClaimAuditList, addClaimAudit, updateClaimAudit, removeClaimAudit } from '@/api/claim/index'
+import { getClaimSearchComprehensive } from '@/api/claimSearch'
+import { getClaimDetail, getClaimAttachments, getClaimAuditList, addClaimAudit, updateClaimAudit, removeClaimAudit } from '@/api/claim/index'
 import { formatFileSize } from '@/util/util'
 import { mapGetters } from 'vuex'
 import {
@@ -208,12 +209,12 @@ export default {
           {
             label: '来源方名称',
             prop: 'sourceName',
-            search: true
+            search: false
           },
           {
             label: '来源编码',
             prop: 'sourceCode',
-            search: true
+            search: false
           },
           {
             label: '联系人',
@@ -232,11 +233,17 @@ export default {
           },
           {
             label: '规格型号',
-            prop: 'tyreSpecs'
+            prop: 'tyreSpecs',
+            search: true
           },
           {
             label: '购买日期',
             prop: 'purchaseDate',
+            type: 'datetime',
+            format: 'yyyy-MM-dd HH:mm:ss',
+            valueFormat: 'yyyy-MM-dd HH:mm:ss',
+            search: true,
+            searchRange: true,
             formatter: function(row, value) {
               if (!value || typeof value !== 'string') return value || ''
               return value.substring(0, 10)
@@ -252,12 +259,13 @@ export default {
           },
           {
             label: '行驶里程(km)',
-            prop: 'runMileage'
+            prop: 'runMileage',
+            type: 'number'
           },
           {
             label: '车牌号',
             prop: 'vehicleNumber',
-            search: true
+            search: false
           },
           {
             label: '轮胎数量',
@@ -328,10 +336,29 @@ export default {
     async onLoad(page, params = {}) {
       try {
         this.loading = true
-        const res = await getClaimList(page.currentPage, page.pageSize, Object.assign(params, this.query))
-        const data = res.data.data
-        this.page.total = data.total
-        this.data = data.records
+        const mergedQuery = Object.assign({}, this.query, params)
+        const { purchaseDate, ...rest } = mergedQuery || {}
+
+        /** @type {ClaimQueryParams & Record<string, any>} */
+        const apiParams = { ...rest }
+
+        // 购买日期区间:页面用 purchaseDate,接口用 purchaseDateStartStr/purchaseDateEndStr
+        if (Array.isArray(purchaseDate) && purchaseDate.length === 2) {
+          apiParams.purchaseDateStartStr = purchaseDate[0]
+          apiParams.purchaseDateEndStr = purchaseDate[1]
+        }
+
+        const res = await getClaimSearchComprehensive(page.pageSize, page.currentPage, apiParams)
+        const pageData = res?.data?.data
+        const records = (pageData && Array.isArray(pageData.records)) ? pageData.records : []
+
+        this.page.total = pageData?.total || 0
+        // 综合查询返回 records[].claimMain,列表展示按主表字段铺平
+        this.data = records.map((r) => ({
+          ...(r && r.claimMain ? r.claimMain : {}),
+          attachments: (r && Array.isArray(r.attachments)) ? r.attachments : [],
+          auditRecords: (r && Array.isArray(r.auditRecords)) ? r.auditRecords : []
+        }))
       } catch (error) {
         console.error('获取理赔列表失败:', error)
         this.$message.error('获取理赔列表失败')
@@ -349,6 +376,7 @@ export default {
      */
     searchChange(params, done) {
       this.query = params
+      this.page.currentPage = 1
       this.onLoad(this.page, params)
       done()
     },
@@ -360,6 +388,7 @@ export default {
      */
     searchReset() {
       this.query = {}
+      this.page.currentPage = 1
       this.onLoad(this.page)
     },
 
@@ -381,6 +410,7 @@ export default {
      */
     currentChange(currentPage) {
       this.page.currentPage = currentPage
+      this.onLoad(this.page, this.query)
     },
 
     /**
@@ -391,6 +421,8 @@ export default {
      */
     sizeChange(pageSize) {
       this.page.pageSize = pageSize
+      this.page.currentPage = 1
+      this.onLoad(this.page, this.query)
     },
 
     /**

+ 1 - 4
src/views/claim/index.vue

@@ -12,10 +12,7 @@
                @current-change="currentChange"
                @size-change="sizeChange"
                @refresh-change="refreshChange"
-               @on-load="onLoad"
-               @row-update="rowUpdate"
-               @row-save="rowSave"
-               @row-del="rowDel">
+               @on-load="onLoad">
       <template slot-scope="scope" slot="menu">
         <el-button type="text"
                    size="small"

+ 84 - 56
src/views/claim/types.d.ts

@@ -6,46 +6,69 @@
  * 理赔申请查询参数类型定义
  */
 export interface ClaimQueryParams {
-  claimNo?: string; // 理赔编号
-  claimSourceType?: number; // 理赔来源类型 1-经销商 2-门店
-  sourceCode?: string; // 来源编码
-  sourceName?: string; // 来源名称
-  consumerName?: string; // 消费者姓名
-  consumerPhone?: string; // 消费者电话
-  tyreNo?: string; // 轮胎编号
-  auditStatus?: number; // 审核状态 0-待审核 1-审核通过 2-审核拒绝
-  startDate?: string; // 开始日期
-  endDate?: string; // 结束日期
+  /** 理赔单号(精准匹配) */
+  claimNo?: string;
+  /** 来源类型:1 - 经销商、2 - 门店、3 - 终端消费者 */
+  claimSourceType?: number;
+  /** 审核状态:0 - 待审核、1 - 审核中、2 - 已通过、3 - 已拒绝 */
+  auditStatus?: number;
+  /** 是否已提交:0 - 未提交、1 - 已提交 */
+  isSubmitTime?: number;
+  /** 消费者姓名(模糊匹配) */
+  consumerName?: string;
+  /** 消费者电话(模糊匹配) */
+  consumerPhone?: string;
+  /** 胎号 / 轮胎宝编号(模糊匹配) */
+  tyreNo?: string;
+  /** 规格型号(模糊匹配) */
+  tyreSpecs?: string;
+  /**
+   * 页面用购买日期区间(avue searchRange 回传)
+   * 接口参数会被转换为 purchaseDateStartStr/purchaseDateEndStr
+   */
+  purchaseDate?: string | [string, string];
+  /** 购买日期开始(格式:yyyy-MM-dd HH:mm:ss) */
+  purchaseDateStartStr?: string;
+  /** 购买日期结束(格式:yyyy-MM-dd HH:mm:ss) */
+  purchaseDateEndStr?: string;
+  /** 索赔金额最小值 */
+  claimAmountMin?: number;
+  /** 索赔金额最大值 */
+  claimAmountMax?: number;
+  /** 行驶里程最小值 (km) */
+  runMileageMin?: number;
+  /** 行驶里程最大值 (km) */
+  runMileageMax?: number;
 }
 
 /**
  * 理赔申请数据项类型定义
  */
 export interface ClaimItem {
-  id: string; // 理赔ID
-  claimNo: string; // 理赔编号
-  claimSourceType: number; // 理赔来源类型
-  sourceId: number; // 来源ID
-  sourceCode: string; // 来源编码
-  sourceName: string; // 来源名称
-  consumerName: string; // 消费者姓名
-  consumerPhone: string; // 消费者电话
-  tyreNo: string; // 轮胎编号
-  tyreSpecs: string; // 轮胎规格
-  purchaseDate: string; // 购买日期
-  mountDate: string; // 安装日期
-  runMileage: number; // 行驶里程
-  vehicleNumber?: string; // 车牌号
-  tireQuantity?: number; // 轮胎数量
-  brandItem?: string; // 花纹
-  brandName?: string; // 品牌
-  claimReason: string; // 理赔原因
-  claimAmount: string; // 理赔金额
-  auditStatus: number; // 审核状态
-  isSubmitTime?: number; // 是否已提交 0-未提交 1-已提交
-  submitTime: string; // 提交时间
-  createTime: string; // 创建时间
-  updateTime: string; // 更新时间
+  id: number | string;
+  claimNo: string;
+  claimSourceType: number;
+  sourceId?: number | string;
+  sourceCode?: string;
+  sourceName?: string;
+  consumerName?: string;
+  consumerPhone?: string;
+  tyreNo?: string;
+  tyreSpecs?: string;
+  purchaseDate?: string;
+  mountDate?: string;
+  runMileage?: number;
+  vehicleNumber?: string;
+  tireQuantity?: number;
+  brandItem?: string;
+  brandName?: string;
+  claimReason?: string;
+  claimAmount?: number;
+  auditStatus?: number;
+  isSubmitTime?: number;
+  submitTime?: string;
+  createTime?: string;
+  updateTime?: string;
 }
 
 /**
@@ -133,42 +156,47 @@ export interface ClaimComponentData {
 export interface ClaimQueryParams {
   claimNo?: string;
   claimSourceType?: number;
-  sourceCode?: string;
-  sourceName?: string;
+  auditStatus?: number;
+  isSubmitTime?: number;
   consumerName?: string;
   consumerPhone?: string;
   tyreNo?: string;
-  auditStatus?: number;
-  startDate?: string;
-  endDate?: string;
+  tyreSpecs?: string;
+  purchaseDate?: string | [string, string];
+  purchaseDateStartStr?: string;
+  purchaseDateEndStr?: string;
+  claimAmountMin?: number;
+  claimAmountMax?: number;
+  runMileageMin?: number;
+  runMileageMax?: number;
 }
 
 // 列表项
 export interface ClaimItem {
-  id: string;
+  id: number | string;
   claimNo: string;
   claimSourceType: number;
-  sourceId: number;
-  sourceCode: string;
-  sourceName: string;
-  consumerName: string;
-  consumerPhone: string;
-  tyreNo: string;
-  tyreSpecs: string;
-  purchaseDate: string;
-  mountDate: string;
-  runMileage: number;
+  sourceId?: number | string;
+  sourceCode?: string;
+  sourceName?: string;
+  consumerName?: string;
+  consumerPhone?: string;
+  tyreNo?: string;
+  tyreSpecs?: string;
+  purchaseDate?: string;
+  mountDate?: string;
+  runMileage?: number;
   vehicleNumber?: string;
   tireQuantity?: number;
   brandItem?: string;
   brandName?: string;
-  claimReason: string;
-  claimAmount: string;
-  auditStatus: number;
+  claimReason?: string;
+  claimAmount?: number;
+  auditStatus?: number;
   isSubmitTime?: number;
-  submitTime: string;
-  createTime: string;
-  updateTime: string;
+  submitTime?: string;
+  createTime?: string;
+  updateTime?: string;
 }
 
 // 审核记录