Commit 2b172e9599ef28a2cb4724a2c2e142ca0a994652

Authored by 陈鑫涛
1 parent 2ef8caa1

未选排版方法时计算最优排法

src/components/Common/Typesetting/typesetting.js
... ... @@ -205,7 +205,6 @@ const Typesetting = props => {
205 205 const boxWidthOffset = evaluateFormula(sSecondLongitudinalOffset, variabless); // 第二列纵向偏移
206 206 const isVertical = sSettingMethod === "从上到下"; // true 表示竖向排列,false 表示横向排列 sSettingMethod === '从上到下'
207 207 const reference = sSGroupOffset === "首盒"; // 第三列参考
208   - console.log(reference,'reference')
209 208 // 计算内层盒子尺寸 加上间距
210 209 let jInnerHeight = innerHeight;
211 210 let jInnerWidth = innerWidth;
... ...
src/components/QuickQuote/index.jsx
... ... @@ -1460,7 +1460,12 @@ const ContentComponent = props => {
1460 1460 if (!boxModelList.length) return;
1461 1461 setActiveKey(0);
1462 1462 }, [sAllPartsName]);
1463   -
  1463 + useEffect(() => {
  1464 + props.setState(pre => ({
  1465 + ...pre,
  1466 + boxModelKey: activeKey,
  1467 + }));
  1468 + }, [activeKey]);
