From f550ba14e878191cd87aaae1ad4c8c8c4f549d6e Mon Sep 17 00:00:00 2001 From: 陈鑫涛 <10125295+chen-xintao97@user.noreply.gitee.com> Date: Wed, 2 Jul 2025 17:10:18 +0800 Subject: [PATCH] 卡牌排版 --- src/components/Common/Typesetting/typesetting.js | 62 ++++++++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 40 insertions(+), 22 deletions(-) diff --git a/src/components/Common/Typesetting/typesetting.js b/src/components/Common/Typesetting/typesetting.js index 11ecbb6..24fea83 100644 --- a/src/components/Common/Typesetting/typesetting.js +++ b/src/components/Common/Typesetting/typesetting.js @@ -213,9 +213,13 @@ const Typesetting = props => { if (iFAngle === 90 || iFAngle === 270 || iSAngle === 90 || iSAngle === 270) { jInnerHeight = innerWidth; jInnerWidth = innerHeight; - // dSvgBoxHeight = jInnerHeight; - // dSvgBoxWidth = jInnerWidth; } + if (state.selectedNode.sTypeKey === 'kaipai' || state.selectedNode.sTypeKey === 'juantong') { + jInnerHeight = innerWidth; + jInnerWidth = innerHeight; + } + console.log(state.selectedNode.sTypeKey,'55555'); + const innerHeightCombined = isVertical ? jInnerHeight * 2 + dSWidthOffset + dFWidthOffset + dXBJJ : Math.max(jInnerHeight + dFWidthOffset, jInnerHeight + dSWidthOffset) + dXBJJ; // 计算内层盒子高度 从上向下排列 取首盒加偏移量和次盒加偏移量最大的值 从左往右排列 盒子尺寸 * 2 加上首盒偏移量和次盒偏移量 @@ -238,33 +242,45 @@ const Typesetting = props => { let cols = dSWidthOffsetCombined === 0 ? 0 : Math.floor(outerWidth / dSWidthOffsetCombined); const rowsCombined = innerHeightCombined + boxWidthOffset + (reference ? 0 : dSWidthOffset); let rows = rowsCombined === 0 ? 0 : Math.floor(outerHeight / rowsCombined); - let colsMaxLength = (cols - 1) * (innerWidthCombined + boxLengthOffset + (reference ? 0 : dSLengthOffset)) + innerWidthCombined; - while (colsMaxLength >= outerWidth && cols > 0) { + let colsMaxLength = (cols) * (innerWidthCombined + boxLengthOffset + (reference ? 0 : dSLengthOffset) + dYBJJ) + dZBLB + dYBLB; + while (colsMaxLength >= outerWidth && cols > 0) { cols = cols - 1; - colsMaxLength = (cols - 1) * (innerWidthCombined + boxLengthOffset + (reference ? 0 : dSLengthOffset)) + innerWidthCombined; + colsMaxLength = (cols) * (innerWidthCombined + boxLengthOffset + (reference ? 0 : dSLengthOffset) + dYBJJ); } - let rowsMaxLength = (rows - 1) * (innerHeightCombined + boxWidthOffset + (reference ? 0 : dSWidthOffset)) + innerHeightCombined; - while (rowsMaxLength >= outerHeight && rows > 0) { + let rowsMaxLength = rows * (innerHeightCombined + boxWidthOffset + (reference ? 0 : dSWidthOffset) + dXBJJ) + dSBLB + dXBLB ; + while (rowsMaxLength>= outerHeight && rows > 0) { rows = rows - 1; - rowsMaxLength = (rows - 1) * (innerHeightCombined + boxWidthOffset + (reference ? 0 : dSWidthOffset)) + innerHeightCombined; + rowsMaxLength = rows * (innerHeightCombined + boxWidthOffset + (reference ? 0 : dSWidthOffset) + dXBJJ) ; } - console.log(cols, rows, outerWidth, outerHeight, "cols rows outerWidth outerHeight"); + + // console.log(cols, rows, outerWidth, outerHeight, colsMaxLength,rowsMaxLength,"cols rows outerWidth outerHeight"); // 最大上机长 上机宽 开料尺寸 // 计算剩余空间 每组都算上偏移量 那么剩余需要加上后面偏移的总量 - const remainingWidth = - outerWidth - - (cols * (innerWidthCombined + boxLengthOffset + (reference ? 0 : dSLengthOffset)) - boxLengthOffset - (reference ? 0 : dSLengthOffset)); - const remainingHeight = - outerHeight - - (rows * (innerHeightCombined + boxWidthOffset + (reference ? 0 : dSWidthOffset)) - boxWidthOffset - (reference ? 0 : dSWidthOffset)); + const remainingWidth = outerWidth - colsMaxLength + const remainingHeight = outerHeight - rowsMaxLength + // const remainingWidth = + // outerWidth - + // (cols * (innerWidthCombined + boxLengthOffset + (reference ? 0 : dSLengthOffset)) - boxLengthOffset - (reference ? 0 : dSLengthOffset)); + // const remainingHeight = + // outerHeight - + // (rows * (innerHeightCombined + boxWidthOffset + (reference ? 0 : dSWidthOffset)) - boxWidthOffset - (reference ? 0 : dSWidthOffset)); //剩余量能不能放一下单独一个 - const commonHeightCheck = remainingHeight > jInnerHeight; - const commonWidthCheck = remainingWidth > jInnerWidth; + const commonHeightCheck = remainingHeight > jInnerHeight + dXBJJ; + const commonWidthCheck = remainingWidth > jInnerWidth + dYBJJ ; const isCustomized = bAdvancedSetting; let remaining = isVertical ? commonHeightCheck : commonWidthCheck; + console.log('剩余长',remainingWidth); + console.log('剩余高',remainingHeight); + console.log('剩余长是否放下',commonWidthCheck); + console.log('剩余高是否放下',commonHeightCheck); + console.log('剩余是否放下',remaining,cols,rows); + console.log('剩余 总高 盒高' , outerHeight, rowsCombined); + console.log('剩余 总长 盒长' , outerWidth, dSWidthOffsetCombined); + console.log('剩余 根据列排最大长高',colsMaxLength,rowsMaxLength); + // const remaining = false; const isOdd = num => { return num % 2 !== 0; @@ -524,8 +540,8 @@ const Typesetting = props => { if (reference) { // 是否首盒 // 首盒的上边距下边距 末尾盒子的上下边距 添加那一行的上边距 - leftPosition = col * innerWidthCombined; - topPosition = rows * innerHeightCombined; + leftPosition = col * (innerWidthCombined + dYBJJ) + dFLengthOffset; + topPosition = rows * (innerHeightCombined + dXBJJ) + dFWidthOffset; } else { leftPosition = col * (innerWidthCombined + dYBJJ); topPosition = rows * (innerHeightCombined + dXBJJ); @@ -567,8 +583,10 @@ const Typesetting = props => { const propsDataHeight = Number(propsData.props.style.height.slice(0, -2)); const propsDataTop = Number(propsData.props.style.top.slice(0, -2)); // 判断列是否是单独的 - const newMaterialLength = parseFloat(propsDataLeft + (remaining ? jInnerWidth : innerWidthCombined) + dSBLB + dXBLB).toFixed(2); // 原纸长 - const newMaterialWidth = parseFloat(propsDataTop + propsDataHeight + dZBLB + dYBLB).toFixed(2); + console.log(propsDataLeft, propsDataWidth, propsDataHeight, propsDataTop, "propsDataLeft propsDataWidth propsDataHeight propsDataTop"); + + const newMaterialLength = parseFloat(propsDataLeft + (remaining ? jInnerWidth : innerWidthCombined) + dZBLB + dYBLB).toFixed(2); // 原纸长 + const newMaterialWidth = parseFloat(propsDataTop + propsDataHeight + dSBLB + dXBLB).toFixed(2); // 计算开数 let dSinglePQty = isVertical @@ -689,7 +707,7 @@ const Typesetting = props => { Number(slaveDataDetail?.dMaxLength) >= Number(slaveRowData?.dMachineLength) && Number(slaveDataDetail?.dMaxWidth) >= Number(slaveRowData?.dMachineWidth); - const isShow = slaveRowData && slaveRowData.dMachineLength && slaveRowData.dMaxWidth && slaveRowData.dMaxLength && isMax && innerDivs.length > 0; + const isShow = true || slaveRowData && slaveRowData.dMachineLength && slaveRowData.dMaxWidth && slaveRowData.dMaxLength && isMax && innerDivs.length > 0; console.log( slaveDataDetail?.dMaxLength, slaveDataDetail?.dMaxWidth, -- libgit2 0.22.2