Commit 3534bd0de80ea77e130cfa2dde2f5364b7ae475f

Authored by 陈鑫涛
1 parent 08e288e3

排版算法

src/components/Common/BoxDesign/createAirplaneBox.js
... ... @@ -666,8 +666,8 @@ const createSvg = d => {
666 666 const svg = document.createElementNS("http://www.w3.org/2000/svg", "path");
667 667 svg.setAttribute("d", d);
668 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 671 return svg;
672 672 };
673 673 const createDasharraySvg = d => {
... ...
src/components/Common/BoxDesignCompontent/svg.js
... ... @@ -324,7 +324,7 @@ const SvgBox = props => {
324 324 } else {
325 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 328 svg.setAttribute("width", `${dSvgBoxWidth}px`);
329 329 svg.setAttribute("height", `${dSvgBoxHeight}px`);
330 330 svgContainerRef.current.style.width = `${dSvgBoxWidth}px`;
... ...
src/components/Common/CommonComponent/index.js
... ... @@ -2880,8 +2880,6 @@ export default class CommonComponent extends Component {
2880 2880 /* 如果是选择空值,则将特殊字符过滤为空值 */
2881 2881 value = "";
2882 2882 }
2883   - console.log("🚀 ~ sAssignFieldObj:", 66666)
2884   -
2885 2883 /* 回带值声明 */
2886 2884 const returnValue = {};
2887 2885 const { searchValue, searchDropDownData, dropDownData } = this.state;
... ...
src/components/Common/Typesetting/typesetting.js
... ... @@ -94,24 +94,25 @@ const Typesetting = props => {
94 94 const H = masterData?.dWidth || 0;
95 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 117 const variables = {
117 118 L,
... ... @@ -217,13 +218,12 @@ const Typesetting = props => {
217 218 // dSvgBoxHeight = jInnerHeight;
218 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 222 // 计算内层盒子宽度 从上向下排列 取首盒加偏移量和次盒加偏移量最大的值 从左往右排列 盒子尺寸 * 2 加上首盒偏移量和次盒偏移量
224 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 228 const style = {
229 229 width: `${outerWidth}px`,
... ... @@ -235,7 +235,8 @@ const Typesetting = props => {
235 235 // 每个盒子加上边距 和第二组偏移量 如果根据次盒再加上次盒偏移量
236 236 const dSWidthOffsetCombined = innerWidthCombined + boxLengthOffset + (reference ? 0 : dSLengthOffset);
237 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 240 let colsMaxLength = (cols - 1) * (innerWidthCombined + boxLengthOffset + (reference ? 0 : dSLengthOffset)) + innerWidthCombined;
240 241 while (colsMaxLength >= outerWidth && cols > 0) {
241 242 cols = cols - 1;
... ... @@ -247,6 +248,7 @@ const Typesetting = props => {
247 248 rows = rows - 1;
248 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 // 计算剩余空间 每组都算上偏移量 那么剩余需要加上后面偏移的总量
... ...