feat: 产品管理: 导出: 各类型的默认单位; +`附加项目`

main
Lei OT 1 month ago
parent 16aa7971f3
commit 785270097b

@ -356,10 +356,11 @@ export const splitTable_R = (use_year, dataSource, retTableOnly = true) => {
return retTableOnly ? tables : { ...chunked, tables }; return retTableOnly ? tables : { ...chunked, tables };
}; };
export const splitTable_8 = (use_year, dataSource) => { export const splitTable_8 = (use_year, dataSource, retTableOnly = true) => {
const chunked = chunkBy(use_year, dataSource); const chunked = chunkBy(use_year, dataSource);
// console.log(chunked); // console.log(chunked);
return addCityRow4Split(splitTable_SizeSets(chunked)); const tables = addCityRow4Split(splitTable_SizeSets(chunked));
return retTableOnly ? tables : { ...chunked, tables };
}; };
export const splitTable_6 = (use_year, dataSource, retTableOnly = true) => { export const splitTable_6 = (use_year, dataSource, retTableOnly = true) => {

@ -70,6 +70,9 @@ export const useProductsTypesMapVal = (value) => {
return stateMapVal; return stateMapVal;
}; };
/**
* 价格的审核状态
*/
export const useProductsAuditStates = () => { export const useProductsAuditStates = () => {
const [types, setTypes] = useState([]); const [types, setTypes] = useState([]);
const { t, i18n } = useTranslation(); const { t, i18n } = useTranslation();
@ -153,7 +156,7 @@ export const useNewProductRecord = () => {
'lastedit_changed': '', 'lastedit_changed': '',
'create_date': '', 'create_date': '',
'created_by': '', 'created_by': '',
'edit_status': 2, 'edit_status': 2, // 信息的审核状态 1已发布2已审核
'sort_order': '', 'sort_order': '',
'sub_type_D': '', // 包价类型, 值保存在`item_type`字段中 'sub_type_D': '', // 包价类型, 值保存在`item_type`字段中
'item_type': '', // 产品子类型的值 'item_type': '', // 产品子类型的值

@ -19,9 +19,14 @@ import {
TextRun, TextRun,
WidthType, WidthType,
} from 'docx' } from 'docx'
import { splitTable_6, splitTable_7, splitTable_B, splitTable_D, splitTable_J, splitTable_Q, splitTable_R } from '@/hooks/useProductsQuotationFormat'; import { splitTable_6, splitTable_7, splitTable_B, splitTable_D, splitTable_J, splitTable_Q, splitTable_R, splitTable_8 } from '@/hooks/useProductsQuotationFormat';
import { formatGroupSize } from '@/hooks/useProductsSets' import { formatGroupSize } from '@/hooks/useProductsSets'
const unitMap = {
'0': '人',
'1': '团',
}
const DOC_TITLE = '地接合同' const DOC_TITLE = '地接合同'
const pageMargins = { const pageMargins = {
top: `15mm`, top: `15mm`,
@ -283,7 +288,15 @@ export default class AgencyContract {
this.createSubHeading(`餐费(元/人/餐)`, { this.createSubHeading(`餐费(元/人/餐)`, {
numbering: { reference: 'products-type', level: 0 }, numbering: { reference: 'products-type', level: 0 },
}), }),
...this.createTable_R(use_year, agencyProducts['R'], agencyExtras), ...this.createTable_R(use_year, agencyProducts['R']),
]),
...(isEmpty(agencyProducts['8'])
? []
: [
this.createSubHeading(`附加项目(元/团,部分价格为元/人单独注明)`, {
numbering: { reference: 'products-type', level: 0 },
}),
...this.createTable_8(use_year, agencyProducts['8']),
]), ]),
...(isEmpty(agencyProducts['D']) ...(isEmpty(agencyProducts['D'])
? [] ? []
@ -317,6 +330,7 @@ export default class AgencyContract {
*/ */
createTable_6(use_year, dataList, style = {}) { createTable_6(use_year, dataList, style = {}) {
const { tables, SSRange } = splitTable_6(use_year, dataList, false); const { tables, SSRange } = splitTable_6(use_year, dataList, false);
const defaultUnit = '0';
const table2Rows = tables.reduce((acc, {info, SS}) => { const table2Rows = tables.reduce((acc, {info, SS}) => {
return acc.concat(SS.map((v, i) => ({...v, info, rowSpan: i===0 ? SS.length : 0}))); return acc.concat(SS.map((v, i) => ({...v, info, rowSpan: i===0 ? SS.length : 0})));
@ -370,7 +384,21 @@ export default class AgencyContract {
verticalAlign: AlignmentType.CENTER, verticalAlign: AlignmentType.CENTER,
children: [ children: [
new Paragraph({ new Paragraph({
text: `${row.adult_cost ?? ''}`, // text: `${row.adult_cost ?? ''}`,
children: [
new TextRun({
text: `${row?.adult_cost ?? ''}`,
}),
...(row?.adult_cost && row?.unit_id !== defaultUnit
? [
new TextRun({
// text: `/${row?.unit_name || ''}`,
text: `/${unitMap[row?.unit_id] || row?.unit_name || ''}`,
// break: 1,
}),
]
: []),
],
alignment: AlignmentType.CENTER, alignment: AlignmentType.CENTER,
}), }),
], ],
@ -388,7 +416,9 @@ export default class AgencyContract {
*/ */
createTable_B(use_year, dataList) { createTable_B(use_year, dataList) {
// console.log('*********************************************************************************************'); // console.log('*********************************************************************************************');
const { tables, SSRange } = splitTable_B(use_year, dataList, false); const { tables, SSRange, PSRange } = splitTable_B(use_year, dataList, false);
const defaultUnit = '0';
const showRangeCol = PSRange.length > 0;
const tableS = tables.reduce((acc, { cols, data }) => { const tableS = tables.reduce((acc, { cols, data }) => {
const subTable = new Table({ const subTable = new Table({
@ -401,8 +431,9 @@ export default class AgencyContract {
new TableRow({ new TableRow({
children: [ children: [
this.createTableHeader('超公里项目', 20), this.createTableHeader('超公里项目', 20),
this.createTableHeader('往返公里数', 20), this.createTableHeader('往返公里数', 15),
this.createTableHeader([...SSRange], 60, { ...(showRangeCol ? [this.createTableHeader('', 15)] : []),
this.createTableHeader([...SSRange], 65, {
columnSpan: cols.length, columnSpan: cols.length,
}), }),
], ],
@ -419,6 +450,15 @@ 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' })],
}),
]
: []),
...cols.map( ...cols.map(
(ss) => (ss) =>
new TableCell({ new TableCell({
@ -430,41 +470,90 @@ export default class AgencyContract {
alignment: AlignmentType.CENTER, alignment: AlignmentType.CENTER,
}), }),
], ],
}), })
), ),
], ],
}), }),
...data.map((row, ri) => new TableRow({ ...data.map(
children: [ (row, ri) =>
row.info?.isCityRow ? this.createTableHeader(row.info?.product_title || '', 20) : new TableCell({ new TableRow({
borders: tableBorderOne, children: [
verticalAlign: AlignmentType.CENTER, ...(row.rowSpan > 0
children: [new Paragraph({ text: row.info?.product_title || '' })], ? row.info?.isCityRow
}), ? [
new TableCell({ this.createTableHeader(row.info?.product_title || '', 20),
borders: tableBorderOne, new TableCell({
verticalAlign: AlignmentType.CENTER, borders: tableBorderOne,
children: [new Paragraph({ text: `${row.info?.km ?? ''}`, alignment: AlignmentType.CENTER, })], verticalAlign: AlignmentType.CENTER,
}), children: [new Paragraph({ text: '' })],
...cols.map( }),
(ss) => ]
new TableCell({ : [
borders: tableBorderOne, new TableCell({
verticalAlign: AlignmentType.CENTER, borders: tableBorderOne,
children: [ verticalAlign: AlignmentType.CENTER,
new Paragraph({ children: [new Paragraph({ text: row.info?.product_title || '' })],
text: `${row?.[formatGroupSize(...ss)]?.adult_cost ?? ''}`, rowSpan: row.rowSpan,
alignment: AlignmentType.CENTER, }),
}), new TableCell({
], borders: tableBorderOne,
}), verticalAlign: AlignmentType.CENTER,
), children: [new Paragraph({ text: `${row.info?.km ?? ''}`, alignment: AlignmentType.CENTER })],
], rowSpan: row.rowSpan,
})), }),
]
: []),
...(showRangeCol
? [
new TableCell({
borders: tableBorderOne,
verticalAlign: AlignmentType.CENTER,
children: [
...(row.quote_season === 'SS'
? 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(
(str) => new Paragraph({ text: str, alignment: AlignmentType.LEFT })
)),
],
}),
]
: []),
...cols.map(
(ss) =>
new TableCell({
borders: tableBorderOne,
verticalAlign: AlignmentType.CENTER,
children: [
new Paragraph({
// text: `${row?.[formatGroupSize(...ss)]?.adult_cost ?? ''}`,
children: [
new TextRun({
text: `${row?.[formatGroupSize(...ss)]?.adult_cost ?? ''}`,
}),
...(row?.[formatGroupSize(...ss)]?.adult_cost && row?.[formatGroupSize(...ss)]?.unit_id !== defaultUnit
? [
new TextRun({
// text: `/${row?.[formatGroupSize(...ss)]?.unit_name || ''}`,
text: `/${unitMap[row?.[formatGroupSize(...ss)]?.unit_id] || row?.[formatGroupSize(...ss)]?.unit_name || ''}`,
break: 1,
}),
]
: []),
],
alignment: AlignmentType.CENTER,
}),
],
})
),
],
})
),
this.createTable_Memo(2 + cols.length, this.#remarkList['B'].Memo.split(`\n`)), this.createTable_Memo(2 + cols.length + (showRangeCol ? 1 : 0), this.#remarkList['B'].Memo.split(`\n`)),
], ],
}) });
acc.push(subTable); acc.push(subTable);
acc.push(new Paragraph({ text: `` })) // acc.push(new Paragraph({ text: `` })) //
return acc return acc
@ -477,7 +566,7 @@ export default class AgencyContract {
*/ */
createTable_J(use_year, dataList) { createTable_J(use_year, dataList) {
const { tables, SSRange, PSRange, } = splitTable_J(use_year, dataList, false); const { tables, SSRange, PSRange, } = splitTable_J(use_year, dataList, false);
// const defaultUnit = '1' const defaultUnit = '1'
const showRangeCol = PSRange.length > 0; const showRangeCol = PSRange.length > 0;
const tableS = tables.reduce((acc, { cols, data }) => { const tableS = tables.reduce((acc, { cols, data }) => {
@ -564,7 +653,21 @@ export default class AgencyContract {
verticalAlign: AlignmentType.CENTER, verticalAlign: AlignmentType.CENTER,
children: [ children: [
new Paragraph({ new Paragraph({
text: `${row?.[formatGroupSize(...ss)]?.adult_cost ?? ''}`, // text: `${row?.[formatGroupSize(...ss)]?.adult_cost ?? ''}`,
children: [
new TextRun({
text: `${row?.[formatGroupSize(...ss)]?.adult_cost ?? ''}`,
}),
...(row?.[formatGroupSize(...ss)]?.adult_cost && row?.[formatGroupSize(...ss)]?.unit_id !== defaultUnit
? [
new TextRun({
// text: `/${row?.[formatGroupSize(...ss)]?.unit_name || ''}`,
text: `/${unitMap[row?.[formatGroupSize(...ss)]?.unit_id] || row?.[formatGroupSize(...ss)]?.unit_name || ''}`,
break: 1,
}),
]
: []),
],
alignment: AlignmentType.CENTER, alignment: AlignmentType.CENTER,
}), }),
], ],
@ -591,7 +694,7 @@ export default class AgencyContract {
const { tables, SSRange, PSRange } = splitTable_D(use_year, dataList, false); const { tables, SSRange, PSRange } = splitTable_D(use_year, dataList, false);
// console.log('DDDD', tables, SSRange, PSRange); // console.log('DDDD', tables, SSRange, PSRange);
// const defaultUnit = '1' const defaultUnit = '1'
const showRangeCol = PSRange.length > 0; // const showRangeCol = PSRange.length > 0; //
// console.log(sizeSets, dataSource) // console.log(sizeSets, dataSource)
@ -681,7 +784,28 @@ export default class AgencyContract {
verticalAlign: AlignmentType.CENTER, verticalAlign: AlignmentType.CENTER,
children: [ children: [
new Paragraph({ new Paragraph({
text: `${row?.[formatGroupSize(...ss)]?.adult_cost ?? ''}`, // text: row?.[formatGroupSize(...ss)]?.adult_cost
// ? `${row?.[formatGroupSize(...ss)]?.adult_cost ?? ''}` +
// (row.info?.isCityRow !== true && // && text
// row?.[formatGroupSize(...ss)]?.unit_id !== defaultUnit
// ? // ? ` /${row?.[formatGroupSize(...ss)]?.unit_name || ''}`
// ` /${unitMap[row?.[formatGroupSize(...ss)]?.unit_id] || ''}`
// : '')
// : '',
children: [
new TextRun({
text: `${row?.[formatGroupSize(...ss)]?.adult_cost ?? ''}`,
}),
...(row?.[formatGroupSize(...ss)]?.adult_cost && row?.[formatGroupSize(...ss)]?.unit_id !== defaultUnit
? [
new TextRun({
// text: `/${row?.[formatGroupSize(...ss)]?.unit_name || ''}`,
text: `/${unitMap[row?.[formatGroupSize(...ss)]?.unit_id] || row?.[formatGroupSize(...ss)]?.unit_name || ''}`,
break: 1,
}),
]
: []),
],
alignment: AlignmentType.CENTER, alignment: AlignmentType.CENTER,
}), }),
], ],
@ -706,6 +830,7 @@ export default class AgencyContract {
*/ */
createTable_Q(use_year, dataList) { createTable_Q(use_year, dataList) {
const tables = splitTable_Q(use_year, dataList, false); const tables = splitTable_Q(use_year, dataList, false);
const defaultUnit = '1'
// console.log('QQQ', tables); // console.log('QQQ', tables);
return new Table({ return new Table({
@ -738,7 +863,24 @@ export default class AgencyContract {
verticalAlign: AlignmentType.CENTER, verticalAlign: AlignmentType.CENTER,
children: children:
(row?.SS || []).length <= 1 (row?.SS || []).length <= 1
? [new Paragraph({ text: `${row?.SS?.[0]?.adult_cost ?? ''}`, alignment: AlignmentType.CENTER })] ? [new Paragraph({
// text: `${row?.SS?.[0]?.adult_cost ?? ''}`,
children: [
new TextRun({
text: `${row?.SS?.[0]?.adult_cost ?? ''}`,
}),
...(row?.SS?.[0].adult_cost && row?.SS?.[0]?.unit_id !== defaultUnit
? [
new TextRun({
// text: `/${row?.[formatGroupSize(...ss)]?.unit_name || ''}`,
text: `/${unitMap[row?.SS?.[0]?.unit_id] || row?.SS?.[0]?.unit_name || ''}`,
// break: 1,
}),
]
: []),
],
alignment: AlignmentType.CENTER
})]
: [ : [
new Table({ new Table({
borders: tableBorderNone, borders: tableBorderNone,
@ -764,6 +906,7 @@ export default class AgencyContract {
}), }),
new TableCell({ new TableCell({
borders: ii !== _arr.length - 1 ? tableBorderInner : tableBorderInnerR, borders: ii !== _arr.length - 1 ? tableBorderInner : tableBorderInnerR,
width: { size: 1200, type: WidthType.DXA },
verticalAlign: AlignmentType.CENTER, verticalAlign: AlignmentType.CENTER,
children: [ children: [
new Paragraph({ new Paragraph({
@ -808,7 +951,8 @@ export default class AgencyContract {
children: [ children: [
new TableCell({ new TableCell({
borders: ii !== _arr.length - 1 ? tableBorderInner : tableBorderInnerR, borders: ii !== _arr.length - 1 ? tableBorderInner : tableBorderInnerR,
width: { size: 2400, type: WidthType.DXA }, // width: { size: 1800, type: WidthType.DXA },
width: { size: 60, type: WidthType.PERCENTAGE },
verticalAlign: AlignmentType.CENTER, 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}.`, '')}` })),
}), }),
@ -817,8 +961,22 @@ export default class AgencyContract {
verticalAlign: AlignmentType.CENTER, verticalAlign: AlignmentType.CENTER,
children: [ children: [
new Paragraph({ new Paragraph({
text: `${quoteItem.adult_cost}`, // text: `${quoteItem.adult_cost}`,
alignment: AlignmentType.LEFT, children: [
new TextRun({
text: `${quoteItem.adult_cost ?? ''}`,
}),
...(quoteItem.adult_cost && quoteItem?.unit_id !== defaultUnit
? [
new TextRun({
// text: `/${row?.[formatGroupSize(...ss)]?.unit_name || ''}`,
text: `/${unitMap[quoteItem?.unit_id] || quoteItem?.unit_name || ''}`,
// break: 1,
}),
]
: []),
],
alignment: AlignmentType.CENTER,
}), }),
], ],
}), }),
@ -841,6 +999,7 @@ export default class AgencyContract {
*/ */
createTable_7(use_year, dataList, agencyExtras) { createTable_7(use_year, dataList, agencyExtras) {
const tables = splitTable_7(use_year, dataList, false); const tables = splitTable_7(use_year, dataList, false);
const defaultUnit = '0';
return new Table({ return new Table({
borders: tableBorderNone, borders: tableBorderNone,
@ -874,7 +1033,7 @@ export default class AgencyContract {
children: children:
(row?.SS || []).length === 0 (row?.SS || []).length === 0
? [new Paragraph({ text: '', alignment: AlignmentType.CENTER })] ? [new Paragraph({ text: '', alignment: AlignmentType.CENTER })]
: (row?.SS || []).length === 1 && row?.SS?.[0]?.unit_id === '0' : (row?.SS || []).length === 1 && row?.SS?.[0]?.unit_id === defaultUnit
? [new Paragraph({ text: `${row?.SS?.[0]?.adult_cost ?? ''}`, alignment: AlignmentType.CENTER })] ? [new Paragraph({ text: `${row?.SS?.[0]?.adult_cost ?? ''}`, alignment: AlignmentType.CENTER })]
: [ : [
new Table({ new Table({
@ -917,7 +1076,7 @@ export default class AgencyContract {
children: [ children: [
new Paragraph({ new Paragraph({
text: `${quoteItem.adult_cost}`, text: `${quoteItem.adult_cost}`,
alignment: AlignmentType.LEFT, alignment: AlignmentType.CENTER,
}), }),
], ],
}), }),
@ -1015,7 +1174,7 @@ export default class AgencyContract {
new Paragraph({ new Paragraph({
children: [ children: [
new TextRun({ new TextRun({
text: `${extra.info.product_title}-${extra.info.product_type_name}`, text: `${extra.info.product_title}-${extra.info.product_type_name_txt}`,
bold: true, bold: true,
}), }),
], ],
@ -1034,8 +1193,9 @@ export default class AgencyContract {
/** /**
* 餐费 * 餐费
*/ */
createTable_R(use_year, dataList, agencyExtras) { createTable_R(use_year, dataList) {
const { tables, SSRange, PSRange } = splitTable_R(use_year, dataList, false); const { tables, SSRange, PSRange } = splitTable_R(use_year, dataList, false);
const defaultUnit = '0';
// console.log('RRRRRR', tables); // console.log('RRRRRR', tables);
const tableS = tables.reduce((acc, { cols, data }) => { const tableS = tables.reduce((acc, { cols, data }) => {
@ -1101,7 +1261,21 @@ export default class AgencyContract {
verticalAlign: AlignmentType.CENTER, verticalAlign: AlignmentType.CENTER,
children: [ children: [
new Paragraph({ new Paragraph({
text: `${row?.[formatGroupSize(...ss)]?.adult_cost ?? ''}`, // text: `${row?.[formatGroupSize(...ss)]?.adult_cost ?? ''}`,
children: [
new TextRun({
text: `${row?.[formatGroupSize(...ss)]?.adult_cost ?? ''}`,
}),
...(row?.[formatGroupSize(...ss)]?.adult_cost && row?.[formatGroupSize(...ss)]?.unit_id !== defaultUnit
? [
new TextRun({
// text: `/${row?.[formatGroupSize(...ss)]?.unit_name || ''}`,
text: `/${unitMap[row?.[formatGroupSize(...ss)]?.unit_id] || row?.[formatGroupSize(...ss)]?.unit_name || ''}`,
break: 1,
}),
]
: []),
],
alignment: AlignmentType.CENTER, alignment: AlignmentType.CENTER,
}), }),
], ],
@ -1121,6 +1295,131 @@ export default class AgencyContract {
return tableS return tableS
} }
/**
* 附加项目
*/
createTable_8(use_year, dataList) {
const { tables, SSRange, PSRange, } = splitTable_8(use_year, dataList, false);
const defaultUnit = '1'
const showRangeCol = PSRange.length > 0;
const tableS = tables.reduce((acc, { cols, data }) => {
const subTable = new Table({
borders: tableBorderNone,
width: {
size: 100,
type: WidthType.PERCENTAGE,
},
rows: [
new TableRow({
children: [
this.createTableHeader('附加项目', 20),
...(showRangeCol ? [this.createTableHeader('', 15)] : []),
this.createTableHeader([...SSRange], 65, { columnSpan: cols.length }),
],
}),
//
new TableRow({
children: [
new TableCell({
borders: tableBorderOne,
verticalAlign: AlignmentType.CENTER,
children: [new Paragraph({ text: '' })],
}),
...(showRangeCol ? [new TableCell({
borders: tableBorderOne,
verticalAlign: AlignmentType.CENTER,
children: [new Paragraph({ text: '时段', alignment: 'center' })],
})]: []),
...cols.map((ss) => {
return new TableCell({
borders: tableBorderOne,
verticalAlign: AlignmentType.CENTER,
width: { size: 2000, type: WidthType.DXA },
children: [
new Paragraph({
text: formatGroupSize(...ss, true),
alignment: AlignmentType.CENTER,
}),
],
});
}),
],
}),
//
...data.map(
(row, ri) =>
new TableRow({
children: [
...(row.rowSpan > 0
? [
row.info?.isCityRow
? this.createTableHeader(row.info?.product_title || '', 20)
: new TableCell({
borders: tableBorderOne,
verticalAlign: AlignmentType.CENTER,
children: [new Paragraph({ text: row.info?.product_title || '' })],
rowSpan: row.rowSpan,
}),
]
: []),
...(showRangeCol
? [
new TableCell({
borders: tableBorderOne,
verticalAlign: AlignmentType.CENTER,
children: [
...(row.quote_season === 'SS'
? 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(
(str) => new Paragraph({ text: str, alignment: AlignmentType.LEFT })
)),
],
}),
]
: []),
...cols.map(
(ss) =>
new TableCell({
borders: tableBorderOne,
verticalAlign: AlignmentType.CENTER,
children: [
new Paragraph({
// text: `${row?.[formatGroupSize(...ss)]?.adult_cost ?? ''}`,
children: [
new TextRun({
text: `${row?.[formatGroupSize(...ss)]?.adult_cost ?? ''}`,
}),
...(row?.[formatGroupSize(...ss)]?.adult_cost && row?.[formatGroupSize(...ss)]?.unit_id !== defaultUnit
? [
new TextRun({
// text: `/${row?.[formatGroupSize(...ss)]?.unit_name || ''}`,
text: `/${unitMap[row?.[formatGroupSize(...ss)]?.unit_id] || row?.[formatGroupSize(...ss)]?.unit_name || ''}`,
break: 1,
}),
]
: []),
],
alignment: AlignmentType.CENTER,
}),
],
})
),
],
})
),
//
this.createTable_Memo(1 + cols.length + (showRangeCol ? 1 : 0), (this.#remarkList?.['8']?.Memo || '').split(`\n`)),
],
});
acc.push(subTable)
acc.push(new Paragraph({ text: `` }))
return acc
}, [])
return tableS
}
createTable_Memo(columnSpan, remarkContent = []) { createTable_Memo(columnSpan, remarkContent = []) {
return new TableRow({ return new TableRow({
children: [ children: [

@ -3,7 +3,7 @@ import { useParams, Link } from 'react-router-dom';
import { Button, Drawer, Card, Table } from 'antd'; import { Button, Drawer, Card, Table } from 'antd';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import useProductsStore, { getAgencyAllExtrasAction } from '@/stores/Products/Index'; import useProductsStore, { getAgencyAllExtrasAction } from '@/stores/Products/Index';
import { useProductsTypes, formatGroupSize } from '@/hooks/useProductsSets'; import { useProductsTypes, formatGroupSize, useProductsTypesMapVal } from '@/hooks/useProductsSets';
import { chunkBy, splitTable_6, splitTable_7, splitTable_8, splitTable_B, splitTable_D, splitTable_J, splitTable_Q, splitTable_R } from '@/hooks/useProductsQuotationFormat'; import { chunkBy, splitTable_6, splitTable_7, splitTable_8, splitTable_B, splitTable_D, splitTable_J, splitTable_Q, splitTable_R } from '@/hooks/useProductsQuotationFormat';
import { groupBy, isNotEmpty } from '@/utils/commons'; import { groupBy, isNotEmpty } from '@/utils/commons';
import useAuthStore from '@/stores/Auth'; import useAuthStore from '@/stores/Auth';
@ -20,6 +20,8 @@ const AgencyPreview = ({ params, ...props }) => {
const [agencyProducts] = useProductsStore((state) => [state.agencyProducts]); const [agencyProducts] = useProductsStore((state) => [state.agencyProducts]);
const [setEditingProduct] = useProductsStore((state) => [state.setEditingProduct]); const [setEditingProduct] = useProductsStore((state) => [state.setEditingProduct]);
const productsTypesMapVal = useProductsTypesMapVal();
const [previewMode, setPreviewMode] = useState(false); const [previewMode, setPreviewMode] = useState(false);
const [tables, setTables] = useState([]); const [tables, setTables] = useState([]);
const [extras, setExtras] = useState([]); const [extras, setExtras] = useState([]);
@ -121,14 +123,68 @@ const AgencyPreview = ({ params, ...props }) => {
render: (_, r) => <div>{formatGroupSize(r.group_size_min, r.group_size_max, true)}</div>, render: (_, r) => <div>{formatGroupSize(r.group_size_min, r.group_size_max, true)}</div>,
}, },
{ {
title: <>{SSRange.map(v => <div key={v}>{v}</div>)}</>, title: (
<>
{SSRange.map((v) => (
<div key={v}>{v}</div>
))}
</>
),
dataIndex: 'SS', dataIndex: 'SS',
key: 'SS', key: 'SS',
width: '9rem', width: '9rem',
align: 'center', align: 'center',
children: [ children: [
{ title: '成人', dataIndex: ['adult_cost'], key: 'adult_cost', width: '9rem', align: 'center', }, {
{ title: '儿童', dataIndex: ['child_cost'], key: 'child_cost', width: '9rem', align: 'center', }, title: '成人',
dataIndex: ['adult_cost'],
key: 'adult_cost',
width: '9rem',
align: 'center',
onCell: (r) => {
const text = r?.adult_cost;
const _warning = r.info?.isCityRow !== true && text && r?.unit_id !== '0';
return { className: _warning ? 'bg-yellow-100' : '' };
},
render: (text, r) => {
const _warning = r.info?.isCityRow !== true && text
&& r?.unit_id !== '0';
// && r?.unit_id !== r.unit_id;
return (
<>
{text}
{_warning ? ` /${r.unit_name}` : ''}
</>
);
},
},
{
title: '儿童',
dataIndex: ['child_cost'],
key: 'child_cost',
width: '9rem',
align: 'center',
onCell: (r) => {
const text = r?.adult_cost;
const _warning = r.info?.isCityRow !== true && text && r?.unit_id !== '0';
return { className: _warning ? 'bg-yellow-100' : '' };
},
render: (text, r) => {
const _warning = r.info?.isCityRow !== true && text
&& r?.unit_id !== '0';
// && r?.unit_id !== r.unit_id;
return (
<>
{text}
{_warning ? ` /${r.unit_name}` : ''}
</>
);
},
},
], ],
}, },
]} ]}
@ -143,6 +199,7 @@ const AgencyPreview = ({ params, ...props }) => {
return null; return null;
} }
const tablesQuote = splitTable_B(use_year, agencyProducts.B); const tablesQuote = splitTable_B(use_year, agencyProducts.B);
// console.log(tablesQuote)
return ( return (
<> <>
{tablesQuote.map(({ cols, colsKey, data }, ti) => ( {tablesQuote.map(({ cols, colsKey, data }, ti) => (
@ -155,10 +212,12 @@ const AgencyPreview = ({ params, ...props }) => {
rowClassName={cityRowHighlights} rowClassName={cityRowHighlights}
columns={[ columns={[
{ {
title: '超公里项目'+` (${ti+1})`, 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',
fixed: 'left', fixed: 'left',
onCell: (record) => { onCell: (record) => {
return { rowSpan: record.rowSpan }; return { rowSpan: record.rowSpan };
@ -168,7 +227,9 @@ const AgencyPreview = ({ params, ...props }) => {
title: '往返公里数', title: '往返公里数',
dataIndex: ['info', 'km'], dataIndex: ['info', 'km'],
key: 'product_title', key: 'product_title',
width: '6rem', maxWidth: '6rem', className: 'max-w-4', width: '6rem',
maxWidth: '6rem',
className: 'max-w-4',
onCell: (record) => { onCell: (record) => {
return { rowSpan: record.rowSpan }; return { rowSpan: record.rowSpan };
}, },
@ -180,11 +241,15 @@ const AgencyPreview = ({ params, ...props }) => {
width: '5rem', width: '5rem',
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' ? (rowSpan > 1 ? ( quote_season === 'SS' ? (
<div> rowSpan > 1 ? (
平季<div>(除特殊时段外)</div> <div>
</div> 平季<div>(除特殊时段外)</div>
) : '') : ( </div>
) : (
''
)
) : (
<div> <div>
特殊时段 特殊时段
<div> <div>
@ -198,8 +263,54 @@ const AgencyPreview = ({ params, ...props }) => {
// dataIndex: [formatGroupSize(...col), 'adult_cost'], // dataIndex: [formatGroupSize(...col), 'adult_cost'],
key: col[0], key: col[0],
children: [ children: [
{ title: '成人', dataIndex: [formatGroupSize(...col), 'adult_cost'], key: 'adult_cost', width: '4rem' }, {
{ title: '儿童', dataIndex: [formatGroupSize(...col), 'child_cost'], key: 'child_cost', width: '4rem' }, title: '成人',
dataIndex: [formatGroupSize(...col), 'adult_cost'],
key: 'adult_cost',
width: '4rem',
onCell: (r) => {
const text = r[formatGroupSize(...col)]?.adult_cost;
const _warning = r.info?.isCityRow !== true && text && r[formatGroupSize(...col)]?.unit_id !== '0';
return { className: _warning ? 'bg-yellow-100' : '' };
},
render: (text, r) => {
const _warning = r.info?.isCityRow !== true && text
&& r[formatGroupSize(...col)]?.unit_id !== '0';
// && r[formatGroupSize(...col)]?.unit_id !== r.unit_id;
return (
<>
{text}
{_warning ? ` /${r[formatGroupSize(...col)].unit_name}` : ''}
</>
);
},
},
{
title: '儿童',
dataIndex: [formatGroupSize(...col), 'child_cost'],
key: 'child_cost',
width: '4rem',
onCell: (r) => {
const text = r[formatGroupSize(...col)]?.child_cost;
const _warning = r.info?.isCityRow !== true && text && r[formatGroupSize(...col)]?.unit_id !== '0';
return { className: _warning ? 'bg-yellow-100' : '' };
},
render: (text, r) => {
const _warning = r.info?.isCityRow !== true && text
&& r[formatGroupSize(...col)]?.unit_id !== '0';
// && r[formatGroupSize(...col)]?.unit_id !== r.unit_id;
return (
<>
{text}
{_warning ? ` /${r[formatGroupSize(...col)].unit_name}` : ''}
</>
);
},
},
], ],
})), })),
]} ]}
@ -465,6 +576,9 @@ const AgencyPreview = ({ params, ...props }) => {
); );
}; };
/**
* 导游
*/
const renderTable_Q = () => { const renderTable_Q = () => {
// console.log('QQQQQQ'); // console.log('QQQQQQ');
if (!('Q' in agencyProducts)) { if (!('Q' in agencyProducts)) {
@ -637,6 +751,9 @@ const AgencyPreview = ({ params, ...props }) => {
); );
}; };
/**
* 景点
*/
const renderTable_7 = () => { const renderTable_7 = () => {
// console.log('7777777777777'); // console.log('7777777777777');
if (!('7' in agencyProducts)) { if (!('7' in agencyProducts)) {
@ -762,7 +879,7 @@ const AgencyPreview = ({ params, ...props }) => {
<div> <div>
{_extras.map((e) => ( {_extras.map((e) => (
<div key={e.info.id}> <div key={e.info.id}>
{e.info.product_title}{e.info.product_type_name} {e.info.product_title}{productsTypesMapVal[e.info.product_type_id]?.label || (e.info.product_type_name)}
</div> </div>
))} ))}
</div> </div>
@ -844,6 +961,18 @@ const AgencyPreview = ({ params, ...props }) => {
return { className: _warning ? 'bg-yellow-100' : '' }; return { className: _warning ? 'bg-yellow-100' : '' };
}, },
render: (text, r) => {
const _warning = r.info?.isCityRow !== true && text
&& r[formatGroupSize(...col)]?.unit_id !== '0';
// && r[formatGroupSize(...col)]?.unit_id !== r.unit_id;
return (
<>
{text}
{_warning ? ` /${r[formatGroupSize(...col)].unit_name}` : ''}
</>
);
},
}, },
{ {
title: '儿童', title: '儿童',
@ -858,6 +987,18 @@ const AgencyPreview = ({ params, ...props }) => {
return { className: _warning ? 'bg-yellow-100' : '' }; return { className: _warning ? 'bg-yellow-100' : '' };
}, },
render: (text, r) => {
const _warning = r.info?.isCityRow !== true && text
&& r[formatGroupSize(...col)]?.unit_id !== '0';
// && r[formatGroupSize(...col)]?.unit_id !== r.unit_id;
return (
<>
{text}
{_warning ? ` /${r[formatGroupSize(...col)].unit_name}` : ''}
</>
);
},
}, },
], ],
})), })),
@ -902,7 +1043,7 @@ const AgencyPreview = ({ params, ...props }) => {
rowClassName={cityRowHighlights} rowClassName={cityRowHighlights}
columns={[ columns={[
{ {
title: '附加项目'+` (${ti+1})`, title: '附加项目' + ` (${ti + 1})`,
dataIndex: ['info', 'product_title'], dataIndex: ['info', 'product_title'],
key: 'product_title', key: 'product_title',
width: '12rem', width: '12rem',
@ -910,7 +1051,7 @@ 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 };
}, },
}, },
{ {
@ -948,21 +1089,22 @@ const AgencyPreview = ({ params, ...props }) => {
key: 'adult_cost', key: 'adult_cost',
width: '4rem', width: '4rem',
className: 'max-w-16', 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 && text && r[formatGroupSize(...col)]?.unit_id !== '1';
&& text // && r[formatGroupSize(...col)]?.unit_id !== r.unit_id;
// && r[formatGroupSize(...col)]?.unit_id !== '1';
&& r[formatGroupSize(...col)]?.unit_id !== r.unit_id;
return { className: _warning ? 'bg-yellow-100' : '' }; return { className: _warning ? 'bg-yellow-100' : '' };
}, },
render: (text, r) => ( render: (text, r) => {
<> const _warning = r.info?.isCityRow !== true && text && r[formatGroupSize(...col)]?.unit_id !== '1';
{text} return (
{r.info?.isCityRow !== true && text ? ` /${r[formatGroupSize(...col)].unit_name}` : ''} <>
</> {text}
), {_warning ? ` /${r[formatGroupSize(...col)].unit_name}` : ''}
</>
);
},
}, },
{ {
title: '儿童', title: '儿童',
@ -970,21 +1112,22 @@ const AgencyPreview = ({ params, ...props }) => {
key: 'child_cost', key: 'child_cost',
width: '4rem', width: '4rem',
className: 'max-w-16', 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 && text && r[formatGroupSize(...col)]?.unit_id !== '1';
&& text // && r[formatGroupSize(...col)]?.unit_id !== r.unit_id;
// && r[formatGroupSize(...col)]?.unit_id !== '1';
&& r[formatGroupSize(...col)]?.unit_id !== r.unit_id;
return { className: _warning ? 'bg-yellow-100' : '' }; return { className: _warning ? 'bg-yellow-100' : '' };
}, },
render: (text, r) => ( render: (text, r) => {
<> const _warning = r.info?.isCityRow !== true && text && r[formatGroupSize(...col)]?.unit_id !== '1';
{text} return (
{r.info?.isCityRow !== true && text ? ` /${r[formatGroupSize(...col)].unit_name}` : ''} <>
</> {text}
), {_warning ? ` /${r[formatGroupSize(...col)].unit_name}` : ''}
</>
);
},
}, },
], ],
})), })),

@ -1,5 +1,5 @@
import { Button } from 'antd'; import { Button } from 'antd';
import { useProductsAuditStatesMapVal } from '@/hooks/useProductsSets'; import { useProductsAuditStatesMapVal, useProductsTypesMapVal } from '@/hooks/useProductsSets';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import useProductsStore, { getAgencyAllExtrasAction } from '@/stores/Products/Index'; import useProductsStore, { getAgencyAllExtrasAction } from '@/stores/Products/Index';
import RequireAuth from '@/components/RequireAuth'; import RequireAuth from '@/components/RequireAuth';
@ -18,13 +18,19 @@ const ExportDocxBtn = ({ params = { travel_agency_id: '', use_year: '', audit_st
const { travel_agency_id, use_year, audit_state } = params; const { travel_agency_id, use_year, audit_state } = params;
const auditStatesMap = useProductsAuditStatesMapVal(); const auditStatesMap = useProductsAuditStatesMapVal();
const productsTypesMapVal = useProductsTypesMapVal();
const { getRemarkList } = useProductsStore((selector) => ({ const { getRemarkList } = useProductsStore((selector) => ({
getRemarkList: selector.getRemarkList, getRemarkList: selector.getRemarkList,
})); }));
const handleDownload = async () => { const handleDownload = async () => {
// await refresh(); // await refresh();
const agencyExtras = await getAgencyAllExtrasAction(params); const _agencyExtras = await getAgencyAllExtrasAction(params);
const agencyExtras = Object.keys(_agencyExtras).reduce((acc, pid) => {
const pitemExtras = _agencyExtras[pid];
const _pitem = (pitemExtras || []).map(eitem => ({ ...eitem, info: { ...eitem.info, product_type_name_txt: productsTypesMapVal[eitem.info.product_type_id]?.label || eitem.info.product_type_name } } ));
return { ...acc, [pid]: _pitem };
}, {});
const remarks = await getRemarkList(); const remarks = await getRemarkList();
const remarksMappedByType = remarks.reduce((r, v) => ({ ...r, [v.product_type_id]: v }), {}); const remarksMappedByType = remarks.reduce((r, v) => ({ ...r, [v.product_type_id]: v }), {});
const documentCreator = new AgencyContract(); const documentCreator = new AgencyContract();

Loading…
Cancel
Save