diff --git a/src/hooks/useProductsQuotationFormat.js b/src/hooks/useProductsQuotationFormat.js index 4a50c50..254daf7 100644 --- a/src/hooks/useProductsQuotationFormat.js +++ b/src/hooks/useProductsQuotationFormat.js @@ -356,10 +356,11 @@ export const splitTable_R = (use_year, dataSource, retTableOnly = true) => { 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); // 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) => { diff --git a/src/hooks/useProductsSets.js b/src/hooks/useProductsSets.js index 850fca9..4f5e334 100644 --- a/src/hooks/useProductsSets.js +++ b/src/hooks/useProductsSets.js @@ -70,6 +70,9 @@ export const useProductsTypesMapVal = (value) => { return stateMapVal; }; +/** + * 价格的审核状态 + */ export const useProductsAuditStates = () => { const [types, setTypes] = useState([]); const { t, i18n } = useTranslation(); @@ -153,7 +156,7 @@ export const useNewProductRecord = () => { 'lastedit_changed': '', 'create_date': '', 'created_by': '', - 'edit_status': 2, + 'edit_status': 2, // 信息的审核状态 1已发布,2已审核 'sort_order': '', 'sub_type_D': '', // 包价类型, 值保存在`item_type`字段中 'item_type': '', // 产品子类型的值 diff --git a/src/views/products/Print/AgencyContract.jsx b/src/views/products/Print/AgencyContract.jsx index c34f234..3b40a07 100644 --- a/src/views/products/Print/AgencyContract.jsx +++ b/src/views/products/Print/AgencyContract.jsx @@ -19,9 +19,14 @@ import { TextRun, WidthType, } 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' +const unitMap = { + '0': '人', + '1': '团', +} + const DOC_TITLE = '地接合同' const pageMargins = { top: `15mm`, @@ -283,7 +288,15 @@ export default class AgencyContract { this.createSubHeading(`餐费(元/人/餐)`, { 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']) ? [] @@ -317,6 +330,7 @@ export default class AgencyContract { */ createTable_6(use_year, dataList, style = {}) { const { tables, SSRange } = splitTable_6(use_year, dataList, false); + const defaultUnit = '0'; const table2Rows = tables.reduce((acc, {info, SS}) => { 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, children: [ 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, }), ], @@ -388,7 +416,9 @@ export default class AgencyContract { */ createTable_B(use_year, dataList) { // 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 subTable = new Table({ @@ -401,8 +431,9 @@ export default class AgencyContract { new TableRow({ children: [ this.createTableHeader('超公里项目', 20), - this.createTableHeader('往返公里数', 20), - this.createTableHeader([...SSRange], 60, { + this.createTableHeader('往返公里数', 15), + ...(showRangeCol ? [this.createTableHeader('', 15)] : []), + this.createTableHeader([...SSRange], 65, { columnSpan: cols.length, }), ], @@ -419,6 +450,15 @@ export default class AgencyContract { verticalAlign: AlignmentType.CENTER, children: [new Paragraph({ text: '' })], }), + ...(showRangeCol + ? [ + new TableCell({ + borders: tableBorderOne, + verticalAlign: AlignmentType.CENTER, + children: [new Paragraph({ text: '时段', alignment: 'center' })], + }), + ] + : []), ...cols.map( (ss) => new TableCell({ @@ -430,41 +470,90 @@ export default class AgencyContract { alignment: AlignmentType.CENTER, }), ], - }), + }) ), ], }), - ...data.map((row, ri) => new TableRow({ - children: [ - 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 || '' })], - }), - new TableCell({ - borders: tableBorderOne, - verticalAlign: AlignmentType.CENTER, - children: [new Paragraph({ text: `${row.info?.km ?? ''}`, alignment: AlignmentType.CENTER, })], - }), - ...cols.map( - (ss) => - new TableCell({ - borders: tableBorderOne, - verticalAlign: AlignmentType.CENTER, - children: [ - new Paragraph({ - text: `${row?.[formatGroupSize(...ss)]?.adult_cost ?? ''}`, - 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: '' })], + }), + ] + : [ + new TableCell({ + borders: tableBorderOne, + verticalAlign: AlignmentType.CENTER, + children: [new Paragraph({ text: row.info?.product_title || '' })], + rowSpan: row.rowSpan, + }), + 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(new Paragraph({ text: `` })) // 多表格之间分隔一行 return acc @@ -477,7 +566,7 @@ export default class AgencyContract { */ createTable_J(use_year, dataList) { const { tables, SSRange, PSRange, } = splitTable_J(use_year, dataList, false); - // const defaultUnit = '1' + const defaultUnit = '1' const showRangeCol = PSRange.length > 0; const tableS = tables.reduce((acc, { cols, data }) => { @@ -564,7 +653,21 @@ export default class AgencyContract { verticalAlign: AlignmentType.CENTER, children: [ 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, }), ], @@ -591,7 +694,7 @@ export default class AgencyContract { const { tables, SSRange, PSRange } = splitTable_D(use_year, dataList, false); // console.log('DDDD', tables, SSRange, PSRange); - // const defaultUnit = '1' + const defaultUnit = '1' const showRangeCol = PSRange.length > 0; // 显示时段列 // console.log(sizeSets, dataSource) @@ -681,7 +784,28 @@ export default class AgencyContract { verticalAlign: AlignmentType.CENTER, children: [ 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, }), ], @@ -706,6 +830,7 @@ export default class AgencyContract { */ createTable_Q(use_year, dataList) { const tables = splitTable_Q(use_year, dataList, false); + const defaultUnit = '1' // console.log('QQQ', tables); return new Table({ @@ -738,7 +863,24 @@ export default class AgencyContract { verticalAlign: AlignmentType.CENTER, children: (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({ borders: tableBorderNone, @@ -764,6 +906,7 @@ export default class AgencyContract { }), new TableCell({ borders: ii !== _arr.length - 1 ? tableBorderInner : tableBorderInnerR, + width: { size: 1200, type: WidthType.DXA }, verticalAlign: AlignmentType.CENTER, children: [ new Paragraph({ @@ -808,7 +951,8 @@ export default class AgencyContract { children: [ new TableCell({ 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, 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, children: [ new Paragraph({ - text: `${quoteItem.adult_cost}`, - alignment: AlignmentType.LEFT, + // text: `${quoteItem.adult_cost}`, + 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) { const tables = splitTable_7(use_year, dataList, false); + const defaultUnit = '0'; return new Table({ borders: tableBorderNone, @@ -874,7 +1033,7 @@ export default class AgencyContract { children: (row?.SS || []).length === 0 ? [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 Table({ @@ -917,7 +1076,7 @@ export default class AgencyContract { children: [ new Paragraph({ text: `${quoteItem.adult_cost}`, - alignment: AlignmentType.LEFT, + alignment: AlignmentType.CENTER, }), ], }), @@ -1015,7 +1174,7 @@ export default class AgencyContract { new Paragraph({ children: [ 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, }), ], @@ -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 defaultUnit = '0'; // console.log('RRRRRR', tables); const tableS = tables.reduce((acc, { cols, data }) => { @@ -1101,7 +1261,21 @@ export default class AgencyContract { verticalAlign: AlignmentType.CENTER, children: [ 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, }), ], @@ -1121,6 +1295,131 @@ export default class AgencyContract { 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 = []) { return new TableRow({ children: [ diff --git a/src/views/products/Print/AgencyPreview.jsx b/src/views/products/Print/AgencyPreview.jsx index 294df6b..78d5771 100644 --- a/src/views/products/Print/AgencyPreview.jsx +++ b/src/views/products/Print/AgencyPreview.jsx @@ -3,7 +3,7 @@ import { useParams, Link } from 'react-router-dom'; import { Button, Drawer, Card, Table } from 'antd'; import { useTranslation } from 'react-i18next'; 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 { groupBy, isNotEmpty } from '@/utils/commons'; import useAuthStore from '@/stores/Auth'; @@ -20,6 +20,8 @@ const AgencyPreview = ({ params, ...props }) => { const [agencyProducts] = useProductsStore((state) => [state.agencyProducts]); const [setEditingProduct] = useProductsStore((state) => [state.setEditingProduct]); + const productsTypesMapVal = useProductsTypesMapVal(); + const [previewMode, setPreviewMode] = useState(false); const [tables, setTables] = useState([]); const [extras, setExtras] = useState([]); @@ -121,14 +123,68 @@ const AgencyPreview = ({ params, ...props }) => { render: (_, r) =>
{formatGroupSize(r.group_size_min, r.group_size_max, true)}
, }, { - title: <>{SSRange.map(v =>
{v}
)}, + title: ( + <> + {SSRange.map((v) => ( +
{v}
+ ))} + + ), dataIndex: 'SS', key: 'SS', width: '9rem', align: 'center', 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; } const tablesQuote = splitTable_B(use_year, agencyProducts.B); + // console.log(tablesQuote) return ( <> {tablesQuote.map(({ cols, colsKey, data }, ti) => ( @@ -155,10 +212,12 @@ const AgencyPreview = ({ params, ...props }) => { rowClassName={cityRowHighlights} columns={[ { - title: '超公里项目'+` (${ti+1})`, + title: '超公里项目' + ` (${ti + 1})`, dataIndex: ['info', 'product_title'], key: 'product_title', - width: '12rem', maxWidth: '12rem', className: 'max-w-48', + width: '12rem', + maxWidth: '12rem', + className: 'max-w-48', fixed: 'left', onCell: (record) => { return { rowSpan: record.rowSpan }; @@ -168,7 +227,9 @@ const AgencyPreview = ({ params, ...props }) => { title: '往返公里数', dataIndex: ['info', 'km'], key: 'product_title', - width: '6rem', maxWidth: '6rem', className: 'max-w-4', + width: '6rem', + maxWidth: '6rem', + className: 'max-w-4', onCell: (record) => { return { rowSpan: record.rowSpan }; }, @@ -180,11 +241,15 @@ const AgencyPreview = ({ params, ...props }) => { width: '5rem', fixed: 'left', render: (_, { quote_season, use_dates_start, use_dates_end, rowSpan }) => - quote_season === 'SS' ? (rowSpan > 1 ? ( -
- 平季
(除特殊时段外)
-
- ) : '') : ( + quote_season === 'SS' ? ( + rowSpan > 1 ? ( +
+ 平季
(除特殊时段外)
+
+ ) : ( + '' + ) + ) : (
特殊时段
@@ -198,8 +263,54 @@ const AgencyPreview = ({ params, ...props }) => { // dataIndex: [formatGroupSize(...col), 'adult_cost'], key: col[0], 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 = () => { // console.log('QQQQQQ'); if (!('Q' in agencyProducts)) { @@ -637,6 +751,9 @@ const AgencyPreview = ({ params, ...props }) => { ); }; + /** + * 景点 + */ const renderTable_7 = () => { // console.log('7777777777777'); if (!('7' in agencyProducts)) { @@ -762,7 +879,7 @@ const AgencyPreview = ({ params, ...props }) => {
{_extras.map((e) => (
- {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)}】
))}
@@ -844,6 +961,18 @@ const AgencyPreview = ({ params, ...props }) => { 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: '儿童', @@ -858,6 +987,18 @@ const AgencyPreview = ({ params, ...props }) => { 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} columns={[ { - title: '附加项目'+` (${ti+1})`, + title: '附加项目' + ` (${ti + 1})`, dataIndex: ['info', 'product_title'], key: 'product_title', width: '12rem', @@ -910,7 +1051,7 @@ const AgencyPreview = ({ params, ...props }) => { className: 'max-w-48', fixed: 'left', onCell: (record) => { - return { rowSpan: record.rowSpan, }; + return { rowSpan: record.rowSpan }; }, }, { @@ -948,21 +1089,22 @@ const AgencyPreview = ({ params, ...props }) => { key: 'adult_cost', width: '4rem', className: 'max-w-16', - onCell: (r, ) => { - const text = r[formatGroupSize(...col)]?.adult_cost - const _warning = r.info?.isCityRow !== true - && text - // && r[formatGroupSize(...col)]?.unit_id !== '1'; - && r[formatGroupSize(...col)]?.unit_id !== r.unit_id; + onCell: (r) => { + const text = r[formatGroupSize(...col)]?.adult_cost; + const _warning = r.info?.isCityRow !== true && text && r[formatGroupSize(...col)]?.unit_id !== '1'; + // && r[formatGroupSize(...col)]?.unit_id !== r.unit_id; return { className: _warning ? 'bg-yellow-100' : '' }; }, - render: (text, r) => ( - <> - {text} - {r.info?.isCityRow !== true && text ? ` /${r[formatGroupSize(...col)].unit_name}` : ''} - - ), + render: (text, r) => { + const _warning = r.info?.isCityRow !== true && text && r[formatGroupSize(...col)]?.unit_id !== '1'; + return ( + <> + {text} + {_warning ? ` /${r[formatGroupSize(...col)].unit_name}` : ''} + + ); + }, }, { title: '儿童', @@ -970,21 +1112,22 @@ const AgencyPreview = ({ params, ...props }) => { key: 'child_cost', width: '4rem', className: 'max-w-16', - onCell: (r, ) => { - const text = r[formatGroupSize(...col)]?.child_cost - const _warning = r.info?.isCityRow !== true - && text - // && r[formatGroupSize(...col)]?.unit_id !== '1'; - && r[formatGroupSize(...col)]?.unit_id !== r.unit_id; + onCell: (r) => { + const text = r[formatGroupSize(...col)]?.child_cost; + const _warning = r.info?.isCityRow !== true && text && r[formatGroupSize(...col)]?.unit_id !== '1'; + // && r[formatGroupSize(...col)]?.unit_id !== r.unit_id; return { className: _warning ? 'bg-yellow-100' : '' }; }, - render: (text, r) => ( - <> - {text} - {r.info?.isCityRow !== true && text ? ` /${r[formatGroupSize(...col)].unit_name}` : ''} - - ), + render: (text, r) => { + const _warning = r.info?.isCityRow !== true && text && r[formatGroupSize(...col)]?.unit_id !== '1'; + return ( + <> + {text} + {_warning ? ` /${r[formatGroupSize(...col)].unit_name}` : ''} + + ); + }, }, ], })), diff --git a/src/views/products/Print/ExportDocxBtn.jsx b/src/views/products/Print/ExportDocxBtn.jsx index b8ad1f6..b58bb4b 100644 --- a/src/views/products/Print/ExportDocxBtn.jsx +++ b/src/views/products/Print/ExportDocxBtn.jsx @@ -1,5 +1,5 @@ import { Button } from 'antd'; -import { useProductsAuditStatesMapVal } from '@/hooks/useProductsSets'; +import { useProductsAuditStatesMapVal, useProductsTypesMapVal } from '@/hooks/useProductsSets'; import { useTranslation } from 'react-i18next'; import useProductsStore, { getAgencyAllExtrasAction } from '@/stores/Products/Index'; 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 auditStatesMap = useProductsAuditStatesMapVal(); + const productsTypesMapVal = useProductsTypesMapVal(); const { getRemarkList } = useProductsStore((selector) => ({ getRemarkList: selector.getRemarkList, })); const handleDownload = async () => { // 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 remarksMappedByType = remarks.reduce((r, v) => ({ ...r, [v.product_type_id]: v }), {}); const documentCreator = new AgencyContract();