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

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

Loading…
Cancel
Save