Просмотр исходного кода

feat(发货状态查询): 添加字段映射和归一化处理

yz 2 недель назад
Родитель
Сommit
8c231ab9af
2 измененных файлов с 96 добавлено и 9 удалено
  1. 55 7
      src/api/types/comprehensive.d.ts
  2. 41 2
      src/views/shipment/shipStatusMixin.js

+ 55 - 7
src/api/types/comprehensive.d.ts

@@ -5,6 +5,8 @@ import { AxiosResponse } from 'axios';
  */
 export interface ComprehensiveApiResponse<T> {
   code: number;
+  /** 后端部分接口会返回 success 字段 */
+  success?: boolean;
   msg: string;
   data: T;
 }
@@ -61,6 +63,16 @@ export interface ShippingStatusInquiryParams {
  * 发货状态综合查询 - 响应记录(字段参考 shipdoc.md 示例)
  */
 export interface ShippingStatusInquiryRecord {
+  /** 通用审计字段(后端实际返回) */
+  id?: string;
+  createUser?: string;
+  createDept?: string;
+  createTime?: string;
+  updateUser?: string;
+  updateTime?: string;
+  isDeleted?: number;
+
+  /** 兼容文档(camelCase) */
   orgId?: number | string;
   orgCode?: string;
   orgName?: string;
@@ -68,24 +80,60 @@ export interface ShippingStatusInquiryRecord {
   docTypeCode?: string;
   docTypeName?: string;
   docNo?: string;
+  businessDate?: string;
   customerId?: number | string;
   customerCode?: string;
+  customerName?: string;
   itemId?: number | string;
   itemCode?: string;
+  itemName?: string;
   specs?: string;
-  finallyPrice?: number;
-  totalMoneyTc?: number;
-  totalNetMoneyTc?: number;
-  totalTaxTc?: number;
+  qty?: number | string;
+  orderPrice?: number | string;
+  finallyPrice?: number | string;
+  totalMoneyTc?: number | string;
+  totalNetMoneyTc?: number | string;
+  totalTaxTc?: number | string;
   whId?: number | string;
   whCode?: string;
   whName?: string;
-  soDocNo?: string;
-  soDocLineNo?: number | string;
+  soDocNo?: string | null;
+  soDocLineNo?: number | string | null;
   shipAddress?: string;
-  businessDate?: string;
   status?: number | string;
   lineStatus?: number | string;
+
+  /** 后端实际返回(PascalCase + 下划线) */
+  Status?: number | string;
+  Org_ID?: number | string;
+  Org_Code?: string;
+  Org_Name?: string;
+  DocType_ID?: number | string;
+  DocType_Code?: string;
+  DocType_Name?: string;
+  DocNo?: string;
+  BusinessDate?: string;
+  Customer_ID?: number | string;
+  Customer_Code?: string;
+  Customer_Name?: string;
+  Item_ID?: number | string;
+  Item_Code?: string;
+  Item_Name?: string;
+  SPECS?: string;
+  Qty?: number | string;
+  OrderPrice?: number | string;
+  FinallyPrice?: number | string;
+  TotalMoneyTC?: number | string;
+  TotalNetMoneyTC?: number | string;
+  TotalTaxTC?: number | string;
+  WH_ID?: number | string;
+  WH_Code?: string;
+  WH_Name?: string;
+  LineStatus?: number | string;
+  SoDocNo?: string | null;
+  SoDocLineNo?: number | string | null;
+  ShipAddress?: string;
+
   [key: string]: any;
 }
 

+ 41 - 2
src/views/shipment/shipStatusMixin.js

@@ -216,6 +216,45 @@ export default {
 
         const res = await getShippingStatusInquiry(params)
         const respData = res && res.data ? res.data.data : null
+
+        // 后端实际返回字段多为 PascalCase + 下划线;表格/搜索字段使用 camelCase
+        // 这里做一层归一化,避免页面列 prop 改动导致搜索参数也被改名。
+        const normalizeShippingStatusRecord = (row) => {
+          if (!row || typeof row !== 'object') return row
+          return {
+            ...row,
+            orgId: row.orgId ?? row.Org_ID,
+            orgCode: row.orgCode ?? row.Org_Code,
+            orgName: row.orgName ?? row.Org_Name,
+            docTypeId: row.docTypeId ?? row.DocType_ID,
+            docTypeCode: row.docTypeCode ?? row.DocType_Code,
+            docTypeName: row.docTypeName ?? row.DocType_Name,
+            docNo: row.docNo ?? row.DocNo,
+            businessDate: row.businessDate ?? row.BusinessDate,
+            customerId: row.customerId ?? row.Customer_ID,
+            customerCode: row.customerCode ?? row.Customer_Code,
+            customerName: row.customerName ?? row.Customer_Name,
+            itemId: row.itemId ?? row.Item_ID,
+            itemCode: row.itemCode ?? row.Item_Code,
+            itemName: row.itemName ?? row.Item_Name,
+            specs: row.specs ?? row.SPECS,
+            qty: row.qty ?? row.Qty,
+            orderPrice: row.orderPrice ?? row.OrderPrice,
+            finallyPrice: row.finallyPrice ?? row.FinallyPrice,
+            totalMoneyTc: row.totalMoneyTc ?? row.TotalMoneyTC,
+            totalNetMoneyTc: row.totalNetMoneyTc ?? row.TotalNetMoneyTC,
+            totalTaxTc: row.totalTaxTc ?? row.TotalTaxTC,
+            whId: row.whId ?? row.WH_ID,
+            whCode: row.whCode ?? row.WH_Code,
+            whName: row.whName ?? row.WH_Name,
+            soDocNo: row.soDocNo ?? row.SoDocNo,
+            soDocLineNo: row.soDocLineNo ?? row.SoDocLineNo,
+            shipAddress: row.shipAddress ?? row.ShipAddress,
+            status: row.status ?? row.Status,
+            lineStatus: row.lineStatus ?? row.LineStatus
+          }
+        }
+
         const isPaged =
           respData &&
           typeof respData === 'object' &&
@@ -225,7 +264,7 @@ export default {
         this.serverPaging = Boolean(isPaged)
 
         if (isPaged) {
-          const records = respData.records
+          const records = (respData.records || []).map(normalizeShippingStatusRecord)
           // 默认按业务日期倒序(无 businessDate 时保持原顺序)
           this.data = records.slice().sort((a, b) => {
             const at = a && a.businessDate ? new Date(a.businessDate).getTime() : 0
@@ -237,7 +276,7 @@ export default {
           return
         }
 
-        const list = Array.isArray(respData) ? respData : []
+        const list = (Array.isArray(respData) ? respData : []).map(normalizeShippingStatusRecord)
 
         // 默认按业务日期倒序(无 businessDate 时保持原顺序)
         this.rawData = list.slice().sort((a, b) => {