From 45aa339fc6bec1aa8c708115a8b2b50928f0c0a9 Mon Sep 17 00:00:00 2001 From: Lei OT Date: Tue, 19 Aug 2025 11:18:17 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BA=A7=E5=93=81=E7=AE=A1=E7=90=86:?= =?UTF-8?q?=20=E9=A2=84=E8=A7=88=20&=20=E5=AF=BC=E5=87=BA=E5=90=88?= =?UTF-8?q?=E5=90=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hooks/useProductsQuotationFormat.js | 27 ++++--- src/views/products/Print/AgencyContract.jsx | 10 +-- src/views/products/Print/AgencyPreview.jsx | 88 +++++++++++---------- 3 files changed, 70 insertions(+), 55 deletions(-) diff --git a/src/hooks/useProductsQuotationFormat.js b/src/hooks/useProductsQuotationFormat.js index 9896c2e..ed8321b 100644 --- a/src/hooks/useProductsQuotationFormat.js +++ b/src/hooks/useProductsQuotationFormat.js @@ -1,6 +1,7 @@ import { flush, groupBy, isEmpty, isNotEmpty, pick, unique, uniqWith } from '@/utils/commons'; import dayjs from 'dayjs'; import { formatGroupSize } from './useProductsSets'; + // Shoulder Season 平季; peak season 旺季 export const isFullYearOrLonger = (year, startDate, endDate) => { // Parse the dates @@ -21,17 +22,21 @@ export const isFullYearOrLonger = (year, startDate, endDate) => { return isFullYear || isLongerThanYear || isLongerThan12M; }; -const uniqueBySub = (arr) => - arr.filter((subArr1, _, self) => { - return !self.some((subArr2) => { - if (subArr1 === subArr2) return false; // don't compare a subarray with itself - const set1 = new Set(subArr1); - const set2 = new Set(subArr2); - // check if subArr1 is a subset of subArr2 - return [...set1].every((value) => set2.has(value)); +const uniqueBySub = (arr) => { + const sortedArr = arr.sort((a, b) => b.length - a.length); + const uniqueArr = []; + sortedArr.forEach((currentSubArr) => { + const isSubsetOfUnique = uniqueArr.some((uniqueSubArr) => { + return currentSubArr.every((item) => uniqueSubArr.includes(item)); }); + if (!isSubsetOfUnique) { + uniqueArr.push(currentSubArr); + } }); + return uniqueArr; +} + export const chunkBy = (use_year, dataList = [], by = []) => { const dataRollSS = dataList.map((rowp, ii) => { const quotation = rowp.quotation.map((quoteItem) => { @@ -77,8 +82,8 @@ export const chunkBy = (use_year, dataList = [], by = []) => { // 补全产品旺季的人等分组 (当旺季和平季的人等不完全一致时) for (const WPI in PGroupSizeSS) { if (Object.prototype.hasOwnProperty.call(PGroupSizeSS, WPI)) { - const element = PGroupSizeSS[WPI]; - const elementP = PGroupSizePS[WPI]; + const element = PGroupSizeSS[WPI] || []; + const elementP = PGroupSizePS[WPI] || []; const diff = (elementP || []).filter((ele, index) => !element.includes(ele)); PGroupSizeSS[WPI] = element.concat(diff); } @@ -148,6 +153,8 @@ export const chunkBy = (use_year, dataList = [], by = []) => { const _quotation = rowp.quotation.map((quoteItem) => { quoteItem.quote_size = pkey; quoteItem.quote_col_key = formatGroupSize(quoteItem.group_size_min, quoteItem.group_size_max); + quoteItem.use_dates_start = quoteItem.use_dates_start.replace(/-/g, '.'); + quoteItem.use_dates_end = quoteItem.use_dates_end.replace(/-/g, '.'); return quoteItem; }); const quote_chunk_flat = groupBy(_quotation, (quoteItem2) => by.map((key) => quoteItem2[key]).join('@') || '#'); diff --git a/src/views/products/Print/AgencyContract.jsx b/src/views/products/Print/AgencyContract.jsx index 47acadf..450e39c 100644 --- a/src/views/products/Print/AgencyContract.jsx +++ b/src/views/products/Print/AgencyContract.jsx @@ -444,7 +444,7 @@ export default class AgencyContract { new TableCell({ borders: tableBorderOne, verticalAlign: AlignmentType.CENTER, - children: [new Paragraph({ text: `${row.info?.km || '0'}`, alignment: AlignmentType.CENTER, })], + children: [new Paragraph({ text: `${row.info?.km ?? ''}`, alignment: AlignmentType.CENTER, })], }), ...cols.map( (ss) => @@ -550,7 +550,7 @@ export default class AgencyContract { ? row.rowSpan > 1 ? ['平季', '(除特殊时段外)'].map((str) => new Paragraph({ text: str, alignment: AlignmentType.LEFT })) : [new Paragraph({ text: '' })] - : ['特殊时段', `${row.use_dates_start.replace(`${use_year}-`, '')}~${row.use_dates_end.replace(`${use_year}-`, '')}`].map( + : ['特殊时段', `${row.use_dates_start.replace(`${use_year}.`, '')}~${row.use_dates_end.replace(`${use_year}.`, '')}`].map( (str) => new Paragraph({ text: str, alignment: AlignmentType.LEFT }) )), ], @@ -667,7 +667,7 @@ export default class AgencyContract { ? row.rowSpan > 1 ? ['平季', '(除特殊时段外)'].map((str) => new Paragraph({ text: str, alignment: AlignmentType.LEFT })) : [new Paragraph({ text: '' })] - : ['特殊时段', `${row.use_dates_start.replace(`${use_year}-`, '')}~${row.use_dates_end.replace(`${use_year}-`, '')}`].map( + : ['特殊时段', `${row.use_dates_start.replace(`${use_year}.`, '')}~${row.use_dates_end.replace(`${use_year}.`, '')}`].map( (str) => new Paragraph({ text: str, alignment: AlignmentType.LEFT }) )), ], @@ -810,7 +810,7 @@ export default class AgencyContract { borders: ii !== _arr.length - 1 ? tableBorderInner : tableBorderInnerR, width: { size: 2400, type: WidthType.DXA }, verticalAlign: AlignmentType.CENTER, - children: quoteItem.rows.map(d => new Paragraph({ alignment: AlignmentType.LEFT, text: `${d.use_dates_start.replace(`${use_year}-`, '')}~${d.use_dates_end.replace(`${use_year}-`, '')}` })), + children: quoteItem.rows.map(d => new Paragraph({ alignment: AlignmentType.LEFT, text: `${d.use_dates_start.replace(`${use_year}.`, '')}~${d.use_dates_end.replace(`${use_year}.`, '')}` })), }), new TableCell({ borders: ii !== _arr.length - 1 ? tableBorderInnerB : tableBorderNone, @@ -953,7 +953,7 @@ export default class AgencyContract { (d) => new Paragraph({ alignment: AlignmentType.LEFT, - text: `${d.use_dates_start.replace(`${use_year}-`, '')}~${d.use_dates_end.replace(`${use_year}-`, '')}`, + text: `${d.use_dates_start.replace(`${use_year}.`, '')}~${d.use_dates_end.replace(`${use_year}.`, '')}`, }) ), }), diff --git a/src/views/products/Print/AgencyPreview.jsx b/src/views/products/Print/AgencyPreview.jsx index 993e75c..e3e7337 100644 --- a/src/views/products/Print/AgencyPreview.jsx +++ b/src/views/products/Print/AgencyPreview.jsx @@ -9,7 +9,7 @@ import { groupBy } from '@/utils/commons'; const AgencyPreview = ({ params, ...props }) => { const { t } = useTranslation(); - const { travel_agency_id, use_year, audit_state } = useParams(); + const { travel_agency_id, use_year } = params; const productsTypes = useProductsTypes(); const [agencyProducts] = useProductsStore((state) => [state.agencyProducts]); @@ -78,7 +78,7 @@ const AgencyPreview = ({ params, ...props }) => { // className='mt-4' columns={[ { - title: '项目', + title: '综费项目', dataIndex: ['info', 'product_title'], key: 'product_title', width: '12rem', @@ -128,7 +128,7 @@ const AgencyPreview = ({ params, ...props }) => { rowClassName={cityRowHighlights} columns={[ { - title: '项目', + title: '超公里项目', dataIndex: ['info', 'product_title'], key: 'product_title', width: '12rem', maxWidth: '12rem', className: 'max-w-48', @@ -161,7 +161,7 @@ const AgencyPreview = ({ params, ...props }) => {
特殊时段
- {use_dates_start.replace(`${use_year}-`, '')}~{use_dates_end.replace(`${use_year}-`, '')} + {use_dates_start.replace(`${use_year}.`, '')}~{use_dates_end.replace(`${use_year}.`, '')}
), @@ -206,7 +206,7 @@ const AgencyPreview = ({ params, ...props }) => { rowClassName={cityRowHighlights} columns={[ { - title: '项目', + title: '车费项目', dataIndex: ['info', 'product_title'], key: 'product_title', width: '12rem', @@ -230,7 +230,7 @@ const AgencyPreview = ({ params, ...props }) => {
特殊时段
- {use_dates_start.replace(`${use_year}-`, '')}~{use_dates_end.replace(`${use_year}-`, '')} + {use_dates_start.replace(`${use_year}.`, '')}~{use_dates_end.replace(`${use_year}.`, '')}
), @@ -275,7 +275,7 @@ const AgencyPreview = ({ params, ...props }) => { rowClassName={cityRowHighlights} columns={[ { - title: '项目', + title: '包价线路项目', dataIndex: ['info', 'product_title'], key: 'product_title', width: '12rem', @@ -291,15 +291,18 @@ const AgencyPreview = ({ params, ...props }) => { width: '9rem', fixed: 'left', render: (_, { quote_season, use_dates_start, use_dates_end, rowSpan }) => - quote_season === 'SS' ? (rowSpan > 1 ? ( + quote_season === 'SS' ? ((rowSpan === 1) ? '' : (
平季
(除特殊时段外)
+
+ {use_dates_start.replace(`${use_year}.`, '')}~{use_dates_end.replace(`${use_year}.`, '')} +
- ) : '') : ( + )) : (
特殊时段
- {use_dates_start.replace(`${use_year}-`, '')}~{use_dates_end.replace(`${use_year}-`, '')} + {use_dates_start.replace(`${use_year}.`, '')}~{use_dates_end.replace(`${use_year}.`, '')}
), @@ -347,7 +350,7 @@ const AgencyPreview = ({ params, ...props }) => { rowClassName={cityRowHighlights} columns={[ { - title: '项目', + title: '导游项目', dataIndex: ['info', 'product_title'], key: 'product_title', width: '12rem', @@ -365,7 +368,7 @@ const AgencyPreview = ({ params, ...props }) => { title: '成人', dataIndex: [0, 'adult_cost'], key: 'adult_cost', - width: '9rem', + width: '9rem', align: 'center', render: (_, { SS }) => (
{(SS || []).length === 1 ? ( @@ -391,7 +394,7 @@ const AgencyPreview = ({ params, ...props }) => { title: '儿童', dataIndex: [0, 'child_cost'], key: 'child_cost', - width: '9rem', + width: '9rem', align: 'center', render: (_, { SS }) => (
{(SS || []).length === 1 ? ( @@ -425,21 +428,19 @@ const AgencyPreview = ({ params, ...props }) => { title: '成人', dataIndex: [0, 'adult_cost'], key: 'adult_cost', - width: '9rem', + width: '9rem', align: 'center', render: (_, { PS }) => (
{(PS || []).map((ele, pi) => ( -
- {ele.adult_cost} -
- { - ele.rows.map((d, di) => ( +
+
+ {ele.rows.map((d, di) => (
- ({d.use_dates_start.replace(`${use_year}-`, '')}~{d.use_dates_end.replace(`${use_year}-`, '')}) + {d.use_dates_start.replace(`${use_year}.`, '')}~{d.use_dates_end.replace(`${use_year}.`, '')}
- )) - } + ))}
+ {ele.adult_cost}
))}
@@ -449,19 +450,19 @@ const AgencyPreview = ({ params, ...props }) => { title: '儿童', dataIndex: [0, 'child_cost'], key: 'child_cost', - width: '9rem', + width: '9rem', align: 'center', render: (_, { PS }) => (
{(PS || []).map((ele, pi) => ( -
- {ele.child_cost} -
+
+
{ele.rows.map((d, di) => (
- ({d.use_dates_start.replace(`${use_year}-`, '')}~{d.use_dates_end.replace(`${use_year}-`, '')}) + {d.use_dates_start.replace(`${use_year}.`, '')}~{d.use_dates_end.replace(`${use_year}.`, '')}
))}
+ {ele.child_cost}
))}
@@ -498,7 +499,7 @@ const AgencyPreview = ({ params, ...props }) => { rowClassName={cityRowHighlights} columns={[ { - title: '项目', + title: '景点项目', dataIndex: ['info', 'product_title'], key: 'product_title', width: '12rem', @@ -546,6 +547,7 @@ const AgencyPreview = ({ params, ...props }) => { <> 旺季
+ - 成人 儿童
@@ -560,17 +562,15 @@ const AgencyPreview = ({ params, ...props }) => { {(PS || []).map((ele, pi) => (
- {ele.adult_cost} - {ele.child_cost} -
-
+
{ele.rows.map((d, di) => (
- ({d.use_dates_start.replace(`${use_year}-`, '')}~{d.use_dates_end.replace(`${use_year}-`, '')}) + {d.use_dates_start.replace(`${use_year}.`, '')}~{d.use_dates_end.replace(`${use_year}.`, '')}
- ))} -
- {/*
( {ele.rows.map((d) => `${d.use_dates_start.replace(`${use_year}-`, '')}~${d.use_dates_end.replace(`${use_year}-`, '')}`).join('; ')} )
*/} + ))}
+ {ele.adult_cost} + {ele.child_cost} +
))}
@@ -604,7 +604,7 @@ const AgencyPreview = ({ params, ...props }) => { rowClassName={cityRowHighlights} columns={[ { - title: '项目', + title: '餐费项目', dataIndex: ['info', 'product_title'], key: 'product_title', width: '12rem', @@ -628,7 +628,7 @@ const AgencyPreview = ({ params, ...props }) => {
特殊时段
- {use_dates_start.replace(`${use_year}-`, '')}~{use_dates_end.replace(`${use_year}-`, '')} + {use_dates_start.replace(`${use_year}.`, '')}~{use_dates_end.replace(`${use_year}.`, '')}
), @@ -677,7 +677,7 @@ const AgencyPreview = ({ params, ...props }) => { rowClassName={cityRowHighlights} columns={[ { - title: '项目', + title: '附加项目', dataIndex: ['info', 'product_title'], key: 'product_title', width: '12rem', maxWidth: '12rem', className: 'max-w-48', @@ -701,7 +701,7 @@ const AgencyPreview = ({ params, ...props }) => {
特殊时段
- {use_dates_start.replace(`${use_year}-`, '')}~{use_dates_end.replace(`${use_year}-`, '')} + {use_dates_start.replace(`${use_year}.`, '')}~{use_dates_end.replace(`${use_year}.`, '')}
), @@ -727,13 +727,21 @@ const AgencyPreview = ({ params, ...props }) => { } const typeTableMap = { + // '6': { render: () => {} }, '6': { render: renderTable_6 }, + // 'B': { render: () => {} }, 'B': { render: renderTable_B }, + // 'J': { render: () => {} }, 'J': { render: renderTable_J }, + // 'Q': { render: () => {} }, 'Q': { render: renderTable_Q }, + // '7': { render: () => {} }, '7': { render: renderTable_7 }, + // 'R': { render: () => {} }, 'R': { render: renderTable_R }, + // '8': { render: () => {} }, '8': { render: renderTable_8 }, + // 'D': { render: () => {} }, 'D': { render: renderTable_D }, };