feat: 产品管理: 预览: 按[单位, 人等]拆分表格 [D J B R 8]

main
Lei OT 1 month ago
parent 36ec3f6e3b
commit 16aa7971f3

@ -152,7 +152,10 @@ export const chunkBy = (use_year, dataList = [], by = []) => {
const chunkSS = structuredClone(dataRollSS).map((rowp) => { const chunkSS = structuredClone(dataRollSS).map((rowp) => {
const pkey = (PGroupSizeSS[rowp.info.id] || []).join(',') || compactSizeSets.SSsizeSetKey[0]; // todo: const pkey = (PGroupSizeSS[rowp.info.id] || []).join(',') || compactSizeSets.SSsizeSetKey[0]; // todo:
let unitCnt = { '0': 0, '1': 0 }; // ? todo: 以平季的为准
const _quotation = rowp.quotation.map((quoteItem) => { const _quotation = rowp.quotation.map((quoteItem) => {
unitCnt[quoteItem.unit_id]++;
quoteItem.quote_size = pkey; quoteItem.quote_size = pkey;
quoteItem.quote_col_key = formatGroupSize(quoteItem.group_size_min, quoteItem.group_size_max); 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_start = quoteItem.use_dates_start.replace(/-/g, '.');
@ -195,8 +198,10 @@ export const chunkBy = (use_year, dataList = [], by = []) => {
return { return {
...rowp, ...rowp,
_quotationTransposeBySize, unitCnt,
unitSet: Object.keys(unitCnt).reduce((a, b) => unitCnt[a] > unitCnt[b] ? a : b),
sizeSetsSS: pkey, sizeSetsSS: pkey,
_quotationTransposeBySize,
quotation: _quotation, quotation: _quotation,
quote_chunk, quote_chunk,
}; };
@ -211,7 +216,7 @@ export const chunkBy = (use_year, dataList = [], by = []) => {
return { return {
chunk: chunkSS, chunk: chunkSS,
dataSource: chunkSS, // dataSource: chunkSS,
SSRange, SSRange,
PSRange, PSRange,
...compactSizeSets, // { SSsizeSetKey, sizeSets } ...compactSizeSets, // { SSsizeSetKey, sizeSets }
@ -219,30 +224,32 @@ export const chunkBy = (use_year, dataList = [], by = []) => {
}; };
/** /**
* 人等拆分表格 * [单位, 人等]拆分表格
* @use D J B R 8 * @use D J B R 8
*/ */
export const splitTable_SizeSets = (chunkData) => { export const splitTable_SizeSets = (chunkData) => {
const { SSRange, PSRange, SSsizeSetKey, SSsizeSetsMap, chunk } = chunkData; const { SSRange, PSRange, SSsizeSetKey, SSsizeSetsMap, chunk } = chunkData;
const bySizeSetKey = groupBy(chunk, 'sizeSetsSS'); // next: city // console.log('---- chunk', chunk);
const bySizeUnitSetKey = groupBy(chunk, pitem => ['unitSet', 'sizeSetsSS', ].map((key) => pitem[key]).join('@'));
// agencyProducts.J. // agencyProducts.J.
// console.log('bySizeSetKey', bySizeSetKey); // console.log('bySizeSetKey', bySizeUnitSetKey);
const tables = Object.keys(bySizeSetKey).map((sizeSetsStr) => { const tables = Object.keys(bySizeUnitSetKey).map((sizeSetsUnitStr) => {
const _thisSSsetProducts = bySizeSetKey[sizeSetsStr]; const [unitSet, sizeSetsStr] = sizeSetsUnitStr.split('@');
const _subTable = _thisSSsetProducts.map(({ info, sizeSetsSS, _quotationTransposeBySize, ...pitem }) => { const _thisSSsetProducts = bySizeUnitSetKey[sizeSetsUnitStr];
const _subTable = _thisSSsetProducts.map(({ info, sizeSetsSS, _quotationTransposeBySize, unitSet, ...pitem }) => {
const transpose = _quotationTransposeBySize['#'][sizeSetsSS]; const transpose = _quotationTransposeBySize['#'][sizeSetsSS];
const _pRow = transpose.map((quote, qi) => ({ ...quote, rowSpan: qi === 0 ? transpose.length : 0 })); const _pRow = transpose.map((quote, qi) => ({ ...quote, rowSpan: qi === 0 ? transpose.length : 0 }));
return { info, sizeSetsSS, rows: _pRow, transpose }; return { info, sizeSetsSS, unitSet, rows: _pRow, transpose };
}); });
return { cols: SSsizeSetsMap[sizeSetsStr], colsKey: sizeSetsStr, data: _subTable }; return { cols: SSsizeSetsMap[sizeSetsStr], colsKey: sizeSetsStr, unitSet, sizeSetsUnitStr, data: _subTable };
}); });
// console.log('---- tables', tables); // console.log('---- tables', tables);
const tablesQuote = tables.map(({ cols, colsKey, data }, ti) => { const tablesQuote = tables.map(({ cols, colsKey, unitSet, sizeSetsUnitStr, data }, ti) => {
const _table = data.reduce((acc, prow) => { const _table = data.reduce((acc, prow) => {
const prows = prow.rows.map((_q) => ({ ..._q, info: prow.info, dateText: `${_q.use_dates_start}~${_q.use_dates_end}` })); const prows = prow.rows.map((_q) => ({ ..._q, info: prow.info, dateText: `${_q.use_dates_start}~${_q.use_dates_end}` }));
return acc.concat(prows); return acc.concat(prows);
}, []); }, []);
return { cols, colsKey, data: _table }; return { cols, colsKey: sizeSetsUnitStr, data: _table }; // `${unitSet}@${colsKey}`
}); });
// console.log('---- tablesQuote', tablesQuote); // console.log('---- tablesQuote', tablesQuote);
return tablesQuote; return tablesQuote;

@ -155,7 +155,7 @@ const AgencyPreview = ({ params, ...props }) => {
rowClassName={cityRowHighlights} rowClassName={cityRowHighlights}
columns={[ columns={[
{ {
title: '超公里项目', title: '超公里项目'+` (${ti+1})`,
dataIndex: ['info', 'product_title'], dataIndex: ['info', 'product_title'],
key: 'product_title', key: 'product_title',
width: '12rem', maxWidth: '12rem', className: 'max-w-48', width: '12rem', maxWidth: '12rem', className: 'max-w-48',
@ -233,7 +233,7 @@ const AgencyPreview = ({ params, ...props }) => {
rowClassName={cityRowHighlights} rowClassName={cityRowHighlights}
columns={[ columns={[
{ {
title: '车费项目', title: '车费项目'+` (${ti+1})`,
dataIndex: ['info', 'product_title'], dataIndex: ['info', 'product_title'],
key: 'product_title', key: 'product_title',
width: '12rem', width: '12rem',
@ -290,14 +290,12 @@ const AgencyPreview = ({ params, ...props }) => {
&& r[formatGroupSize(...col)]?.unit_id !== '1'; && r[formatGroupSize(...col)]?.unit_id !== '1';
// && r[formatGroupSize(...col)]?.unit_id !== r.unit_id; // && r[formatGroupSize(...col)]?.unit_id !== r.unit_id;
return { return (
children: ( <>
<> {text}
{text} {_warning ? ` /${r[formatGroupSize(...col)].unit_name}` : ''}
{_warning ? ` /${r[formatGroupSize(...col)].unit_name}` : ''} </>
</> );
),
};
}, },
}, },
{ {
@ -318,14 +316,12 @@ const AgencyPreview = ({ params, ...props }) => {
const _warning = r.info?.isCityRow !== true && text const _warning = r.info?.isCityRow !== true && text
&& r[formatGroupSize(...col)]?.unit_id !== '1'; && r[formatGroupSize(...col)]?.unit_id !== '1';
// && r[formatGroupSize(...col)]?.unit_id !== r.unit_id; // && r[formatGroupSize(...col)]?.unit_id !== r.unit_id;
return { return (
children: (
<> <>
{text} {text}
{_warning ? ` /${r[formatGroupSize(...col)].unit_name}` : ''} {_warning ? ` /${r[formatGroupSize(...col)].unit_name}` : ''}
</> </>
), );
};
}, },
}, },
], ],
@ -343,6 +339,7 @@ const AgencyPreview = ({ params, ...props }) => {
}; };
const renderTable_D = () => { const renderTable_D = () => {
// console.clear();
// console.log('DDDDDDDDDDDDDDDDDDDDDDDDDDDDDD'); // console.log('DDDDDDDDDDDDDDDDDDDDDDDDDDDDDD');
if (!('D' in agencyProducts)) { if (!('D' in agencyProducts)) {
return null; return null;
@ -361,7 +358,7 @@ const AgencyPreview = ({ params, ...props }) => {
rowClassName={cityRowHighlights} rowClassName={cityRowHighlights}
columns={[ columns={[
{ {
title: '包价线路项目', title: '包价线路项目'+` (${ti+1})`,
dataIndex: ['info', 'product_title'], dataIndex: ['info', 'product_title'],
key: 'product_title', key: 'product_title',
width: '12rem', width: '12rem',
@ -420,14 +417,12 @@ const AgencyPreview = ({ params, ...props }) => {
const _warning = r.info?.isCityRow !== true && text const _warning = r.info?.isCityRow !== true && text
&& r[formatGroupSize(...col)]?.unit_id !== '1'; && r[formatGroupSize(...col)]?.unit_id !== '1';
// && r[formatGroupSize(...col)]?.unit_id !== r.unit_id; // && r[formatGroupSize(...col)]?.unit_id !== r.unit_id;
return { return (
children: (
<> <>
{text} {text}
{_warning ? ` /${r[formatGroupSize(...col)].unit_name}` : ''} {_warning ? ` /${r[formatGroupSize(...col)].unit_name}` : ''}
</> </>
), );
};
}, },
}, },
{ {
@ -448,14 +443,12 @@ const AgencyPreview = ({ params, ...props }) => {
const _warning = r.info?.isCityRow !== true && text const _warning = r.info?.isCityRow !== true && text
&& r[formatGroupSize(...col)]?.unit_id !== '1'; && r[formatGroupSize(...col)]?.unit_id !== '1';
// && r[formatGroupSize(...col)]?.unit_id !== r.unit_id; // && r[formatGroupSize(...col)]?.unit_id !== r.unit_id;
return { return (
children: (
<> <>
{text} {text}
{_warning ? ` /${r[formatGroupSize(...col)].unit_name}` : ''} {_warning ? ` /${r[formatGroupSize(...col)].unit_name}` : ''}
</> </>
), );
};
}, },
}, },
] ]
@ -800,7 +793,7 @@ const AgencyPreview = ({ params, ...props }) => {
rowClassName={cityRowHighlights} rowClassName={cityRowHighlights}
columns={[ columns={[
{ {
title: '餐费项目', title: '餐费项目'+` (${ti+1})`,
dataIndex: ['info', 'product_title'], dataIndex: ['info', 'product_title'],
key: 'product_title', key: 'product_title',
width: '12rem', width: '12rem',
@ -890,11 +883,13 @@ const AgencyPreview = ({ params, ...props }) => {
}; };
const renderTable_8 = () => { const renderTable_8 = () => {
// console.clear();
// console.log('888888'); // console.log('888888');
if (!('8' in agencyProducts)) { if (!('8' in agencyProducts)) {
return null; return null;
} }
const tablesQuote = splitTable_8(use_year, agencyProducts['8']); const tablesQuote = splitTable_8(use_year, agencyProducts['8']);
// console.log('---- tablesQuote ----', tablesQuote)
return ( return (
<> <>
{tablesQuote.map(({ cols, colsKey, data }, ti) => ( {tablesQuote.map(({ cols, colsKey, data }, ti) => (
@ -907,7 +902,7 @@ const AgencyPreview = ({ params, ...props }) => {
rowClassName={cityRowHighlights} rowClassName={cityRowHighlights}
columns={[ columns={[
{ {
title: '附加项目', title: '附加项目'+` (${ti+1})`,
dataIndex: ['info', 'product_title'], dataIndex: ['info', 'product_title'],
key: 'product_title', key: 'product_title',
width: '12rem', width: '12rem',
@ -915,14 +910,14 @@ const AgencyPreview = ({ params, ...props }) => {
className: 'max-w-48', className: 'max-w-48',
fixed: 'left', fixed: 'left',
onCell: (record) => { onCell: (record) => {
return { rowSpan: record.rowSpan }; return { rowSpan: record.rowSpan, };
}, },
}, },
{ {
title: '时段', title: '时段',
dataIndex: 'dateText', dataIndex: 'dateText',
key: 'dateText', key: 'dateText',
width: '5rem', width: '8rem',
fixed: 'left', fixed: 'left',
render: (_, { quote_season, use_dates_start, use_dates_end, rowSpan }) => render: (_, { quote_season, use_dates_start, use_dates_end, rowSpan }) =>
quote_season === 'SS' ? ( quote_season === 'SS' ? (
@ -952,6 +947,7 @@ const AgencyPreview = ({ params, ...props }) => {
dataIndex: [formatGroupSize(...col), 'adult_cost'], dataIndex: [formatGroupSize(...col), 'adult_cost'],
key: 'adult_cost', key: 'adult_cost',
width: '4rem', width: '4rem',
className: 'max-w-16',
onCell: (r, ) => { onCell: (r, ) => {
const text = r[formatGroupSize(...col)]?.adult_cost const text = r[formatGroupSize(...col)]?.adult_cost
const _warning = r.info?.isCityRow !== true const _warning = r.info?.isCityRow !== true
@ -973,6 +969,7 @@ const AgencyPreview = ({ params, ...props }) => {
dataIndex: [formatGroupSize(...col), 'child_cost'], dataIndex: [formatGroupSize(...col), 'child_cost'],
key: 'child_cost', key: 'child_cost',
width: '4rem', width: '4rem',
className: 'max-w-16',
onCell: (r, ) => { onCell: (r, ) => {
const text = r[formatGroupSize(...col)]?.child_cost const text = r[formatGroupSize(...col)]?.child_cost
const _warning = r.info?.isCityRow !== true const _warning = r.info?.isCityRow !== true

Loading…
Cancel
Save