Commit c0d9a47f49a017f40755bdea90e32eb1a2744664

Authored by 陈鑫涛
1 parent 89f2e12c

排版

src/components/Common/Typesetting/typesetting.js
... ... @@ -87,11 +87,10 @@ const Typesetting = props => {
87 87 // 如果需要自定义排版数
88 88 // 确认是竖向排列还是横向排列
89 89  
90   - const L = masterData?.dLength || 0;
91   - const W = masterData?.dWidth || 0 ;
  90 + const L = Number(masterData?.dLength) || 0;
  91 + const W = masterData?.dWidth || 0;
92 92 const H = masterData?.dWidth || 0;
93 93 const D = masterData?.dHeight || 0;
94   -
95 94 // 动态计算公式值
96 95 const evaluateFormula = (formula, variables) => {
97 96 if (!formula) return 0; // 如果公式为空,返回0
... ... @@ -118,8 +117,9 @@ const Typesetting = props => {
118 117 D,
119 118 ...props.slaveRowData,
120 119 };
  120 + const { sStripType = 0 } = props.state.selectedNode;
121 121 let boxList = [];
122   - if (sColumnNameConfig) {
  122 + if (sColumnNameConfig ) {
123 123 const slaveNewData = JSON.parse(sColumnNameConfig);
124 124 const tables = [
125 125 { name: "盒型类别", value: slaveRowData.sBoxType, type: null },
... ... @@ -142,7 +142,7 @@ const Typesetting = props => {
142 142 slaveNewData.forEach(x => {
143 143 let key = 0;
144 144 if (x.sAssignFormula) {
145   - key = evaluateFormula(x.sAssignFormula, variables);
  145 + key = parseFloat(evaluateFormula(x.sAssignFormula, variables)).toFixed(2) || 0;
146 146 } else {
147 147 key = slaveRowData[x.sName];
148 148 }
... ... @@ -176,7 +176,7 @@ const Typesetting = props => {
176 176 });
177 177 }
178 178  
179   - const result = boxList.reduce((acc, { sCode, value }) => ({ ...acc, [sCode]: value }), {});
  179 + const result = boxList?.reduce((acc, { sCode, value }) => ({ ...acc, [sCode]: value }), {});
180 180  
181 181 // 计算表达式结果
182 182 const variabless = {
... ... @@ -187,26 +187,6 @@ const Typesetting = props => {
187 187 ...props.slaveRowData,
188 188 ...result,
189 189 };
190   - const evaluateFormulas = (formula, variables) => {
191   - if (!formula) return ""; // 如果公式为空,返回空字符串
192   -
193   - 提; //取公式中的变量名
194   - const variableNames = formula.match(/\b[a-zA-Z_][a-zA-Z0-9_]*\b/g) || [];
195   -
196   - // 替换公式中的变量为实际值
197   - let modifiedFormula = formula;
198   - variableNames.forEach(name => {
199   - if (variables[name] !== undefined) {
200   - modifiedFormula = modifiedFormula.replace(new RegExp(`\\b${name}\\b`, "g"), variables[name]);
201   - }
202   - });
203   -
204   - return modifiedFormula;
205   - };
206   - // const s = `((dYXCW + D) >= dSFHS) && ((dYXCW + D) >= dZSCW)
207   - // ? (dSFHS >= dZSCW ? -(dYXCW + D - dSFHS) * 2 : -((dYXCW + D) - dZSCW)) * 2
208   - // : dSFHS >= dZSCW ? (dYXCW + D >= dZSCW) ? -(dSFHS - (dYXCW + D)) * 2 : -(dSFHS - dZXCW) * 2 : (dYXCW + D >= dSFHS) ? -(dZSCW - (dYXCW + D)) * 2 : -(dZXCW - dSFHS) * 2`
209   - // const ddd = evaluateFormula(s, variabless);
210 190 let DisableMateriallIcon = L ? sPackDetailPath : null;
211 191 // 盒子展长展开公式计算
212 192 const innerWidth = slaveRowData.sTypes === "6" ? evaluateFormula(sWidthFormula, variabless) : evaluateFormula(sLengthFormula, variabless);
... ... @@ -220,15 +200,16 @@ const Typesetting = props => {
220 200 const boxWidthOffset = evaluateFormula(sSecondLongitudinalOffset, variabless); // 第二列纵向偏移
221 201 const isVertical = sSettingMethod === "从上到下"; // true 表示竖向排列,false 表示横向排列 sSettingMethod === '从上到下'
222 202 const reference = sSGroupOffset === "首盒"; // 第三列参考
223   -
  203 + console.log(innerWidth,innerHeight,dFWidthOffset,dFLengthOffset,dSWidthOffset,dSLengthOffset,boxLengthOffset,boxWidthOffset,'typeSetting');
  204 +
224 205 // 计算内层盒子尺寸 加上间距
225   - let jInnerHeight = innerHeight + dXBJJ * 2;
226   - let jInnerWidth = innerWidth + dYBJJ * 2;
  206 + let jInnerHeight = innerHeight;
  207 + let jInnerWidth = innerWidth;
227 208 let dSvgBoxWidth = innerWidth;
228 209 let dSvgBoxHeight = innerHeight;
229 210 if (iFAngle === 90 || iFAngle === 270 || iSAngle === 90 || iSAngle === 270) {
230   - jInnerHeight = innerWidth + dYBJJ + dYBJJ;
231   - jInnerWidth = innerHeight + dXBJJ + dXBJJ;
  211 + jInnerHeight = innerWidth;
  212 + jInnerWidth = innerHeight;
232 213 // dSvgBoxHeight = jInnerHeight;
233 214 // dSvgBoxWidth = jInnerWidth;
234 215 }
... ... @@ -301,11 +282,6 @@ const Typesetting = props => {
301 282 }
302 283 }
303 284 }
304   -
305   - // 抵扣盒默认展示 svg
306   - // const isSvg = props.slaveRowData.sName === "扣抵盒";
307   - // 组装svg数据
308   -
309 285 const svgProps = {
310 286 ...props,
311 287 boxList,
... ... @@ -340,7 +316,7 @@ const Typesetting = props => {
340 316 </div>
341 317 </div>
342 318 );
343   -
  319 +
344 320 const createBox = (col, row, index, leftPosition, topPosition, offsetZ, icon) => (
345 321 <div
346 322 key={`${col}-${row}-${index}`}
... ... @@ -369,14 +345,23 @@ const Typesetting = props =&gt; {
369 345 justifyContent: "center",
370 346 alignItems: "center",
371 347 position: "absolute",
372   - left: `${dFLengthOffset + dYBJJ}px`,
373   - top: `${iFAngle === 90 || iFAngle === 270 ? dFLengthOffset : dFWidthOffset + dXBJJ}px`,
  348 + left: `${dFLengthOffset}px`,
  349 + top: `${iFAngle === 90 || iFAngle === 270 ? dFLengthOffset : dFWidthOffset}px`,
374 350 }}
375 351 >
376 352 <div style={{ transform: `rotateZ(${iFAngle}deg)` }}>
377   - {!sSvgPath ? <DynamicSVG {...svgProps} /> : <img src={sSvgPath} width={ `${iSAngle === 90 || iSAngle === 270 ? jInnerWidth : innerWidth}px`} height={ `${iFAngle === 90 || iFAngle === 270 ? jInnerHeight : innerHeight}px`} />}
  353 + {!sSvgPath ? (
  354 + <DynamicSVG {...svgProps} />
  355 + ) : (
  356 + <img
  357 + src={sSvgPath}
  358 + width={`${iSAngle === 90 || iSAngle === 270 ? jInnerWidth : innerWidth}px`}
  359 + height={`${iFAngle === 90 || iFAngle === 270 ? jInnerHeight : innerHeight}px`}
  360 + />
  361 + )}
378 362 </div>
379 363 </div>
  364 + {/* 次盒 */}
380 365 <div
381 366 key={`${col}-${row}-${index}-1`}
382 367 style={{
... ... @@ -386,14 +371,24 @@ const Typesetting = props =&gt; {
386 371 justifyContent: "center",
387 372 alignItems: "center",
388 373 position: "absolute",
389   - left: `${isVertical ? dSLengthOffset :iSAngle === 90 || iSAngle === 270 ? innerHeight + dFLengthOffset + dSLengthOffset + dYBJJ * 2: innerWidth + dFLengthOffset + dSLengthOffset + dYBJJ * 2}px`,
390   - top: `${
391   - isVertical ? jInnerHeight + dXBJJ + dFWidthOffset + dSWidthOffset : iSAngle === 90 || iSAngle === 270 ? dSWidthOffset : dSWidthOffset + dXBJJ
  374 + left: `${
  375 + isVertical ? dSLengthOffset : iSAngle === 90 || iSAngle === 270
  376 + ? innerHeight + dFLengthOffset + dSLengthOffset + dYBJJ
  377 + : innerWidth + dFLengthOffset + dSLengthOffset + dYBJJ
392 378 }px`,
  379 + top: `${isVertical ? jInnerHeight + dFWidthOffset + dSWidthOffset + dXBJJ: iSAngle === 90 || iSAngle === 270 ? dSWidthOffset : dSWidthOffset}px`,
393 380 }}
394 381 >
395 382 <div style={{ transform: `rotateZ(${iSAngle}deg)` }}>
396   - {!sSvgPath ? <DynamicSVG {...svgProps} /> : <img src={sSvgPath} width={ `${iSAngle === 90 || iSAngle === 270 ? jInnerWidth : innerWidth}px`} height={`${iSAngle === 90 || iSAngle === 270 ? jInnerHeight : innerHeight}px`} />}
  383 + {!sSvgPath ? (
  384 + <DynamicSVG {...svgProps} />
  385 + ) : (
  386 + <img
  387 + src={sSvgPath}
  388 + width={`${iSAngle === 90 || iSAngle === 270 ? jInnerWidth : innerWidth}px`}
  389 + height={`${iSAngle === 90 || iSAngle === 270 ? jInnerHeight : innerHeight}px`}
  390 + />
  391 + )}
397 392 </div>
398 393 </div>
399 394 </div>
... ... @@ -426,8 +421,8 @@ const Typesetting = props =&gt; {
426 421 justifyContent: "center",
427 422 alignItems: "center",
428 423 position: "absolute",
429   - left: `${dFLengthOffset + dYBJJ}px`,
430   - top: `${dFWidthOffset + dXBJJ}px`,
  424 + left: `${dFLengthOffset}px`,
  425 + top: `${dFWidthOffset}px`,
431 426 }}
432 427 >
433 428 {/* <img src={icon} width="100%" height="100%" /> */}
... ... @@ -486,14 +481,13 @@ const Typesetting = props =&gt; {
486 481 }, [radioValue, slaveRowData, masterData, selectedNode, slaveData]);
487 482 // 生成里层 div 的数组
488 483 const innerDivs = [];
489   -
490   - console.log(cols,rows,'cols');
491   -
  484 + console.log("🚀 ~ typeSetting:",cols, rows,dZBLB,dSBLB)
  485 +
492 486 for (let col = 0; col < cols; col++) {
493 487 for (let row = 0; row < rows; row++) {
494   - const leftPosition = col * innerWidthCombined;
495   - const topPosition = row * innerHeightCombined;
496   - innerDivs.push(createBox(col, row, 1, leftPosition + dZBLB, topPosition + dSBLB, iFAngle, DisableMateriallIcon));
  488 + const leftPosition = col * (innerWidthCombined + dYBJJ);
  489 + const topPosition = row * (innerHeightCombined + dXBJJ);
  490 + innerDivs.push(createBox(col, row, 1, leftPosition, topPosition, iFAngle, DisableMateriallIcon));
497 491 }
498 492 // 如果可以放下首盒
499 493 if (remaining) {
... ... @@ -506,10 +500,10 @@ const Typesetting = props =&gt; {
506 500 leftPosition = col * innerWidthCombined;
507 501 topPosition = rows * innerHeightCombined;
508 502 } else {
509   - leftPosition = col * innerWidthCombined;
510   - topPosition = rows * innerHeightCombined;
  503 + leftPosition = col * (innerWidthCombined + dYBJJ); ;
  504 + topPosition = rows *( innerHeightCombined + dXBJJ);
511 505 }
512   - innerDivs.push(createBoxOne(col, rows, 3, leftPosition + dZBLB, topPosition + dSBLB, iFAngle, DisableMateriallIcon));
  506 + innerDivs.push(createBoxOne(col, rows, 3, leftPosition, topPosition, iFAngle, DisableMateriallIcon));
513 507 } else {
514 508 for (let index = 0; index < rows; index++) {
515 509 // 先默认为首盒参考
... ... @@ -522,7 +516,7 @@ const Typesetting = props =&gt; {
522 516 topPosition = index * (innerHeightCombined + boxWidthOffset + dSWidthOffset);
523 517 leftPosition = cols * (innerWidthCombined + boxLengthOffset + dSLengthOffset);
524 518 }
525   - innerDivs.push(createDiv(col, index, 3, leftPosition + dZBLB, topPosition + dSBLB, iFAngle, DisableMateriallIcon));
  519 + innerDivs.push(createDiv(col, index, 3, leftPosition + (col * dYBJJ), topPosition + (index * dXBJJ), iFAngle, DisableMateriallIcon));
526 520 }
527 521 }
528 522 }
... ... @@ -533,20 +527,19 @@ const Typesetting = props =&gt; {
533 527 if (maxLength > innerWidth) {
534 528 let leftPosition = 0;
535 529 let topPosition = 0;
536   -
537   - innerDivs.push(createBoxOne(0, rows, 3, leftPosition + dZBLB, topPosition + dSBLB, iFAngle, DisableMateriallIcon));
  530 + innerDivs.push(createBoxOne(0, rows, 3, leftPosition , topPosition , iFAngle, DisableMateriallIcon));
538 531 }
539 532 }
540   - // 如果第一列
  533 + // 如果第一列
541 534 if (rows === 0) {
542   - const maxWidth = Number(slaveDataDetail?.dMaxWidth)
  535 + const maxWidth = Number(slaveDataDetail?.dMaxWidth);
543 536 if (maxWidth > innerHeight) {
544   - let leftPosition = 0;
  537 + let leftPosition = 0;
545 538 let topPosition = 0;
546   - innerDivs.push(createBoxOne(cols, 0, 3, leftPosition + dZBLB, topPosition + dSBLB, iFAngle, DisableMateriallIcon));
  539 + innerDivs.push(createBoxOne(cols, 0, 3, leftPosition , topPosition, iFAngle, DisableMateriallIcon));
547 540 }
548 541 }
549   - console.log(cols, '列数', rows, '行数');
  542 +
550 543 // 判断展开长展开宽是否变化
551 544 if (dPartsLength !== innerWidth && !innerDivs.length) {
552 545 setDPartsLength(innerWidth);
... ... @@ -562,11 +555,11 @@ const Typesetting = props =&gt; {
562 555 const propsDataHeight = Number(propsData.props.style.height.slice(0, -2));
563 556 const propsDataTop = Number(propsData.props.style.top.slice(0, -2));
564 557 // 判断列是否是单独的
565   - const newMaterialLength = propsDataLeft + (remaining ? jInnerWidth : innerWidthCombined) - dYBJJ; // 原纸长
566   - const newMaterialWidth = propsDataTop + propsDataHeight - dSBLB;
  558 + const newMaterialLength = parseFloat(propsDataLeft + (remaining ? jInnerWidth : innerWidthCombined) + dSBLB + dXBLB).toFixed(2); // 原纸长
  559 + const newMaterialWidth = parseFloat(propsDataTop + propsDataHeight + dZBLB + dYBLB).toFixed(2);
567 560  
568 561 // 计算开数
569   - const dSinglePQty = isVertical
  562 + let dSinglePQty = isVertical
570 563 ? remaining
571 564 ? cols + cols * (rows * 2)
572 565 : cols * (rows * 2)
... ... @@ -574,6 +567,10 @@ const Typesetting = props =&gt; {
574 567 ? rows + rows * (cols * 2)
575 568 : rows * (cols * 2);
576 569 // 计算竖版数量
  570 + if ((cols === 1 && rows === 0 )|| (cols === 0 && rows === 1 )) {
  571 + dSinglePQty = 1
  572 + }
  573 +
577 574 const dHorizontalType = isVertical ? cols : remaining ? cols * 2 + 1 : cols * 2;
578 575 const dPortraitType = isVertical ? (remaining ? rows * 2 + 1 : rows * 2) : remaining ? rows : rows;
579 576  
... ... @@ -643,15 +640,15 @@ const Typesetting = props =&gt; {
643 640 setTimeout(() => {
644 641 if (typesettingBox.current) {
645 642 typesettingBox.current.style.backgroundColor = "#b7e0ff";
646   - typesettingBox.current.style.marginTop = dSBLB + "px";
647   - typesettingBox.current.style.marginLeft = dZBLB + "px";
  643 + // typesettingBox.current.style.margin = [dSBLB, dYBLB, dXBLB, dZBLB].map(item => item + "px").join(" ");
648 644 typesettingBox.current.style.width = newMaterialLength + dYBLB + "px";
649 645 typesettingBox.current.style.height = newMaterialWidth + dXBLB + "px";
  646 + // typesettingBox.current.style.top = dSBLB + "px";
  647 + // typesettingBox.current.style.left = dZBLB + "px";
650 648 }
651 649 if (typesettingBoxs.current) {
652   - typesettingBoxs.current.style.backgroundColor = "#b7e0ff";
653   - typesettingBoxs.current.style.marginTop = dSBLB + "px";
654   - typesettingBoxs.current.style.marginLeft = dZBLB + "px";
  650 + typesettingBoxs.current.style.backgroundColor = "#b7e0ff";
  651 + // typesettingBox.current.style.margin = [dSBLB, dYBLB, dXBLB, dZBLB].map(item => item + "px").join(" ");
655 652 typesettingBoxs.current.style.width = newMaterialLength + dYBLB + "px";
656 653 typesettingBoxs.current.style.height = newMaterialWidth + dXBLB + "px";
657 654 }
... ... @@ -673,11 +670,11 @@ const Typesetting = props =&gt; {
673 670 isShow,
674 671 "isMax"
675 672 );
676   - const confirmParam = commonFunc.showLocalMessage(props, 'confirmParam', '排版尺寸大于上机尺寸,请确认参数!');
  673 + const confirmParam = commonFunc.showLocalMessage(props, "confirmParam", "排版尺寸大于上机尺寸,请确认参数!");
677 674  
678 675 if (isCustomized && !isShow) {
679 676 if (isMobile) return;
680   - message.error( confirmParam);
  677 + message.error(confirmParam);
681 678 }
682 679 const onClick = () => {
683 680 if (isMobile) return;
... ... @@ -716,11 +713,13 @@ const Typesetting = props =&gt; {
716 713 right: 0,
717 714 zIndex: 10,
718 715 maxHeight: `${clientHeight}`,
719   - padding: `${dSBLB}px ${dYBLB}px ${dXBLB}px ${dZBLB}px`,
  716 + // padding: `${dSBLB}px ${dYBLB}px ${dXBLB}px ${dZBLB}px`,
720 717 }}
721 718 >
722 719 <div style={style} ref={boxRef}>
723   - {boxList.length ? innerDivs : []}
  720 + <div style={{ position: "absolute", width: `${materialLength}px`, height: `${materialWidth}px`, marginLeft:`${dZBLB}px`, marginTop:`${dSBLB}px`,marginRight:`${dYBLB}px`, marginBottom:`${dXBLB}px` }}>
  721 + {boxList.length ? innerDivs : []}
  722 + </div>
724 723 <div
725 724 ref={typesettingBox}
726 725 style={{
... ... @@ -745,7 +744,7 @@ const Typesetting = props =&gt; {
745 744 transformOrigin: "top left",
746 745 }}
747 746 >
748   - <span style={{ color: "red", display: "inline-block", width: "50px" }}>{materialLength}</span>
  747 + <span style={{ color: "red", display: "inline-block", width: "100px" }}>{materialLength}</span>
749 748 <div className={styles.maxWidthLeft}>
750 749 <VerticalRightOutlined />
751 750 <div
... ... @@ -1004,7 +1003,7 @@ const Typesetting = props =&gt; {
1004 1003 wordBreak: "break-all", // 确保长单词换行
1005 1004 }}
1006 1005 >
1007   - {confirmParam}
  1006 + {confirmParam}
1008 1007 </span>
1009 1008 </div>
1010 1009 )}
... ... @@ -1037,7 +1036,9 @@ const Typesetting = props =&gt; {
1037 1036 }}
1038 1037 >
1039 1038 <div style={{ ...style, position: "absolute", left: "50%" }} ref={boxsRef}>
1040   - {boxList.length ? innerDivs : []}
  1039 + <div style={{ position: "absolute", width: `${materialLength}px`, height: `${materialWidth}px`, marginLeft:`${dZBLB}px`, marginTop:`${dSBLB}px`,marginRight:`${dYBLB}px`, marginBottom:`${dXBLB}px`}}>
  1040 + {boxList.length ? innerDivs : []}
  1041 + </div>
1041 1042 <div
1042 1043 ref={typesettingBoxs}
1043 1044 style={{
... ... @@ -1060,7 +1061,7 @@ const Typesetting = props =&gt; {
1060 1061 color: "#333",
1061 1062 }}
1062 1063 >
1063   - <span style={{ color: "red", display: "inline-block", width: "50px" }}>{materialLength}</span>
  1064 + <span style={{ color: "red", display: "inline-block", width: "100px" }}>{materialLength}</span>
1064 1065 <div className={styles.maxWidthLeft}>
1065 1066 <LeftOutlined style={{ fontSize: "20px" }} />
1066 1067 <div
... ... @@ -1120,11 +1121,11 @@ const Typesetting = props =&gt; {
1120 1121 color: "#333",
1121 1122 }}
1122 1123 >
1123   - <span style={{ color: "red", display: "inline-block", width: "50px" }}>{materialWidth}</span>
  1124 + <span style={{ color: "red", display: "inline-block", width: "100px" }}>{materialWidth}</span>
1124 1125 <div
1125 1126 style={{
1126 1127 position: "absolute",
1127   - top: `-${materialWidth / 2 - dSBLB}px`,
  1128 + top: `-${materialWidth / 2 }px`,
1128 1129 left: "14px",
1129 1130 width: "20px",
1130 1131 }}
... ... @@ -1135,7 +1136,7 @@ const Typesetting = props =&gt; {
1135 1136 height: `${materialWidth * 0.3}px`,
1136 1137 position: "absolute",
1137 1138 right: "10px",
1138   - top: `${materialWidth / 2 - dSBLB + 8}px`,
  1139 + top: `${materialWidth / 2 + 8}px`,
1139 1140 width: "2px",
1140 1141 backgroundColor: "#333",
1141 1142 }}
... ... @@ -1146,7 +1147,7 @@ const Typesetting = props =&gt; {
1146 1147 width: "30px",
1147 1148 backgroundColor: "#333",
1148 1149 position: "absolute",
1149   - top: `${materialWidth / 2 - dSBLB}px`,
  1150 + top: `${materialWidth / 2 }px`,
1150 1151 right: "-4.5px",
1151 1152 }}
1152 1153 />
... ...
src/components/QuickQuote/index.jsx
... ... @@ -215,6 +215,7 @@ const QuickQuoteEvent = props =&gt; {
215 215 upAbleConfigsExtra: sColumnNameConfig,
216 216 };
217 217 } else {
  218 + if(!slaveData[0]) return
218 219 const sColumnNameConfig = commonUtils.convertStrToObj(slaveData[0].sColumnNameConfig, []).map(item => ({
219 220 ...item,
220 221 iColValue: item.iColValue || 6,
... ... @@ -2004,7 +2005,7 @@ const BoxComponent = props =&gt; {
2004 2005 slaveNewData.forEach(x => {
2005 2006 let key = 0;
2006 2007 if (x.sAssignFormula) {
2007   - key = evaluateFormula(x.sAssignFormula, variables);
  2008 + key = parseFloat(evaluateFormula(x.sAssignFormula, variables)).toFixed(2);
2008 2009 slaveRowData[x.sName] = key;
2009 2010 } else {
2010 2011 key = slaveRowData[x.sName];
... ...