perf: 导出合同: 车费, 增加时段列, 显示价格行的时段信息; 景点的绑定: 仅显示`项目名称-类型`; 包价: 全年的时段不显示, 与车费一样按时段分行

main
Lei OT 7 months ago
parent 9adf82de12
commit 813258881f

@ -600,6 +600,7 @@ export default class AgencyContract {
const showPSCol = false const showPSCol = false
const defaultUnit = '1' const defaultUnit = '1'
const { dataSource, sizeSets, SSRange, PSRange } = chunkBy(use_year, dataList, chunk_By) const { dataSource, sizeSets, SSRange, PSRange } = chunkBy(use_year, dataList, chunk_By)
const showRangeCol = PSRange.length > 0;
// //
const [remarkItem] = this.#remarkList.filter((i) => i.product_type_id == 'J') const [remarkItem] = this.#remarkList.filter((i) => i.product_type_id == 'J')
@ -615,7 +616,7 @@ export default class AgencyContract {
new TableRow({ new TableRow({
children: [ children: [
tableHeader('项目', 15), tableHeader('项目', 15),
tableHeader('', 15), ...(showRangeCol ? [tableHeader('', 15)] : []),
tableHeader([...SSRange], 30, { columnSpan: setItem.length + 1 }), tableHeader([...SSRange], 30, { columnSpan: setItem.length + 1 }),
showPSCol showPSCol
? tableHeader(['旺季', ...PSRange], 40, { ? tableHeader(['旺季', ...PSRange], 40, {
@ -632,11 +633,11 @@ export default class AgencyContract {
verticalAlign: AlignmentType.CENTER, verticalAlign: AlignmentType.CENTER,
children: [new Paragraph({ text: '' })], children: [new Paragraph({ text: '' })],
}), }),
new TableCell({ ...(showRangeCol ? [new TableCell({
borders: tableBorderOne, borders: tableBorderOne,
verticalAlign: AlignmentType.CENTER, verticalAlign: AlignmentType.CENTER,
children: [new Paragraph({ text: '时段', alignment: 'center' })], children: [new Paragraph({ text: '时段', alignment: 'center' })],
}), })]: []),
...setItem.map((ss) => { ...setItem.map((ss) => {
return new TableCell({ return new TableCell({
borders: tableBorderOne, borders: tableBorderOne,
@ -648,7 +649,7 @@ export default class AgencyContract {
alignment: AlignmentType.CENTER, alignment: AlignmentType.CENTER,
}), }),
], ],
}) });
}), }),
...(showPSCol ...(showPSCol
? setItem.map( ? setItem.map(
@ -664,7 +665,7 @@ export default class AgencyContract {
alignment: AlignmentType.CENTER, alignment: AlignmentType.CENTER,
}), }),
], ],
}), })
) )
: []), : []),
], ],
@ -678,13 +679,14 @@ export default class AgencyContract {
withSize: false, withSize: false,
defaultUnit, defaultUnit,
withSeason: showPSCol, withSeason: showPSCol,
}), showRangeCol,
) })
);
}, []), }, []),
// //
this.createTable_Memo(1 + setItem.length * 2, remarkItem.Memo.split(`\n`)), this.createTable_Memo(1 + setItem.length * 2, remarkItem.Memo.split(`\n`)),
], ],
}) });
rt.push(subTable) rt.push(subTable)
rt.push(new Paragraph({ text: `` })) rt.push(new Paragraph({ text: `` }))
return rt return rt
@ -700,6 +702,7 @@ export default class AgencyContract {
const showPSCol = false const showPSCol = false
const defaultUnit = '1' const defaultUnit = '1'
const { dataSource, sizeSets, SSRange, PSRange } = chunkBy(use_year, dataList, chunk_By) const { dataSource, sizeSets, SSRange, PSRange } = chunkBy(use_year, dataList, chunk_By)
const showRangeCol = PSRange.length > 0;
// console.log(sizeSets, dataSource) // console.log(sizeSets, dataSource)
// //
const [remarkItem] = this.#remarkList.filter((i) => i.product_type_id == 'D') const [remarkItem] = this.#remarkList.filter((i) => i.product_type_id == 'D')
@ -716,6 +719,7 @@ export default class AgencyContract {
new TableRow({ new TableRow({
children: [ children: [
tableHeader('项目', 20), tableHeader('项目', 20),
...(showRangeCol ? [tableHeader('', 15)] : []),
tableHeader([...SSRange], 40, { columnSpan: setItem.length }), tableHeader([...SSRange], 40, { columnSpan: setItem.length }),
showPSCol showPSCol
? tableHeader(['旺季', ...PSRange], 40, { ? tableHeader(['旺季', ...PSRange], 40, {
@ -731,6 +735,11 @@ export default class AgencyContract {
verticalAlign: AlignmentType.CENTER, verticalAlign: AlignmentType.CENTER,
children: [new Paragraph({ text: '' })], children: [new Paragraph({ text: '' })],
}), }),
...(showRangeCol ? [new TableCell({
borders: tableBorderOne,
verticalAlign: AlignmentType.CENTER,
children: [new Paragraph({ text: '时段', alignment: 'center' })],
})]: []),
...setItem.map( ...setItem.map(
(ss) => (ss) =>
new TableCell({ new TableCell({
@ -768,10 +777,11 @@ export default class AgencyContract {
.reduce( .reduce(
(acc, row, ri) => (acc, row, ri) =>
acc.concat( acc.concat(
this.createDetailRowSize_D(setItem, row, ri, { this.createDetailRowSize_J(setItem, row, ri, {
withSize: false, withSize: false,
defaultUnit, defaultUnit,
withSeason: showPSCol, withSeason: showPSCol,
showRangeCol,
}), }),
), ),
[], [],
@ -850,7 +860,7 @@ export default class AgencyContract {
const thisE = new Paragraph({ const thisE = new Paragraph({
children: [ children: [
new TextRun({ new TextRun({
text: `${extra.info.city_name}-${extra.info.product_title}-${extra.info.product_type_name}`, text: `${extra.info.product_title}-${extra.info.product_type_name}`,
bold: true, bold: true,
}), }),
], ],
@ -1086,7 +1096,7 @@ export default class AgencyContract {
sizeSets, sizeSets,
rowp, rowp,
ii, ii,
{ withSeason = false, withSize = true, infoCol = () => {}, extraCol = () => {}, defaultUnit = '0' } = {}, { withSeason = false, withSize = true, showRangeCol=true, infoCol = () => {}, extraCol = () => {}, defaultUnit = '0' } = {},
) { ) {
const sizeCol = sizeSets.map((ss) => ss.join('-')) const sizeCol = sizeSets.map((ss) => ss.join('-'))
@ -1137,13 +1147,13 @@ export default class AgencyContract {
children: [ children: [
new Paragraph({ new Paragraph({
text: index == 0 ? `${rowp?.info?.product_title}` : '', text: index == 0 ? `${rowp?.info?.product_title}` : '',
alignment: AlignmentType.CENTER, alignment: AlignmentType.LEFT,
}), }),
], ],
}), }),
] ]
: []), : []),
new TableCell({ ...(showRangeCol ? [new TableCell({
borders: tableBorderOne, borders: tableBorderOne,
verticalAlign: AlignmentType.CENTER, verticalAlign: AlignmentType.CENTER,
children: [ children: [
@ -1152,7 +1162,7 @@ export default class AgencyContract {
alignment: AlignmentType.CENTER, alignment: AlignmentType.CENTER,
}), }),
], ],
}), })] : []),
infoCol(rowp), infoCol(rowp),
...arr.map((quoteItem) => { ...arr.map((quoteItem) => {
return new TableCell({ return new TableCell({
@ -1209,6 +1219,21 @@ export default class AgencyContract {
) { ) {
const sizeCol = sizeSets.map((ss) => ss.join('-')) const sizeCol = sizeSets.map((ss) => ss.join('-'))
const ranges = rowp['quotation'].map((i) =>
Object.assign(i, {
range: ((quote_season) => {
const range = `${dayjs(i.use_dates_start).format('M-D').replace(/-/gi, '.')}-${dayjs(i.use_dates_end)
.format('M-D')
.replace(/-/gi, '.')}`
if (quote_season == 'SS') return `平季(除特殊时段以外)`
else return `特殊时段(${range}`
})(i.quote_season),
}),
)
//()
const product_rows = [...new Map(ranges.map((item) => [item.range, item])).values()]
// //
const firstDayOfYear = dayjs().startOf('year').format('YYYY-MM-DD') const firstDayOfYear = dayjs().startOf('year').format('YYYY-MM-DD')
const lastDayOfYear = dayjs().endOf('year').format('YYYY-MM-DD') const lastDayOfYear = dayjs().endOf('year').format('YYYY-MM-DD')
@ -1237,7 +1262,7 @@ export default class AgencyContract {
...subItems.reduce((acc, quoteItem, index) => { ...subItems.reduce((acc, quoteItem, index) => {
const start = dayjs(quoteItem.use_dates_start).format('M-D').replace('-', '.') const start = dayjs(quoteItem.use_dates_start).format('M-D').replace('-', '.')
const end = dayjs(quoteItem.use_dates_end).format('M-D').replace('-', '.') const end = dayjs(quoteItem.use_dates_end).format('M-D').replace('-', '.')
const year = dayjs(quoteItem.use_dates_start).year()
return acc.concat( return acc.concat(
...[ ...[
new Paragraph({ new Paragraph({
@ -1248,7 +1273,7 @@ export default class AgencyContract {
? `${quoteItem.group_size_min}-${quoteItem.group_size_max}人,${quoteItem.unit_name}, ${quoteItem.adult_cost}` ? `${quoteItem.group_size_min}-${quoteItem.group_size_max}人,${quoteItem.unit_name}, ${quoteItem.adult_cost}`
: `${quoteItem.adult_cost}`, : `${quoteItem.adult_cost}`,
}), }),
...(quoteItem.use_dates_start != firstDayOfYear && quoteItem.use_dates_end != lastDayOfYear ...( !isFullYearOrLonger(year, quoteItem.use_dates_start, quoteItem.use_dates_end)
? [ ? [
new Paragraph({ new Paragraph({
alignment: AlignmentType.CENTER, alignment: AlignmentType.CENTER,
@ -1362,7 +1387,7 @@ export default class AgencyContract {
} }
createDetailRowSeason2(rowp, ii, { withSize = true, defaultUnit = '0', extraCol = () => {} } = {}) { createDetailRowSeason2(rowp, ii, { withSize = true, defaultUnit = '0', extraCol = () => {} } = {}) {
console.log(rowp); // console.log(rowp);
return [ return [
new TableRow({ new TableRow({
children: [ children: [
@ -1384,11 +1409,11 @@ export default class AgencyContract {
verticalAlign: AlignmentType.CENTER, verticalAlign: AlignmentType.CENTER,
children: [ children: [
...(rowp.quote_chunk['SS'] || []).map( ...(rowp.quote_chunk['SS'] || []).map(
(quoteItem, ii) => (quoteItem, ii, _arr) =>
new Paragraph({ new Paragraph({
alignment: AlignmentType.CENTER, alignment: AlignmentType.CENTER,
text: text:
(withSize && String(quoteItem.unit_id) !== defaultUnit (withSize && (String(quoteItem.unit_id) !== defaultUnit || _arr.length > 1)
? `${quoteItem.group_size_min}-${quoteItem.group_size_max}人,${quoteItem.unit_name},` ? `${quoteItem.group_size_min}-${quoteItem.group_size_max}人,${quoteItem.unit_name},`
: '') + `${quoteItem.adult_cost}`, : '') + `${quoteItem.adult_cost}`,
}), }),

Loading…
Cancel
Save