From 44d315a9530c190932e6f78459dd5e88fa7d2998 Mon Sep 17 00:00:00 2001 From: dzq Date: Thu, 27 Nov 2025 11:49:55 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E8=AE=A2=E5=8D=95):=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E6=9C=BA=E6=9F=9C=E5=92=8C=E6=A0=BC=E5=8F=A3=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E5=8F=8A=E5=8F=82=E6=95=B0=E8=BF=87=E6=BB=A4?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在借还记录页面添加机柜名称和格口号显示,并新增工具函数过滤请求参数中的undefined和null值 --- src/api/shop/order.ts | 8 +++++++ src/utils/http/index.ts | 6 ++++- src/utils/tools/object.ts | 23 +++++++++++++++++++ src/views/shop/goods/borrow-return-record.vue | 13 ++++++++--- 4 files changed, 46 insertions(+), 4 deletions(-) create mode 100644 src/utils/tools/object.ts diff --git a/src/api/shop/order.ts b/src/api/shop/order.ts index 28134f7..d175e60 100644 --- a/src/api/shop/order.ts +++ b/src/api/shop/order.ts @@ -184,6 +184,14 @@ export interface BorrowReturnRecordDTO { status: number; /** 状态描述 */ statusStr: string; + /** 格口ID */ + cellId?: number; + /** 格口号 */ + cellNo?: number; + /** 柜机ID */ + cabinetId?: number; + /** 柜机名称 */ + cabinetName?: string; } /** 获取借还记录分页列表 */ diff --git a/src/utils/http/index.ts b/src/utils/http/index.ts index 6382eac..b5db671 100644 --- a/src/utils/http/index.ts +++ b/src/utils/http/index.ts @@ -17,6 +17,7 @@ import { ElMessageBox } from "element-plus"; import { router } from "@/router"; import { removeToken } from "@/utils/auth"; import { downloadByData } from "@pureadmin/utils"; +import { filterUndefinedAndNull } from "../tools/object"; // console.log("Utils:" + router); const { VITE_APP_BASE_API } = import.meta.env; @@ -201,10 +202,13 @@ class PureHttp { param?: AxiosRequestConfig, axiosConfig?: PureHttpRequestConfig ): Promise { + // 过滤param中的undefined和null值 + const filteredParam = param ? filterUndefinedAndNull(param) : param; + const config = { method, url, - ...param, + ...filteredParam, ...axiosConfig } as PureHttpRequestConfig; diff --git a/src/utils/tools/object.ts b/src/utils/tools/object.ts new file mode 100644 index 0000000..e1be05c --- /dev/null +++ b/src/utils/tools/object.ts @@ -0,0 +1,23 @@ + +/** 过滤掉值为undefined和null的字段 */ +export const filterUndefinedAndNull = (obj: any): any => { + if (obj === null || obj === undefined) { + return obj; + } + + if (Array.isArray(obj)) { + return obj.map(item => filterUndefinedAndNull(item)); + } + + if (typeof obj === 'object') { + const filteredObj: any = {}; + for (const [key, value] of Object.entries(obj)) { + if (value !== undefined && value !== null) { + filteredObj[key] = filterUndefinedAndNull(value); + } + } + return filteredObj; + } + + return obj; +} \ No newline at end of file diff --git a/src/views/shop/goods/borrow-return-record.vue b/src/views/shop/goods/borrow-return-record.vue index d658e5a..79d6131 100644 --- a/src/views/shop/goods/borrow-return-record.vue +++ b/src/views/shop/goods/borrow-return-record.vue @@ -82,9 +82,6 @@ onMounted(() => { - - - 搜索 @@ -103,6 +100,16 @@ onMounted(() => { {{ row.orderTime ? new Date(row.orderTime).toLocaleString() : '-' }} + + + + + +