1464 1469 const dividerProps = {
1465 1470 className: styles.divider,
1466 1471 orientation: "left",
... ... @@ -2763,18 +2768,48 @@ const ManyComponent = props => {
2763 2768  
2764 2769 // 核价事件
2765 2770 const onCalcPrice = () => {
  2771 + const { state } = props;
  2772 + const { masterData = {}, slaveConfig, slaveData = [], selectedNode = {}, backendConfig = {}, boxModelKey = 0, bestAlgorithm,activeKey } = state;
  2773 + if (activeKey === 0) {
  2774 + const radios = GetBestAlgorithm(props);
  2775 + slaveData[boxModelKey] = {
  2776 + ...slaveData[boxModelKey],
  2777 + radioValue: radios.sCode,
  2778 + };
  2779 + props.setState(pre => ({ ...pre, slaveData, bestAlgorithm: commonUtils.createSid(),onCalcPrices:true }));
  2780 + } else {
2766 2781 const addState = {
2767 2782 ...props.onGetAllDelData(),
2768 2783 manyDataCache: [],
2769 2784 };
2770   -
2771 2785 props.onSaveState({
2772 2786 masterData: { ...props.masterData, handleType: props.masterData.handleType || "update" },
2773 2787 calcPriceTime: commonUtils.createSid(),
2774 2788 ...addState,
2775 2789 });
  2790 + props.setState(pre => ({ ...pre,onCalcPrices:false }));
  2791 + }
  2792 +
  2793 + // setTimeout(() => {
  2794 +
  2795 + // }, 500);
  2796 +
2776 2797 };
  2798 + const { bestAlgorithm,onCalcPrices } = state;
  2799 + useEffect(() => {
  2800 + if (!bestAlgorithm) return
  2801 + if (!onCalcPrices) return
  2802 + const addState = {
  2803 + ...props.onGetAllDelData(),
  2804 + manyDataCache: [],
  2805 + };
2777 2806  
  2807 + props.onSaveState({
  2808 + masterData: { ...props.masterData, handleType: props.masterData.handleType || "update" },
  2809 + calcPriceTime: commonUtils.createSid(),
  2810 + ...addState,
  2811 + });
  2812 + }, [bestAlgorithm,onCalcPrices]);
2778 2813 useEffect(() => {
2779 2814 if (props.calcPriceTime) {
2780 2815 props.onSaveState({ calcPriceTime: undefined });
... ... @@ -3326,5 +3361,514 @@ const BackendParamsExtraComponent = props => {
3326 3361 </>
3327 3362 );
3328 3363 };
  3364 +const GetBestAlgorithm = props => {
  3365 + const { state } = props;
  3366 + const { masterData = {}, slaveConfig, slaveData = [], selectedNode = {}, backendConfig = {}, boxModelKey = 0 } = state;
  3367 + if (!slaveConfig) return "";
  3368 + const { sParentFieldsName, sBoxModel, printParamsId } = backendConfig;
  3369 + const slaveRowData = slaveData.filter(item => item.sTreeNodeName === selectedNode.showName)[boxModelKey] || {};
  3370 + if (!slaveRowData) return null;
  3371 + const { sColumnNameConfigExclusion } = slaveRowData;
  3372 + console.log("🚀 ~ slaveRowData:", slaveRowData);
  3373 + const calcMethodData = commonUtils.convertStrToObj(sColumnNameConfigExclusion, []);
  3374 + let {
  3375 + dSBLB = 0, // 上边留白
  3376 + dXBLB = 0, // 下边留白
  3377 + dZBLB = 0, // 左边留白
  3378 + dYBLB = 0, // 右边留白
  3379 + // dXBJJ, // 上边距
  3380 + dXBJJ = 0, // 下边距
  3381 + // dYBJJ, // 左边距
  3382 + dYBJJ = 0, // 右边距
  3383 + sLengthFormula, // 盒长公式
  3384 + sWidthFormula, // 盒宽公式
  3385 + sPackDetailPath,
  3386 + sColumnNameConfig,
  3387 + bAdvancedSetting, // 高级设置
  3388 + sSvgPath,
  3389 + dL = 0,
  3390 + dW = 0,
  3391 + } = slaveRowData;
  3392 + if (selectedNode && selectedNode.sTypeKey === "juantong") {
  3393 + dXBLB = dSBLB;
  3394 + dZBLB = 0;
  3395 + dYBLB = 0;
  3396 + }
  3397 + let { dHorizontal, dPortrait, dHorizontalType, dPortraitType } = slaveRowData;
  3398 + const slaveDataDetail = slaveRowData;
  3399 + const maxWidth = Number(slaveDataDetail?.dMaxLength);
  3400 + const maxHeight = Number(slaveDataDetail?.dMaxWidth);
  3401 +
  3402 + let outerWidth = Number(slaveDataDetail?.dMaxLength); // 默认取最大上机尺寸
  3403 + let outerHeight = Number(slaveDataDetail?.dMaxWidth); // 默认取最大上机尺寸
  3404 + const L = slaveRowData.dL ? Number(dL) : Number(masterData?.dLength) || 0;
  3405 + const W = slaveRowData.dW ? Number(dW) : masterData?.dWidth || 0;
  3406 + const H = masterData?.dWidth || 0;
  3407 + const D = masterData?.dHeight || 0;
  3408 + // 动态计算公式值
  3409 + const evaluateFormula = (formula, variables) => {
  3410 + if (!formula) return 0; // 如果公式为空,返回0
  3411 + try {
  3412 + // 提取公式中的变量名
  3413 + const variableNames = formula.match(/\b[a-zA-Z_][a-zA-Z0-9_]*\b/g) || [];
  3414 + // 构建函数参数
  3415 + const params = variableNames.join(",") + ",Math";
  3416 + // 替换公式中的变量为实际值
  3417 + const func = new Function(params, `return ${formula}`);
  3418 + // 提取变量值
  3419 + const args = variableNames.map(name => Number(variables[name]) || 0);
  3420 + // 执行函数并返回结果
  3421 + return func(...args, Math);
  3422 + } catch (error) {
  3423 + return 0;
  3424 + }
  3425 + };
  3426 +
  3427 + // 计算公式值
  3428 + const variables = {
  3429 + L,
  3430 + W,
  3431 + H,
  3432 + D,
  3433 + ...slaveRowData,
  3434 + };
  3435 + let boxList = [];
  3436 + if (slaveRowData.sColumnNameConfig) {
  3437 + const slaveNewData = slaveRowData.upAbleConfigsExtra || JSON.parse(slaveRowData.sColumnNameConfig);
  3438 + const tables = [
  3439 + { name: "盒型类别", value: slaveRowData.sBoxType, type: null },
  3440 + { name: "盒身", value: slaveRowData.sBoxBody, type: slaveRowData.sTypes },
  3441 + { name: "盒长", value: L, type: null },
  3442 + { name: "盒宽", value: W, type: null },
  3443 + { name: "盒高", value: D, type: null },
  3444 + ];
  3445 + const titleList1 = [
  3446 + { name: "上方盒舌", value: "dSFHS" },
  3447 + { name: "盒底组件", value: "dHDC" },
  3448 + { name: "下方盒舌", value: "dXFHS" },
  3449 + { name: "左(上)插位组件", value: "dZSCW" },
  3450 + { name: "左贴边位", value: "dZTBW" },
  3451 + { name: "左(下)插位组件", value: "dZXCW" },
  3452 + { name: "右(上)插位组件", value: "dYSCW" },
  3453 + { name: "右贴边位", value: "dYTBW" },
  3454 + { name: "右(下)插位组件", value: "dYXCW" },
  3455 + ];
  3456 + slaveNewData.forEach(x => {
  3457 + let key = 0;
  3458 + if (x.sAssignFormula) {
  3459 + key = parseFloat(evaluateFormula(x.sAssignFormula, variables)).toFixed(2) || 0;
  3460 + } else {
  3461 + key = slaveRowData[x.sName];
  3462 + }
  3463 + boxList.push({
  3464 + value: key,
  3465 + sName: titleList1.find(item => item.value === x.sName)?.name || "",
  3466 + isEditable: true,
  3467 + isSelect: false,
  3468 + selectValue: null,
  3469 + selectLabel: "",
  3470 + selectImage: null,
  3471 + type: x.sTypes || null,
  3472 + show: true,
  3473 + sCode: titleList1.find(item => item.value === x.sName)?.value || "",
  3474 + showName: x.showName, // 参数名称
  3475 + });
  3476 + });
  3477 + tables.forEach(x => {
  3478 + boxList.push({
  3479 + value: x.value,
  3480 + sName: x.name,
  3481 + isEditable: true,
  3482 + isSelect: false,
  3483 + selectValue: null,
  3484 + selectLabel: "",
  3485 + selectImage: null,
  3486 + type: x.type || null,
  3487 + show: true,
  3488 + showName: x.name, // 参数名称
  3489 + });
  3490 + });
  3491 + }
  3492 +
  3493 + const result = boxList?.reduce((acc, { sCode, value }) => ({ ...acc, [sCode]: Number(value) }), {});
  3494 +
  3495 + // 计算表达式结果
  3496 + const variabless = {
  3497 + ...variables,
  3498 + ...result,
  3499 + };
  3500 + Object.keys(variabless).forEach(key => {
  3501 + if (variabless[key] === null || variabless[key] === undefined || variabless[key] === "") {
  3502 + variabless[key] = 0;
  3503 + }
  3504 + });
  3505 + const calculateLayout = (radioValue, i) => {
  3506 + const innerWidth = slaveRowData.sTypes === "6" ? evaluateFormula(sWidthFormula, variabless) : evaluateFormula(sLengthFormula, variabless);
  3507 + const innerHeight = slaveRowData.sTypes === "6" ? evaluateFormula(sLengthFormula, variabless) : evaluateFormula(sWidthFormula, variabless);
  3508 + const { sSettingMethod, sSGroupOffset, iFAngle, iSAngle, sSecondorizontalOffset, sSecondLongitudinalOffset } = radioValue ? radioValue : {};
  3509 + const dFWidthOffset = evaluateFormula(radioValue?.sFWidthOffset, variabless); // 首盒纵向偏移
  3510 + const dFLengthOffset = evaluateFormula(radioValue?.sFLengthOffset, variabless); // 首盒横向偏移
  3511 + const dSWidthOffset = evaluateFormula(radioValue?.sSWidthOffset, variabless); // 次盒纵向偏移
  3512 + const dSLengthOffset = evaluateFormula(radioValue?.sSLengthOffset, variabless); // 次盒横向偏移
  3513 + const boxLengthOffset = evaluateFormula(sSecondorizontalOffset, variabless); // 第二列横向偏移
  3514 + const boxWidthOffset = evaluateFormula(sSecondLongitudinalOffset, variabless); // 第二列纵向偏移
  3515 + const isVertical = sSettingMethod === "从上到下"; // true 表示竖向排列,false 表示横向排列 sSettingMethod === '从上到下'
  3516 + const reference = sSGroupOffset === "首盒"; // 第三列参考
  3517 + // 计算内层盒子尺寸 加上间距
  3518 + let jInnerHeight = innerHeight;
  3519 + let jInnerWidth = innerWidth;
  3520 + let dSvgBoxWidth = innerWidth;
  3521 + let dSvgBoxHeight = innerHeight;
  3522 + const isRrotate = iFAngle === 90 || iFAngle === 270 || iSAngle === 90 || iSAngle === 270;
  3523 + if (iFAngle === 90 || iFAngle === 270 || iSAngle === 90 || iSAngle === 270) {
  3524 + jInnerHeight = innerWidth;
  3525 + jInnerWidth = innerHeight;
  3526 + }
  3527 + if (state.selectedNode.sTypeKey === "kapai" || state.selectedNode.sTypeKey === "juantong") {
  3528 + jInnerHeight = innerHeight;
  3529 + jInnerWidth = innerWidth;
  3530 + }
  3531 +
  3532 + const innerHeightCombined =
  3533 + (isVertical ? jInnerHeight * 2 + dSWidthOffset + dFWidthOffset : Math.max(jInnerHeight + dFWidthOffset, jInnerHeight + dSWidthOffset)) + dXBJJ; // 计算内层盒子高度 从上向下排列 取首盒加偏移量和次盒加偏移量最大的值 从左往右排列 盒子尺寸 * 2 加上首盒偏移量和次盒偏移量
  3534 + // 计算内层盒子宽度 从上向下排列 取首盒加偏移量和次盒加偏移量最大的值 从左往右排列 盒子尺寸 * 2 加上首盒偏移量和次盒偏移量
  3535 + const innerWidthCombined =
  3536 + (isVertical ? Math.max(jInnerWidth + dFLengthOffset, jInnerWidth + dSLengthOffset) : jInnerWidth * 2 + dSLengthOffset + dFLengthOffset) + dYBJJ;
  3537 + // 加上间距后的最大盒子长宽 计算每列可以放多少个组合 需要计算间距
  3538 + // 每个盒子加上边距 和第二组偏移量 如果根据次盒再加上次盒偏移量
  3539 + const dSWidthOffsetCombined = innerWidthCombined + boxLengthOffset + (reference ? 0 : dSLengthOffset);
  3540 + let cols = dSWidthOffsetCombined === 0 ? 0 : Math.floor(outerWidth / dSWidthOffsetCombined);
  3541 + const rowsCombined = innerHeightCombined + boxWidthOffset + (reference ? 0 : dSWidthOffset);
  3542 + let rows = rowsCombined === 0 ? 0 : Math.floor(outerHeight / rowsCombined);
  3543 + let colsMaxLength =
  3544 + cols * (innerWidthCombined + boxLengthOffset + (reference ? 0 : dSLengthOffset) + dYBJJ) + dZBLB + dYBLB - (reference ? 0 : dSLengthOffset);
  3545 + let rowsMaxLength =
  3546 + rows * (innerHeightCombined + boxWidthOffset + (reference ? 0 : dSWidthOffset) + dXBJJ) + dSBLB + dXBLB - (reference ? 0 : dSWidthOffset);
  3547 + while (colsMaxLength > outerWidth && cols > 0) {
  3548 + cols = cols - 1;
  3549 + colsMaxLength = cols * (innerWidthCombined + boxLengthOffset + (reference ? 0 : dSLengthOffset) + dYBJJ);
  3550 + }
  3551 +
  3552 + while (rowsMaxLength > outerHeight && rows > 0) {
  3553 + rows = rows - 1;
  3554 + rowsMaxLength = rows * (innerHeightCombined + boxWidthOffset + (reference ? 0 : dSWidthOffset) + dXBJJ);
  3555 + }
  3556 + // 最大上机长 上机宽 开料尺寸
  3557 + // 计算剩余空间 每组都算上偏移量 那么剩余需要加上后面偏移的总量
  3558 + const remainingWidth = outerWidth - colsMaxLength + (boxLengthOffset + (reference ? 0 : dSLengthOffset));
  3559 + const remainingHeight = outerHeight - rowsMaxLength + (boxWidthOffset + (reference ? 0 : dSWidthOffset));
  3560 + //剩余量能不能放一下单独一个
  3561 + const commonHeightCheck = remainingHeight > jInnerHeight + dXBJJ;
  3562 + const commonWidthCheck = remainingWidth > jInnerWidth + dYBJJ;
  3563 + const isCustomized = bAdvancedSetting;
  3564 + let remaining = isVertical ? commonHeightCheck : commonWidthCheck;
  3565 +
  3566 + // 判断
  3567 + // const remaining = false;
  3568 + const isOdd = num => {
  3569 + return num % 2 !== 0;
  3570 + };
  3571 +
  3572 + // 是否定制
  3573 + if (isCustomized) {
  3574 + if (isVertical) {
  3575 + cols = dHorizontal || 0;
  3576 + rows = dPortrait ? Math.trunc(dPortrait / 2) : 0;
  3577 + if (isOdd(dPortrait)) {
  3578 + remaining = true;
  3579 + } else {
  3580 + remaining = false;
  3581 + }
  3582 + } else {
  3583 + cols = dHorizontal ? Math.trunc(dHorizontal / 2) : 0;
  3584 + rows = dPortrait || 0;
  3585 + if (isOdd(dHorizontal)) {
  3586 + remaining = true;
  3587 + } else {
  3588 + remaining = false;
  3589 + }
  3590 + }
  3591 + }
  3592 + const createDiv = (col, row, index, leftPosition, topPosition, offsetZ, icon) => (
  3593 + <div
  3594 + key={`${col}-${row}-${index}`}
  3595 + style={{
  3596 + width: `${jInnerWidth}px`,
  3597 + height: `${jInnerHeight}px`,
  3598 + // backgroundColor: "#fff",
  3599 + display: "flex",
  3600 + justifyContent: "center",
  3601 + alignItems: "center",
  3602 + position: "absolute",
  3603 + left: `${leftPosition}px`,
  3604 + top: `${topPosition}px`,
  3605 +
  3606 + zIndex: 10,
  3607 + }}
  3608 + onDoubleClick={() => {
  3609 + onClick();
  3610 + }}
  3611 + >
  3612 + <div style={{ transform: `rotateZ(${offsetZ}deg)` }}></div>
  3613 + </div>
  3614 + );
  3615 +
  3616 + const createBox = (col, row, index, leftPosition, topPosition, offsetZ, icon) => (
  3617 + <div
  3618 + key={`${col}-${row}-${index}`}
  3619 + style={{
  3620 + width: `${innerWidthCombined}px`,
  3621 + height: `${innerHeightCombined}px`,
  3622 + display: "flex",
  3623 + justifyContent: "center",
  3624 + alignItems: "center",
  3625 + position: "absolute",
  3626 + overflow: "hidden",
  3627 + left: `${calculateLeftPosition(col, reference, isVertical, leftPosition, dYBJJ, dSLengthOffset)}px`,
  3628 + top: `${calculateTopPosition(row, reference, isVertical, topPosition, dSWidthOffset, dXBJJ)}px`,
  3629 + zIndex: 10,
  3630 + }}
  3631 + onDoubleClick={() => {
  3632 + onClick();
  3633 + }}
  3634 + >
  3635 + <div
  3636 + key={`${col}-${row}-${index}`}
  3637 + style={{
  3638 + width: `${iSAngle === 90 || iSAngle === 270 ? jInnerWidth : innerWidth}px`,
  3639 + height: `${iFAngle === 90 || iFAngle === 270 ? jInnerHeight : innerHeight}px`,
  3640 + display: "flex",
  3641 + justifyContent: "center",
  3642 + alignItems: "center",
  3643 + position: "absolute",
  3644 + left: `${dFLengthOffset}px`,
  3645 + top: `${iFAngle === 90 || iFAngle === 270 ? dFLengthOffset : dFWidthOffset}px`,
  3646 + }}
  3647 + >
  3648 + <div style={{ transform: `rotateZ(${iFAngle}deg)` }}></div>
  3649 + </div>
  3650 + {/* 次盒 */}
  3651 + <div
  3652 + key={`${col}-${row}-${index}-1`}
  3653 + style={{
  3654 + width: `${iSAngle === 90 || iSAngle === 270 ? jInnerWidth : innerWidth}px`,
  3655 + height: `${iSAngle === 90 || iSAngle === 270 ? jInnerHeight : innerHeight}px`,
  3656 + display: "flex",
  3657 + justifyContent: "center",
  3658 + alignItems: "center",
  3659 + position: "absolute",
  3660 + left: `${
  3661 + isVertical
  3662 + ? dSLengthOffset
  3663 + : iSAngle === 90 || iSAngle === 270
  3664 + ? innerHeight + dFLengthOffset + dSLengthOffset + dYBJJ
  3665 + : innerWidth + dFLengthOffset + dSLengthOffset + dYBJJ
  3666 + }px`,
  3667 + top: `${
  3668 + isVertical ? jInnerHeight + dFWidthOffset + dSWidthOffset + dXBJJ : iSAngle === 90 || iSAngle === 270 ? dSWidthOffset : dSWidthOffset
  3669 + }px`,
  3670 + }}
  3671 + ></div>
  3672 + </div>
  3673 + );
  3674 + const createBoxOne = (col, row, index, leftPosition, topPosition, offsetZ, icon) => (
  3675 + <div
  3676 + key={`${col}-${row}-${index}`}
  3677 + style={{
  3678 + width: `${jInnerWidth}px`,
  3679 + height: `${jInnerHeight}px`,
  3680 + display: "flex",
  3681 + justifyContent: "center",
  3682 + alignItems: "center",
  3683 + position: "absolute",
  3684 + overflow: "hidden",
  3685 + left: `${calculateLeftPosition(col, reference, isVertical, leftPosition, dYBJJ, dSLengthOffset)}px`,
  3686 + top: `${calculateTopPosition(row, reference, isVertical, topPosition, dSWidthOffset, dXBJJ)}px`,
  3687 + zIndex: 10,
  3688 + }}
  3689 + onDoubleClick={() => {
  3690 + onClick();
  3691 + }}
  3692 + >
  3693 + <div
  3694 + key={`${col}-${row}-${index}`}
  3695 + style={{
  3696 + width: `${jInnerWidth}px`,
  3697 + height: `${jInnerHeight}px`,
  3698 + display: "flex",
  3699 + justifyContent: "center",
  3700 + alignItems: "center",
  3701 + position: "absolute",
  3702 + left: `${dFLengthOffset}px`,
  3703 + top: `${dFWidthOffset}px`,
  3704 + }}
  3705 + ></div>
  3706 + </div>
  3707 + );
  3708 + // 计算左偏移
  3709 + const calculateLeftPosition = (col, reference, isVertical, leftPosition, dYBJJ, dSLengthOffset) => {
  3710 + console.log(isVertical, reference, "reference");
  3711 + if (isVertical) {
  3712 + if (reference) {
  3713 + return col === 0 ? leftPosition : leftPosition + dYBJJ * col;
  3714 + }
  3715 + return col === 0 ? leftPosition : leftPosition + (boxLengthOffset + dYBJJ) * col;
  3716 + } else {
  3717 + if (reference) {
  3718 + return col === 0 ? leftPosition : leftPosition + dYBJJ * col;
  3719 + }
  3720 + return col === 0 ? leftPosition : leftPosition + (boxLengthOffset + dYBJJ) * col + dSLengthOffset * col;
  3721 + }
  3722 + };
  3723 + // 计算上偏移
  3724 + const calculateTopPosition = (row, reference, isVertical, topPosition, dSWidthOffset, dXBJJ) => {
  3725 + if (isVertical) {
  3726 + if (reference) {
  3727 + return row === 0 ? topPosition : topPosition + boxWidthOffset * row;
  3728 + } else {
  3729 + return row === 0 ? topPosition : topPosition + (dSWidthOffset + boxWidthOffset) * row;
  3730 + }
  3731 + } else {
  3732 + if (reference) {
  3733 + return row === 0 ? 0 : topPosition + boxWidthOffset * row;
  3734 + } else {
  3735 + return row === 0 ? topPosition : topPosition + (dSWidthOffset + boxWidthOffset) * row;
  3736 + }
  3737 + }
  3738 + };
  3739 + const innerDivs = [];
  3740 + // 生成盒子
  3741 + if (cols === 0 || rows === 0) {
  3742 + if (cols > 0) {
  3743 + for (let col = 0; col < cols; col++) {
  3744 + const leftPosition = col * innerWidthCombined;
  3745 + const topPosition = 0 * innerHeightCombined;
  3746 + innerDivs.push(createBoxOne(col, 0, 3, leftPosition, topPosition, iFAngle));
  3747 + }
  3748 + }
  3749 + if (rows > 0) {
  3750 + for (let row = 0; row < rows; row++) {
  3751 + const leftPosition = 0 * innerWidthCombined;
  3752 + const topPosition = row * innerHeightCombined;
  3753 + innerDivs.push(createBoxOne(0, row, 3, leftPosition, topPosition, iFAngle));
  3754 + }
  3755 + }
  3756 + } else {
  3757 + let hasPushed = false; // 标志变量
  3758 + for (let col = 0; col < cols; col++) {
  3759 + for (let row = 0; row < rows; row++) {
  3760 + const leftPosition = col * innerWidthCombined;
  3761 + const topPosition = row * innerHeightCombined;
  3762 + innerDivs.push(createBox(col, row, 1, leftPosition, topPosition, iFAngle));
  3763 + }
  3764 + // 如果可以放下首盒\
  3765 + if (remaining && isVertical) {
  3766 + let leftPosition = 0;
  3767 + let topPosition = 0;
  3768 + if (reference) {
  3769 + // 是否首盒
  3770 + // 首盒的上边距下边距 末尾盒子的上下边距 添加那一行的上边距
  3771 + leftPosition = col * innerWidthCombined + dFLengthOffset;
  3772 + topPosition = rows * innerHeightCombined + dFWidthOffset;
  3773 + } else {
  3774 + leftPosition = col * innerWidthCombined;
  3775 + topPosition = rows * innerHeightCombined;
  3776 + }
  3777 + innerDivs.push(createBoxOne(col, rows, 3, leftPosition, topPosition + dXBJJ, iFAngle));
  3778 + }
  3779 + }
  3780 + if (remaining && !isVertical) {
  3781 + for (let index = 0; index < rows; index++) {
  3782 + // 先默认为首盒参考
  3783 + let topPosition = 0;
  3784 + let leftPosition = 0;
  3785 + if (reference) {
  3786 + topPosition = index * (innerHeightCombined + boxWidthOffset);
  3787 + leftPosition = cols * (innerWidthCombined + boxLengthOffset);
  3788 + } else {
  3789 + topPosition = index * (innerHeightCombined + boxWidthOffset + dSWidthOffset);
  3790 +
  3791 + leftPosition = cols * (innerWidthCombined + boxLengthOffset + dSLengthOffset + dYBJJ);
  3792 + }
  3793 + innerDivs.push(createDiv(cols - 1, index, 3, leftPosition, topPosition, iFAngle));
  3794 + }
  3795 + }
  3796 + }
  3797 + const propsData = innerDivs[innerDivs.length - 1];
  3798 + let openEdition = 0;
  3799 + const { dWlcd, sBillNo } = slaveRowData;
  3800 +
  3801 + const propsDataLeft = Number(propsData.props.style.left.slice(0, -2));
  3802 + // 长需要找出最大的
  3803 + const propsDataWidth = Number(propsData.props.style.width.slice(0, -2));
  3804 + const propsDataHeight = Number(propsData.props.style.height.slice(0, -2));
  3805 + const propsDataTop = Number(propsData.props.style.top.slice(0, -2));
  3806 + // 判断列是否是单独的
  3807 +
  3808 + const newMaterialLength = parseFloat(propsDataLeft + (remaining ? jInnerWidth : innerWidthCombined) + dZBLB + dYBLB).toFixed(2); // 原纸长
  3809 + const newMaterialWidth = parseFloat(
  3810 + propsDataTop + propsDataHeight + dSBLB + dXBLB - (isVertical ? 0 : rows >= 1 ? (remaining ? 0 : dXBJJ) : 0)
  3811 + ).toFixed(2);
  3812 +
  3813 + // 计算开数
  3814 + let dSinglePQty = isVertical
  3815 + ? remaining
  3816 + ? cols + cols * (rows * 2)
  3817 + : cols * (rows * 2)
  3818 + : remaining
  3819 + ? rows + rows * (cols * 2)
  3820 + : rows * (cols * 2);
  3821 +
  3822 + let dHorizontalType = isVertical ? cols : remaining ? cols * 2 + 1 : cols * 2;
  3823 + let dPortraitType = isVertical ? (remaining ? rows * 2 + 1 : rows * 2) : remaining ? rows : rows;
  3824 + if (cols === 0 || rows === 0) {
  3825 + if (innerDivs.length > 0) {
  3826 + if (cols === 0 && rows > 0) {
  3827 + dSinglePQty = rows;
  3828 + dPortraitType = rows;
  3829 + dHorizontalType = 1;
  3830 + } else if (rows === 0 && cols > 0) {
  3831 + dSinglePQty = cols;
  3832 + dHorizontalType = cols;
  3833 + dPortraitType = 1;
  3834 + }
  3835 + }
  3836 + }
  3837 + const newDProductQty = masterData.dProductQty;
  3838 + const dMaterialsKQty = slaveDataDetail.dMaterialsKQty || 1;
  3839 + openEdition = (((newMaterialLength * newMaterialWidth) / (maxWidth * maxHeight)) * 100).toFixed(2);
3329 3840  
  3841 + return {
  3842 + newMaterialLength,
  3843 + newMaterialWidth,
  3844 + dSinglePQty,
  3845 + index: i,
  3846 + };
  3847 + };
  3848 + let list = [];
  3849 + if (calcMethodData && calcMethodData.length) {
  3850 + list = calcMethodData.map((item, i) => {
  3851 + return calculateLayout(item, i);
  3852 + });
  3853 + }
  3854 + const findMinValueItem = data => {
  3855 + let minItem = null;
  3856 + let minValue = Infinity;
  3857 +
  3858 + for (const item of data) {
  3859 + const { newMaterialLength, newMaterialWidth, dSinglePQty } = item;
  3860 + const length = parseFloat(newMaterialLength);
  3861 + const width = parseFloat(newMaterialWidth);
  3862 + const value = (length * width) / dSinglePQty;
  3863 +
  3864 + if (value < minValue) {
  3865 + minValue = value;
  3866 + minItem = item;
  3867 + }
  3868 + }
  3869 +
  3870 + return minItem;
  3871 + };
  3872 + return list.length ? calcMethodData[findMinValueItem(list).index] : calcMethodData[0];
  3873 +};
3330 3874 export default QuickQuote;
... ...