From 0ab72e43eb4c0e4f6439d0d71f8f70fc88471180 Mon Sep 17 00:00:00 2001 From: Lei OT Date: Thu, 2 Apr 2026 10:36:24 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E4=BA=BA=E7=AD=89=E7=9A=84=E6=98=BE?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hooks/useProductsSets.js | 7 +++++++ src/views/products/Detail/ProductInfoQuotation.jsx | 4 ++-- src/views/products/Print/AgencyPreview.jsx | 12 ++++++------ 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/hooks/useProductsSets.js b/src/hooks/useProductsSets.js index f3afebf..fbc354f 100644 --- a/src/hooks/useProductsSets.js +++ b/src/hooks/useProductsSets.js @@ -210,6 +210,13 @@ export const PackageTypes = [ ]; export const formatGroupSize = (min, max, suffix = false) => { + const minSize = min === 0 ? 1 : min; + // const rangeStr = max === min ? `${minSize}` : `${minSize}-${max}`; + const rangeStr = `${minSize}-${max}`; + return max === 1000 ? minSize <= 1 ? '不分人等' : `${minSize}人以上` : (`${rangeStr}`+(suffix ? '人' : '')); +}; + +export const formatGroupSizeRender = (min, max, suffix = false) => { const minSize = min === 0 ? 1 : min; const rangeStr = max === min ? `${minSize}` : `${minSize}-${max}`; return max === 1000 ? minSize <= 1 ? '不分人等' : `${minSize}人以上` : (`${rangeStr}`+(suffix ? '人' : '')); diff --git a/src/views/products/Detail/ProductInfoQuotation.jsx b/src/views/products/Detail/ProductInfoQuotation.jsx index 3a1017f..6c81cee 100644 --- a/src/views/products/Detail/ProductInfoQuotation.jsx +++ b/src/views/products/Detail/ProductInfoQuotation.jsx @@ -30,7 +30,7 @@ import dayjs from "dayjs"; import useProductsStore from "@/stores/Products/Index"; import useAuthStore from '@/stores/Auth' import PriceCompactInput from "@/views/products/Detail/PriceCompactInput"; -import { formatGroupSize } from "@/hooks/useProductsSets"; +import { formatGroupSize, formatGroupSizeRender } from "@/hooks/useProductsSets"; const { RangePicker } = DatePicker; @@ -259,7 +259,7 @@ const ProductInfoQuotation = ({ editable, ...props }) => { dataIndex: "group_size", width: "6rem", render: (_, record) => - formatGroupSize(record.group_size_min, record.group_size_max), + formatGroupSizeRender(record.group_size_min, record.group_size_max), }, { diff --git a/src/views/products/Print/AgencyPreview.jsx b/src/views/products/Print/AgencyPreview.jsx index 7fb6c72..127c7d0 100644 --- a/src/views/products/Print/AgencyPreview.jsx +++ b/src/views/products/Print/AgencyPreview.jsx @@ -3,7 +3,7 @@ import { useParams, Link } from 'react-router-dom'; import { Button, Drawer, Card, Table } from 'antd'; import { useTranslation } from 'react-i18next'; import useProductsStore, { getAgencyAllExtrasAction } from '@/stores/Products/Index'; -import { useProductsTypes, formatGroupSize, useProductsTypesMapVal } from '@/hooks/useProductsSets'; +import { useProductsTypes, formatGroupSize, useProductsTypesMapVal, formatGroupSizeRender } from '@/hooks/useProductsSets'; import { chunkBy, splitTable_6, splitTable_7, splitTable_8, splitTable_B, splitTable_D, splitTable_J, splitTable_Q, splitTable_R } from '@/hooks/useProductsQuotationFormat'; import { groupBy, isNotEmpty } from '@haina/utils-commons'; import useAuthStore from '@/stores/Auth'; @@ -259,7 +259,7 @@ const AgencyPreview = ({ params, ...props }) => { ), }, ...cols.map((col) => ({ - title: formatGroupSize(...col), + title: formatGroupSizeRender(...col), // dataIndex: [formatGroupSize(...col), 'adult_cost'], key: col[0], children: [ @@ -378,7 +378,7 @@ const AgencyPreview = ({ params, ...props }) => { ), }, ...cols.map((col) => ({ - title: formatGroupSize(...col), + title: formatGroupSizeRender(...col), // dataIndex: [formatGroupSize(...col), 'adult_cost'], key: col[0], children: [ @@ -502,7 +502,7 @@ const AgencyPreview = ({ params, ...props }) => { ), }, ...cols.map((col) => ({ - title: formatGroupSize(...col), + title: formatGroupSizeRender(...col), // dataIndex: [formatGroupSize(...col), 'adult_cost'], key: col[0], // children1: [ @@ -965,7 +965,7 @@ const AgencyPreview = ({ params, ...props }) => { ), }, ...cols.map((col) => ({ - title: formatGroupSize(...col), + title: formatGroupSizeRender(...col), // dataIndex: [formatGroupSize(...col), 'adult_cost'], key: col[0], children: [ @@ -1100,7 +1100,7 @@ const AgencyPreview = ({ params, ...props }) => { ), }, ...cols.map((col) => ({ - title: formatGroupSize(...col), + title: formatGroupSizeRender(...col), // dataIndex: [formatGroupSize(...col), 'adult_cost'], key: col[0], children: [