Commit 3534bd0de80ea77e130cfa2dde2f5364b7ae475f
1 parent
08e288e3
排版算法
Showing
4 changed files
with
29 additions
and
29 deletions
src/components/Common/BoxDesign/createAirplaneBox.js
| @@ -666,8 +666,8 @@ const createSvg = d => { | @@ -666,8 +666,8 @@ const createSvg = d => { | ||
| 666 | const svg = document.createElementNS("http://www.w3.org/2000/svg", "path"); | 666 | const svg = document.createElementNS("http://www.w3.org/2000/svg", "path"); |
| 667 | svg.setAttribute("d", d); | 667 | svg.setAttribute("d", d); |
| 668 | svg.setAttribute("fill", "transparent"); | 668 | svg.setAttribute("fill", "transparent"); |
| 669 | - svg.setAttribute("stroke", "#7588B9"); | ||
| 670 | - svg.setAttribute("stroke-width", "1"); | 669 | + svg.setAttribute("stroke", "#333"); |
| 670 | + svg.setAttribute("stroke-width", "0.5"); | ||
| 671 | return svg; | 671 | return svg; |
| 672 | }; | 672 | }; |
| 673 | const createDasharraySvg = d => { | 673 | const createDasharraySvg = d => { |
src/components/Common/BoxDesignCompontent/svg.js
| @@ -324,7 +324,7 @@ const SvgBox = props => { | @@ -324,7 +324,7 @@ const SvgBox = props => { | ||
| 324 | } else { | 324 | } else { |
| 325 | leftSize = zbtb?.value; | 325 | leftSize = zbtb?.value; |
| 326 | } | 326 | } |
| 327 | - svg.setAttribute("viewBox", `${-(leftSize * scale || 0)} ${-ySvg} ${dSvgBoxWidth} ${dSvgBoxHeight}`); | 327 | + svg.setAttribute("viewBox", `${-((leftSize) * scale || 0)} ${-ySvg} ${dSvgBoxWidth} ${dSvgBoxHeight}`); |
| 328 | svg.setAttribute("width", `${dSvgBoxWidth}px`); | 328 | svg.setAttribute("width", `${dSvgBoxWidth}px`); |
| 329 | svg.setAttribute("height", `${dSvgBoxHeight}px`); | 329 | svg.setAttribute("height", `${dSvgBoxHeight}px`); |
| 330 | svgContainerRef.current.style.width = `${dSvgBoxWidth}px`; | 330 | svgContainerRef.current.style.width = `${dSvgBoxWidth}px`; |
src/components/Common/CommonComponent/index.js
| @@ -2880,8 +2880,6 @@ export default class CommonComponent extends Component { | @@ -2880,8 +2880,6 @@ export default class CommonComponent extends Component { | ||
| 2880 | /* 如果是选择空值,则将特殊字符过滤为空值 */ | 2880 | /* 如果是选择空值,则将特殊字符过滤为空值 */ |
| 2881 | value = ""; | 2881 | value = ""; |
| 2882 | } | 2882 | } |
| 2883 | - console.log("🚀 ~ sAssignFieldObj:", 66666) | ||
| 2884 | - | ||
| 2885 | /* 回带值声明 */ | 2883 | /* 回带值声明 */ |
| 2886 | const returnValue = {}; | 2884 | const returnValue = {}; |
| 2887 | const { searchValue, searchDropDownData, dropDownData } = this.state; | 2885 | const { searchValue, searchDropDownData, dropDownData } = this.state; |
src/components/Common/Typesetting/typesetting.js
| @@ -94,24 +94,25 @@ const Typesetting = props => { | @@ -94,24 +94,25 @@ const Typesetting = props => { | ||
| 94 | const H = masterData?.dWidth || 0; | 94 | const H = masterData?.dWidth || 0; |
| 95 | const D = masterData?.dHeight || 0; | 95 | const D = masterData?.dHeight || 0; |
| 96 | // 动态计算公式值 | 96 | // 动态计算公式值 |
| 97 | - const evaluateFormula = (formula, variables) => { | ||
| 98 | - if (!formula) return 0; // 如果公式为空,返回0 | ||
| 99 | - try { | ||
| 100 | - // 提取公式中的变量名 | ||
| 101 | - const variableNames = formula.match(/\b[a-zA-Z_][a-zA-Z0-9_]*\b/g) || []; | ||
| 102 | - // 构建函数参数 | ||
| 103 | - const params = variableNames.join(","); | ||
| 104 | - // 替换公式中的变量为实际值 | ||
| 105 | - const func = new Function(params, `return ${formula}`); | ||
| 106 | - // 提取变量值 | ||
| 107 | - const args = variableNames.map(name => Number(variables[name]) || 0); | ||
| 108 | - // 执行函数并返回结果 | ||
| 109 | - return func(...args); | ||
| 110 | - } catch (error) { | ||
| 111 | - console.error("公式执行错误:", error); | ||
| 112 | - return 0; | ||
| 113 | - } | ||
| 114 | -}; | 97 | +const evaluateFormula = (formula, variables) => { |
| 98 | + if (!formula) return 0; // 如果公式为空,返回0 | ||
| 99 | + try { | ||
| 100 | + // 提取公式中的变量名 | ||
| 101 | + const variableNames = formula.match(/\b[a-zA-Z_][a-zA-Z0-9_]*\b/g) || []; | ||
| 102 | + // 构建函数参数 | ||
| 103 | + const params = variableNames.join(",") + ",Math"; | ||
| 104 | + // 替换公式中的变量为实际值 | ||
| 105 | + const func = new Function(params, `return ${formula}`); | ||
| 106 | + // 提取变量值 | ||
| 107 | + const args = variableNames.map(name => Number(variables[name]) || 0); | ||
| 108 | + // 执行函数并返回结果 | ||
| 109 | + return func(...args, Math); | ||
| 110 | + } catch (error) { | ||
| 111 | + console.error("公式执行错误:", error); | ||
| 112 | + return 0; | ||
| 113 | + } | ||
| 114 | + }; | ||
| 115 | + | ||
| 115 | // 计算公式值 | 116 | // 计算公式值 |
| 116 | const variables = { | 117 | const variables = { |
| 117 | L, | 118 | L, |
| @@ -217,13 +218,12 @@ const Typesetting = props => { | @@ -217,13 +218,12 @@ const Typesetting = props => { | ||
| 217 | // dSvgBoxHeight = jInnerHeight; | 218 | // dSvgBoxHeight = jInnerHeight; |
| 218 | // dSvgBoxWidth = jInnerWidth; | 219 | // dSvgBoxWidth = jInnerWidth; |
| 219 | } | 220 | } |
| 220 | - const innerHeightCombined = isVertical | ||
| 221 | - ? jInnerHeight * 2 + dSWidthOffset + dFWidthOffset | ||
| 222 | - : Math.max(jInnerHeight + dFWidthOffset, jInnerHeight + dSWidthOffset); | 221 | + const innerHeightCombined = isVertical ? jInnerHeight * 2 + dSWidthOffset + dFWidthOffset + dXBJJ: Math.max(jInnerHeight + dFWidthOffset, jInnerHeight + dSWidthOffset) + dXBJJ; // 计算内层盒子高度 从上向下排列 取首盒加偏移量和次盒加偏移量最大的值 从左往右排列 盒子尺寸 * 2 加上首盒偏移量和次盒偏移量 |
| 223 | // 计算内层盒子宽度 从上向下排列 取首盒加偏移量和次盒加偏移量最大的值 从左往右排列 盒子尺寸 * 2 加上首盒偏移量和次盒偏移量 | 222 | // 计算内层盒子宽度 从上向下排列 取首盒加偏移量和次盒加偏移量最大的值 从左往右排列 盒子尺寸 * 2 加上首盒偏移量和次盒偏移量 |
| 224 | const innerWidthCombined = isVertical | 223 | const innerWidthCombined = isVertical |
| 225 | - ? Math.max(jInnerWidth + dFLengthOffset, jInnerWidth + dSLengthOffset) | ||
| 226 | - : jInnerWidth * 2 + dSLengthOffset + dFLengthOffset; | 224 | + ? Math.max(jInnerWidth + dFLengthOffset, jInnerWidth + dSLengthOffset) + dYBJJ |
| 225 | + : jInnerWidth * 2 + dSLengthOffset + dFLengthOffset + dYBJJ; | ||
| 226 | +console.log('总高',innerHeightCombined,'总款',innerWidthCombined); | ||
| 227 | 227 | ||
| 228 | const style = { | 228 | const style = { |
| 229 | width: `${outerWidth}px`, | 229 | width: `${outerWidth}px`, |
| @@ -235,7 +235,8 @@ const Typesetting = props => { | @@ -235,7 +235,8 @@ const Typesetting = props => { | ||
| 235 | // 每个盒子加上边距 和第二组偏移量 如果根据次盒再加上次盒偏移量 | 235 | // 每个盒子加上边距 和第二组偏移量 如果根据次盒再加上次盒偏移量 |
| 236 | const dSWidthOffsetCombined = innerWidthCombined + boxLengthOffset + (reference ? 0 : dSLengthOffset); | 236 | const dSWidthOffsetCombined = innerWidthCombined + boxLengthOffset + (reference ? 0 : dSLengthOffset); |
| 237 | let cols = dSWidthOffsetCombined === 0 ? 0 : Math.floor(outerWidth / dSWidthOffsetCombined); | 237 | let cols = dSWidthOffsetCombined === 0 ? 0 : Math.floor(outerWidth / dSWidthOffsetCombined); |
| 238 | - let rows = Math.floor(outerHeight / (innerHeightCombined + boxWidthOffset + (reference ? 0 : dSWidthOffset))); | 238 | + const rowsCombined = innerHeightCombined + boxWidthOffset + (reference ? 0 : dSWidthOffset); |
| 239 | + let rows =rowsCombined === 0 ? 0 : Math.floor(outerHeight / (rowsCombined)); | ||
| 239 | let colsMaxLength = (cols - 1) * (innerWidthCombined + boxLengthOffset + (reference ? 0 : dSLengthOffset)) + innerWidthCombined; | 240 | let colsMaxLength = (cols - 1) * (innerWidthCombined + boxLengthOffset + (reference ? 0 : dSLengthOffset)) + innerWidthCombined; |
| 240 | while (colsMaxLength >= outerWidth && cols > 0) { | 241 | while (colsMaxLength >= outerWidth && cols > 0) { |
| 241 | cols = cols - 1; | 242 | cols = cols - 1; |
| @@ -247,6 +248,7 @@ const Typesetting = props => { | @@ -247,6 +248,7 @@ const Typesetting = props => { | ||
| 247 | rows = rows - 1; | 248 | rows = rows - 1; |
| 248 | rowsMaxLength = (rows - 1) * (innerHeightCombined + boxWidthOffset + (reference ? 0 : dSWidthOffset)) + innerHeightCombined; | 249 | rowsMaxLength = (rows - 1) * (innerHeightCombined + boxWidthOffset + (reference ? 0 : dSWidthOffset)) + innerHeightCombined; |
| 249 | } | 250 | } |
| 251 | +console.log(cols, rows, outerWidth, outerHeight, "cols rows outerWidth outerHeight"); | ||
| 250 | 252 | ||
| 251 | // 最大上机长 上机宽 开料尺寸 | 253 | // 最大上机长 上机宽 开料尺寸 |
| 252 | // 计算剩余空间 每组都算上偏移量 那么剩余需要加上后面偏移的总量 | 254 | // 计算剩余空间 每组都算上偏移量 那么剩余需要加上后面偏移的总量 |