From f0f7dc3939f9122b4a799e217b0eb5d0fbe10145 Mon Sep 17 00:00:00 2001 From: Lei OT Date: Fri, 30 Aug 2024 22:31:03 +0800 Subject: [PATCH] . --- src/views/products/Print/AgencyContract.jsx | 32 ++++++++++++--------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/src/views/products/Print/AgencyContract.jsx b/src/views/products/Print/AgencyContract.jsx index 1bdc2d1..3aaa855 100644 --- a/src/views/products/Print/AgencyContract.jsx +++ b/src/views/products/Print/AgencyContract.jsx @@ -72,15 +72,20 @@ const chunkBy = (use_year, dataList = [], by = []) => { uniqWith(groupSize, (a, b) => a[0] === b[0] && a[1] === b[1]), (c) => c[0] ); + // 按max最大值 cut分组 const sizeSets = Object.keys(allSizeCut).map((s1) => [Number(s1), Math.max(...allSizeCut[s1].map((c) => c[1]))]); const sizeSetsByMax = uniqWith(sizeSets, (a, b) => a[1] === b[1]); - // const sizeSetsByMax = [[1,4], [5,6], [7, 9], [10, Infinity]]; // test: 固定车辆座次 + // // const sizeSetsByMax = [[1,4], [5,6], [7, 9], [10, Infinity]]; // test: 固定车辆座次 + // 按max最小值 cut分组 + // const sizeSets = Object.keys(allSizeCut).map((s1) => [Number(s1), Math.min(...allSizeCut[s1].map((c) => c[1]))]); + // const sizeSetsByMax = uniqWith(sizeSets, (a, b) => a[1] === b[1]); const dataRoll = dataList.map((rowp, ii) => { const quotation = rowp.quotation.map((quoteItem) => { const matchRange = cloneDeep(sizeSetsByMax) .reverse() .find((ss) => quoteItem.group_size_min >= ss[0] && quoteItem.group_size_max <= ss[1]); + const inSet = matchRange; // const matchMax = // matchRange || // cloneDeep(sizeSetsByMax) @@ -92,7 +97,6 @@ const chunkBy = (use_year, dataList = [], by = []) => { // // .reverse() // .find((ss) => quoteItem.group_size_min >= ss[0]); // const inSet = matchMin; - const inSet = matchRange; return { ...quoteItem, quote_season: isFullYearOrLonger(use_year, quoteItem.use_dates_start, quoteItem.use_dates_end) ? 'SS' : 'PS', @@ -120,9 +124,10 @@ const chunkBy = (use_year, dataList = [], by = []) => { return { ...rowp, quote_chunk: thisChunk }; }); const allquotation = chunk.reduce((a, c) => a.concat(c.quotation), []); + // 取出两季相应的时效区间 const SSRange = unique((allquotation || []).filter((q) => q.quote_season === 'SS').map((qr) => `${qr.use_dates_start}~${qr.use_dates_end}`)); const PSRange = unique((allquotation || []).filter((q) => q.quote_season === 'PS').map((qr) => `${qr.use_dates_start}~${qr.use_dates_end}`)); - // console.log(chunk, dataSource, sizeSets, sizeSetsByMax); + // console.log('chunk', chunk, dataSource, sizeSets, sizeSetsByMax); return { chunk, dataSource, sizeSets: sizeSetsByMax, SSRange, PSRange }; }; @@ -153,6 +158,7 @@ export default class AgencyContract { const yearStart = dayjs(`${use_year}-01-01`).format('YYYY.MM.DD'); const yearEnd = dayjs(`${use_year}-12-31`).format('YYYY.MM.DD'); // console.log(agencyExtras); + console.log('*********************************************************************************************'); const document = new Document({ creator: 'China Highlights', @@ -317,26 +323,21 @@ export default class AgencyContract { }), }, children: [ - // new Paragraph({ - // text: h1, - // heading: HeadingLevel.HEADING_1, - // alignment: 'center', - // }), this.createTitle(h1), this.createSubHeading(`价格有效期: ${yearStart}-${yearEnd}`, { alignment: AlignmentType.CENTER }), ...(isEmpty(agencyProducts['6']) ? [] - : [this.createSubHeading(`综费`, { numbering: { reference: 'products-type', level: 0 } }), this.createTable_6(use_year, agencyProducts['6'])]), + : [this.createSubHeading(`综费`, { numbering: { reference: 'products-type', level: 0 } }), this.createTable_6Q(use_year, agencyProducts['6'])]), ...(isEmpty(agencyProducts['B']) ? [] : [this.createSubHeading(`超公里`, { numbering: { reference: 'products-type', level: 0 } }), this.createTable_B(use_year, agencyProducts['B'])]), ...(isEmpty(agencyProducts['J']) ? [] - : [this.createSubHeading(`车费`, { numbering: { reference: 'products-type', level: 0 } }), this.createTable_J(use_year, agencyProducts['J'])]), + : [this.createSubHeading(`车费`, { numbering: { reference: 'products-type', level: 0 } }), this.createTable_JD(use_year, agencyProducts['J'])]), ...(isEmpty(agencyProducts['Q']) ? [] - : [this.createSubHeading(`导游`, { numbering: { reference: 'products-type', level: 0 } }), this.createTable_6(use_year, agencyProducts['Q'])]), + : [this.createSubHeading(`导游`, { numbering: { reference: 'products-type', level: 0 } }), this.createTable_6Q(use_year, agencyProducts['Q'])]), // this.createTable_Q(use_year, agencyProducts['Q']), ...(isEmpty(agencyProducts['7']) ? [] @@ -346,7 +347,7 @@ export default class AgencyContract { : [this.createSubHeading(`餐费`, { numbering: { reference: 'products-type', level: 0 } }), this.createTable_R(use_year, agencyProducts['R'], agencyExtras)]), ...(isEmpty(agencyProducts['D']) ? [] - : [this.createSubHeading(`包价线路`, { numbering: { reference: 'products-type', level: 0 } }), this.createTable_J(use_year, agencyProducts['D'])]), + : [this.createSubHeading(`包价线路`, { numbering: { reference: 'products-type', level: 0 } }), this.createTable_JD(use_year, agencyProducts['D'])]), this.createSubHeading(`公司银行账户`, { numbering: { reference: 'products-type', level: 0 } }), this.createInfo_Bank(), this.createSubHeading(`联系资料`, { numbering: { reference: 'products-type', level: 0 } }), @@ -363,8 +364,9 @@ export default class AgencyContract { /** * 综费 + * 导游 */ - createTable_6(use_year, dataList, style = {}) { + createTable_6Q(use_year, dataList, style = {}) { const { chunk, SSRange, PSRange } = chunkBy(use_year, dataList, ['quote_season']); return new Table({ @@ -429,9 +431,11 @@ export default class AgencyContract { /** * 车费 + * 包价线路 */ - createTable_J(use_year, dataList) { + createTable_JD(use_year, dataList) { const { chunk, dataSource, sizeSets, SSRange, PSRange } = chunkBy(use_year, dataList, ['quote_season', 'quote_size']); + // console.log(chunk, dataSource, sizeSets); return new Table({ borders: tableBorderNone,