diff --git a/src/components/Common/BoxDesignCompontent/index.js b/src/components/Common/BoxDesignCompontent/index.js index 6b9642c..7def463 100644 --- a/src/components/Common/BoxDesignCompontent/index.js +++ b/src/components/Common/BoxDesignCompontent/index.js @@ -187,6 +187,21 @@ const BoxDesignCompontent = baseProps => { "右插位组件", "右下插位组件", ]; + const doubleTitlieList1 = [ + { name: "左上插位组件", value: "dZSCW" }, + { name: "上插位组件", value: "dSCW" }, + { name: "右上插位组件", value: "dYSCW" }, + { name: "左偏移", value: "dZPY" }, + { name: "左插位组件", value: "dZCW" }, + { name: "左下插位组件", value: "dZXCW" }, + { name: "右偏移", value: "dYPY" }, + { name: "右插位组件", value: "dYCW" }, + { name: "右下插位组件", value: "dYXCW" }, + { name: "首盒长", value: "dSHC" }, + { name: "首盒宽", value: "dSHK" }, + { name: "次盒长", value: "dCHC" }, + { name: "次盒宽", value: "dCHK" }, + ]; const newBoxList = []; // const boxs = titleList.length + tableData.length; @@ -218,8 +233,10 @@ const BoxDesignCompontent = baseProps => { }); }); // 部件信息 + + const boxTypes = masterData.sTypes; if (slaveData && slaveData.length) { - if (boxType !== "8") { + if (boxTypes !== "8") { slaveData.forEach((item, index) => { const i = titleList1.findIndex(i => { return i.value === item.sCode; @@ -236,11 +253,30 @@ const BoxDesignCompontent = baseProps => { } }); } else { + slaveData.forEach((item, index) => { + const i = doubleTitlieList1.findIndex(i => { + return i.value === item.sCode; + }); + if (i !== -1) { + const x = newBoxList.findIndex(z => z.sName === doubleTitlieList1[i].name); + newBoxList[x].value = item.iValue; + newBoxList[x].type = item.sTypes; + newBoxList[x].showName = item.sName; + newBoxList[x].selectImage = item.sMakeUpPath; + newBoxList[x].sName = doubleTitlieList1[i].name; + newBoxList[x].sAssignFormula = item.sAssignFormula; + newBoxList[x].bVisible = item.bVisible; + } + }); // 双盒盒型单独处理 } } // 盒身信息 if (masterData) { + const headLength = slaveData.find(item => item.sCode === "dSHC")?.iValue + const headWidth = slaveData.find(item => item.sCode === "dSHK")?.iValue + const orderLength = slaveData.find(item => item.sCode === "dCHC")?.iValue + const orderWidth = slaveData.find(item => item.sCode === "dCHK")?.iValue newBoxList.forEach((item, index) => { if (item.sName === "盒身") { newBoxList[index].value = masterData.sBoxBody; @@ -254,7 +290,15 @@ const BoxDesignCompontent = baseProps => { newBoxList[index].value = masterData.dBoxHeight; } else if (item.sName === "盒型名称") { newBoxList[index].value = masterData.sName; - } + } else if (item.sName === "首盒长") { + newBoxList[index].value = headLength; + } else if (item.sName === "首盒宽") { + newBoxList[index].value = headWidth; + } else if (item.sName === "次盒长") { + newBoxList[index].value = orderLength; + } else if (item.sName === "次盒宽") { + newBoxList[index].value = orderWidth; + } }); } // 有数据的时候 盒型设计需要赋值 @@ -355,9 +399,9 @@ const BoxDesignCompontent = baseProps => { sAssignFormula: null, })); setDoubleLayerList(createBox(["首盒长", "首盒宽", "次盒长", "次盒宽"])); - setTopDoubleBoxList(createBox(["左上插位组件", "上插位组件", "右上插位组件"])); - setLeftDoubleBoxList(createBox(["左偏移", "左插位组件", "左下插位组件"])); - setRightDoubleBoxList(createBox(["右偏移", "右插位组件", "右下插位组件"])); + // setTopDoubleBoxList(createBox(["左上插位组件", "上插位组件", "右上插位组件"])); + // setLeftDoubleBoxList(createBox(["左偏移", "左插位组件", "左下插位组件"])); + // setRightDoubleBoxList(createBox(["右偏移", "右插位组件", "右下插位组件"])); } else { } }, [boxType]); @@ -379,7 +423,6 @@ const BoxDesignCompontent = baseProps => { }; const handleChange = (e, index) => { - console.log(e.target.value, index, "handleChange"); const updatedBoxList = [...boxList]; updatedBoxList[index].value = e.target.value; setBoxList(updatedBoxList); @@ -450,15 +493,17 @@ const BoxDesignCompontent = baseProps => { // 判断是新增还是修改 // 存储子表数据 + const boxTypes = boxList.find(item => item.sName === "盒身")?.type; + const findList = boxTypes === "8" ? doubleTitlieList1 : titleList1; boxList.forEach((item, index) => { - const i = titleList1.findIndex(i => i.name === item.sName); - const slave = slaveData.find(z => z.sCode === titleList1[i]?.value); + const i = findList.findIndex(i => i.name === item.sName); + const slave = slaveData.find(z => z.sCode === findList[i]?.value); if (i !== -1) { const data = { ...slaveData[0], handleType: slave ? "update" : "add", sName: item.showName, - sCode: titleList1[i].value, + sCode: findList[i].value, iValue: item.value, iOrder: index + 1, iRowNum: index + 1, @@ -488,213 +533,17 @@ const BoxDesignCompontent = baseProps => { let sLengthFormula = ""; let sWidthFormula = ""; const boxType = boxList.find(item => item.sName === "盒身")?.type; - const boxLength = Number(boxList.find(item => item.sName === "盒长")?.value); - const boxWidth = Number(boxList.find(item => item.sName === "盒宽")?.value); - const boxHeight = Number(boxList.find(item => item.sName === "盒高")?.value); - const zxcw = boxList.find(x => x.sName === "左(下)插位组件"); - const zscw = boxList.find(x => x.sName === "左(上)插位组件"); - const yscw = boxList.find(x => x.sName === "右(上)插位组件"); - const yxcw = boxList.find(x => x.sName === "右(下)插位组件"); - const hdzj = boxList.find(x => x.sName === "盒底组件"); - const zxcwType = zxcw?.type; - const zxcwValue = zxcw?.value; - const zscwType = zscw?.type; - const zscwValue = zscw?.value; - const yscwType = yscw?.type; - const yscwValue = yscw?.value; - const yxcwType = yxcw?.type; - const yxcwValue = yxcw?.value; - let leftTopValue = 0; - let leftTop = ""; - let rightTopValue = 0; - let rightTop = ""; - let leftBottomValue = 0; - let leftBottom = ""; - let rightBottomValue = 0; - let rightBottom = ""; - if (boxType && boxType === "1") { - // 四面盒 - const ztbw = boxList.find(x => x.sName === "左贴边位")?.type && boxList.find(x => x.sName === "左贴边位")?.value; - const ytbw = boxList.find(x => x.sName === "右贴边位")?.type && boxList.find(x => x.sName === "右贴边位")?.value; - sLengthFormula = (ztbw ? "dZTBW+ " : "") + "L * 2 + W * 2" + (ytbw ? " +dYTBW" : ""); - - if (zxcwType === "4001" || zxcwType === "4006" || zxcwType === "4007") { - leftBottomValue = Number(zxcwValue) + boxHeight; - leftBottom = " + dZXCW + W"; - } else if (zxcwType === "4002" || zxcwType === "4003") { - leftBottomValue = Number(zxcwValue); - leftBottom = " + dZXCW"; - } else if (zxcwType === "4004") { - leftBottomValue = Number(zxcwValue) + boxHeight * 2; - leftBottom = " + dZXCW + W * 2"; - } else if (zxcwType === "4005") { - leftBottomValue = boxHeight * 2; - leftBottom = "+ W * 2"; - } - if (yscwType === "6001" || yscwType === "6006" || yscwType === "6007") { - rightTopValue = Number(yscwValue) + boxHeight; - rightTop = "dYSCW + W + "; - } else if (yscwType === "6002" || yscwType === "6003") { - rightTopValue = Number(yscwValue); - rightTop = "dYSCW + "; - } else if (yscwType === "6004") { - rightTopValue = Number(yscwValue) + boxHeight * 2; - rightTop = "dYSCW + W * 2+ "; - } else if (yscwType === "6005") { - rightTopValue = boxHeight * 2; - rightTop = "W * 2+ "; - } - if (zscwType === "3001" || zscwType === "3006" || zscwType === "3007") { - leftTopValue = Number(zscwValue) + boxHeight; - leftTop = "dZSCW + W +"; - } else if (zscwType === "3002" || zscwType === "3003") { - leftTopValue = Number(zscwValue); - leftTop = "dZSCW +"; - } else if (zscwType === "3004") { - leftTopValue = Number(zscwValue) + boxHeight * 2; - leftTop = "dZSCW + W * 2 +"; - } else if (zscwType === "3005") { - leftTopValue = boxHeight * 2; - leftTop = "W * 2 +"; - } - if (yxcwType === "7001" || yxcwType === "7006" || yxcwType === "7007") { - rightBottomValue = Number(yxcwValue) + boxHeight; - rightBottom = "+ dYXCW + W"; - } else if (yxcwType === "7002" || yxcwType === "7003") { - rightBottomValue = Number(yxcwValue); - rightBottom = "+ dYXCW "; - } else if (yxcwType === "7004") { - rightBottomValue = Number(yxcwValue) + boxHeight * 2; - rightBottom = "+ dYXCW + W * 2"; - } else if (yxcwType === "7005") { - rightBottomValue = boxHeight * 2; - rightBottom = "+ W * 2"; - } - sWidthFormula = - (leftTopValue > rightTopValue ? leftTop : rightTop) + - "D" + - (hdzj ? " + dHDC" : leftBottomValue > rightBottomValue ? leftBottom : rightBottom); - } else if (boxType && boxType === "2") { - // 单折 - const ztbw = boxList.find(x => x.sName === "左贴边位")?.type && boxList.find(x => x.sName === "左贴边位")?.value; - const ytbw = boxList.find(x => x.sName === "右贴边位")?.type && boxList.find(x => x.sName === "右贴边位")?.value; - sLengthFormula = (ztbw ? "dZTBW+ " : "") + "L * 2 + W" + (ytbw ? " +dYTBW" : ""); - if (zxcwType === "4001" || zxcwType === "4006" || zxcwType === "4007") { - leftBottomValue = Number(zxcwValue) + boxHeight; - leftBottom = " + dZXCW + W"; - } else if (zxcwType === "4002" || zxcwType === "4003") { - leftBottomValue = Number(zxcwValue); - leftBottom = " + dZXCW"; - } else if (zxcwType === "4004") { - leftBottomValue = Number(zxcwValue) + boxHeight * 2; - leftBottom = " + dZXCW + W * 2"; - } else if (zxcwType === "4005") { - leftBottomValue = boxHeight * 2; - leftBottom = "+ W * 2"; - } - if (yscwType === "6001" || yscwType === "6006" || yscwType === "6007") { - rightTopValue = Number(yscwValue) + boxHeight; - rightTop = "dYSCW + W + "; - } else if (yscwType === "6002" || yscwType === "6003") { - rightTopValue = Number(yscwValue); - rightTop = "dYSCW + "; - } else if (yscwType === "6004") { - rightTopValue = Number(yscwValue) + boxHeight * 2; - rightTop = "dYSCW + W * 2+ "; - } else if (yscwType === "6005") { - rightTopValue = boxHeight * 2; - rightTop = "W * 2+ "; - } - if (zscwType === "3001" || zscwType === "3006" || zscwType === "3007") { - leftTopValue = Number(zscwValue) + boxHeight; - leftTop = "dZSCW + W +"; - } else if (zscwType === "3002" || zscwType === "3003") { - leftTopValue = Number(zscwValue); - leftTop = "dZSCW +"; - } else if (zscwType === "3004") { - leftTopValue = Number(zscwValue) + boxHeight * 2; - leftTop = "dZSCW + W * 2 +"; - } else if (zscwType === "3005") { - leftTopValue = boxHeight * 2; - leftTop = "W * 2 +"; - } - if (yxcwType === "7001" || yxcwType === "7006" || yxcwType === "7007") { - rightBottomValue = Number(yxcwValue) + boxHeight; - rightBottom = "+ dYXCW + W"; - } else if (yxcwType === "7002" || yxcwType === "7003") { - rightBottomValue = Number(yxcwValue); - rightBottom = "+ dYXCW "; - } else if (yxcwType === "7004") { - rightBottomValue = Number(yxcwValue) + boxHeight * 2; - rightBottom = "+ dYXCW + W * 2"; - } else if (yxcwType === "7005") { - rightBottomValue = boxHeight * 2; - rightBottom = "+ W * 2"; - } - sWidthFormula = (leftTopValue > rightTopValue ? leftTop : rightTop) + "D" + (leftBottomValue > rightBottomValue ? leftBottom : rightBottom); - } else if (boxType && boxType === "3") { - const ztbw = boxList.find(x => x.sName === "左贴边位")?.type && boxList.find(x => x.sName === "左贴边位")?.value; - const ytbw = boxList.find(x => x.sName === "右贴边位")?.type && boxList.find(x => x.sName === "右贴边位")?.value; - sLengthFormula = (ztbw ? "dZTBW+ " : "") + "L + W * 2" + (ytbw ? " +dYTBW" : ""); - if (zxcwType === "4001" || zxcwType === "4006" || zxcwType === "4007") { - leftBottomValue = Number(zxcwValue) + boxHeight; - leftBottom = " + dZXCW + W"; - } else if (zxcwType === "4002" || zxcwType === "4003") { - leftBottomValue = Number(zxcwValue); - leftBottom = " + dZXCW"; - } else if (zxcwType === "4004") { - leftBottomValue = Number(zxcwValue) + boxHeight * 2; - leftBottom = " + dZXCW + W * 2"; - } else if (zxcwType === "4005") { - leftBottomValue = boxHeight * 2; - leftBottom = "+ W * 2"; - } - if (yscwType === "6001" || yscwType === "6006" || yscwType === "6007") { - rightTopValue = Number(yscwValue) + boxHeight; - rightTop = "dYSCW + W + "; - } else if (yscwType === "6002" || yscwType === "6003") { - rightTopValue = Number(yscwValue); - rightTop = "dYSCW + "; - } else if (yscwType === "6004") { - rightTopValue = Number(yscwValue) + boxHeight * 2; - rightTop = "dYSCW + W * 2+ "; - } else if (yscwType === "6005") { - rightTopValue = boxHeight * 2; - rightTop = "W * 2+ "; - } - if (zscwType === "3001" || zscwType === "3006" || zscwType === "3007") { - leftTopValue = Number(zscwValue) + boxHeight; - leftTop = "dZSCW + W +"; - } else if (zscwType === "3002" || zscwType === "3003") { - leftTopValue = Number(zscwValue); - leftTop = "dZSCW +"; - } else if (zscwType === "3004") { - leftTopValue = Number(zscwValue) + boxHeight * 2; - leftTop = "dZSCW + W * 2 +"; - } else if (zscwType === "3005") { - leftTopValue = boxHeight * 2; - leftTop = "W * 2 +"; - } - if (yxcwType === "7001" || yxcwType === "7006" || yxcwType === "7007") { - rightBottomValue = Number(yxcwValue) + boxHeight; - rightBottom = "+ dYXCW + W"; - } else if (yxcwType === "7002" || yxcwType === "7003") { - rightBottomValue = Number(yxcwValue); - rightBottom = "+ dYXCW "; - } else if (yxcwType === "7004") { - rightBottomValue = Number(yxcwValue) + boxHeight * 2; - rightBottom = "+ dYXCW + W * 2"; - } else if (yxcwType === "7005") { - rightBottomValue = boxHeight * 2; - rightBottom = "+ W * 2"; - } - sWidthFormula = (leftTopValue > rightTopValue ? leftTop : rightTop) + "D" + (leftBottomValue > rightBottomValue ? leftBottom : rightBottom); - } else if (boxType && boxType === "4") { - // 天地盒 + if (boxType === "8") { + + } else { + const boxLength = Number(boxList.find(item => item.sName === "盒长")?.value); + const boxWidth = Number(boxList.find(item => item.sName === "盒宽")?.value); + const boxHeight = Number(boxList.find(item => item.sName === "盒高")?.value); const zxcw = boxList.find(x => x.sName === "左(下)插位组件"); const zscw = boxList.find(x => x.sName === "左(上)插位组件"); const yscw = boxList.find(x => x.sName === "右(上)插位组件"); const yxcw = boxList.find(x => x.sName === "右(下)插位组件"); + const hdzj = boxList.find(x => x.sName === "盒底组件"); const zxcwType = zxcw?.type; const zxcwValue = zxcw?.value; const zscwType = zscw?.type; @@ -703,111 +552,312 @@ const BoxDesignCompontent = baseProps => { const yscwValue = yscw?.value; const yxcwType = yxcw?.type; const yxcwValue = yxcw?.value; - let leftValue = ""; - let rightValue = ""; - let topValue = ""; - let bottomValue = ""; - if (zxcwType === "4001" || zxcwType === "4006" || zxcwType === "4007") { - // leftValue = leftValue + Number(zxcwValue) + boxHeight * 2; - leftValue = "dZXCW + D * 2 +"; - } else if (zxcwType === "4002" || zxcwType === "4003") { - leftValue = "dZXCW + D +"; - } else if (zxcwType === "4004") { - leftValue = "dZXCW + D * 3 +"; - } else if (zxcwType === "4005") { - leftValue = "D * 3 +"; - } - if (yscwType === "6001" || yscwType === "6006" || yscwType === "6007") { - rightValue = "+ dYSCW + D * 2"; - } else if (yscwType === "6002" || yscwType === "6003") { - rightValue = "+ dYSCW + D"; - } else if (yscwType === "6004") { - rightValue = "+ dYSCW + D * 3"; - } else if (yscwType === "6005") { - rightValue = " + D * 3"; - } - if (zscwType === "3001" || zscwType === "3006" || zscwType === "3007") { - topValue = "dZSCW + D * 2 +"; - } else if (zscwType === "3002" || zscwType === "3003") { - topValue = "dZSCW + D +"; - } else if (zscwType === "3004") { - topValue = "dZSCW + D * 3 +"; - } else if (zscwType === "3005") { - topValue = "D * 3+"; - } - if (yxcwType === "7001" || yxcwType === "7006" || yxcwType === "7007") { - bottomValue = "+ dYXCW + D * 2"; - } else if (yxcwType === "7002" || yxcwType === "7003") { - bottomValue = "+ dYXCW + D "; - } else if (yxcwType === "7004") { - bottomValue = "+ dYXCW + D * 3"; - } else if (yxcwType === "7005") { - bottomValue = "+ D * 3"; - } - // viewBoxWidth = Number(boxLength) + leftValue + rightValue; - // viewBoxHeight = Number(boxWidth) + topValue + bottomValue; - sLengthFormula = leftValue + "L" + rightValue; - sWidthFormula = topValue + "W" + bottomValue; - } else if (boxType && boxType === "5") { - // 飞机盒 - const ztbw = boxList.find(x => x.sName === "左贴边位")?.type && boxList.find(x => x.sName === "左贴边位")?.value; - const ytbw = boxList.find(x => x.sName === "右贴边位")?.type && boxList.find(x => x.sName === "右贴边位")?.value; - sLengthFormula = (ztbw ? "dZTBW+ " : "") + "D * 2 + W * 2" + (ytbw ? " +dYTBW" : ""); - if (zxcwType === "4001" || zxcwType === "4006" || zxcwType === "4007") { - leftBottomValue = Number(zxcwValue) + boxHeight; - leftBottom = " + dZXCW + D"; - } else if (zxcwType === "4002" || zxcwType === "4003") { - leftBottomValue = Number(zxcwValue); - leftBottom = " + dZXCW"; - } else if (zxcwType === "4004") { - leftBottomValue = Number(zxcwValue) + boxHeight * 2; - leftBottom = " + dZXCW + D * 2"; - } else if (zxcwType === "4005") { - leftBottomValue = boxHeight * 2; - leftBottom = "+ D * 2"; - } - if (yscwType === "6001" || yscwType === "6006" || yscwType === "6007") { - rightTopValue = Number(yscwValue) + boxHeight; - rightTop = "dYSCW + D + "; - } else if (yscwType === "6002" || yscwType === "6003") { - rightTopValue = Number(yscwValue); - rightTop = "dYSCW + "; - } else if (yscwType === "6004") { - rightTopValue = Number(yscwValue) + boxHeight * 2; - rightTop = "dYSCW + D * 2+ "; - } else if (yscwType === "6005") { - rightTopValue = boxHeight * 2; - rightTop = "D * 2+ "; - } - if (zscwType === "3001" || zscwType === "3006" || zscwType === "3007") { - leftTopValue = Number(zscwValue) + boxHeight; - leftTop = "dZSCW + D +"; - } else if (zscwType === "3002" || zscwType === "3003") { - leftTopValue = Number(zscwValue); - leftTop = "dZSCW +"; - } else if (zscwType === "3004") { - leftTopValue = Number(zscwValue) + boxHeight * 2; - leftTop = "dZSCW + D * 2 +"; - } else if (zscwType === "3005") { - leftTopValue = boxHeight * 2; - leftTop = "D * 2 +"; - } - if (yxcwType === "7001" || yxcwType === "7006" || yxcwType === "7007") { - rightBottomValue = Number(yxcwValue) + boxHeight; - rightBottom = "+ dYXCW + D"; - } else if (yxcwType === "7002" || yxcwType === "7003") { - rightBottomValue = Number(yxcwValue); - rightBottom = "+ dYXCW "; - } else if (yxcwType === "7004") { - rightBottomValue = Number(yxcwValue) + boxHeight * 2; - rightBottom = "+ dYXCW + D * 2"; - } else if (yxcwType === "7005") { - rightBottomValue = boxHeight * 2; - rightBottom = "+ D * 2"; + let leftTopValue = 0; + let leftTop = ""; + let rightTopValue = 0; + let rightTop = ""; + let leftBottomValue = 0; + let leftBottom = ""; + let rightBottomValue = 0; + let rightBottom = ""; + if (boxType && boxType === "1") { + // 四面盒 + const ztbw = boxList.find(x => x.sName === "左贴边位")?.type && boxList.find(x => x.sName === "左贴边位")?.value; + const ytbw = boxList.find(x => x.sName === "右贴边位")?.type && boxList.find(x => x.sName === "右贴边位")?.value; + sLengthFormula = (ztbw ? "dZTBW+ " : "") + "L * 2 + W * 2" + (ytbw ? " +dYTBW" : ""); + + if (zxcwType === "4001" || zxcwType === "4006" || zxcwType === "4007") { + leftBottomValue = Number(zxcwValue) + boxHeight; + leftBottom = " + dZXCW + W"; + } else if (zxcwType === "4002" || zxcwType === "4003") { + leftBottomValue = Number(zxcwValue); + leftBottom = " + dZXCW"; + } else if (zxcwType === "4004") { + leftBottomValue = Number(zxcwValue) + boxHeight * 2; + leftBottom = " + dZXCW + W * 2"; + } else if (zxcwType === "4005") { + leftBottomValue = boxHeight * 2; + leftBottom = "+ W * 2"; + } + if (yscwType === "6001" || yscwType === "6006" || yscwType === "6007") { + rightTopValue = Number(yscwValue) + boxHeight; + rightTop = "dYSCW + W + "; + } else if (yscwType === "6002" || yscwType === "6003") { + rightTopValue = Number(yscwValue); + rightTop = "dYSCW + "; + } else if (yscwType === "6004") { + rightTopValue = Number(yscwValue) + boxHeight * 2; + rightTop = "dYSCW + W * 2+ "; + } else if (yscwType === "6005") { + rightTopValue = boxHeight * 2; + rightTop = "W * 2+ "; + } + if (zscwType === "3001" || zscwType === "3006" || zscwType === "3007") { + leftTopValue = Number(zscwValue) + boxHeight; + leftTop = "dZSCW + W +"; + } else if (zscwType === "3002" || zscwType === "3003") { + leftTopValue = Number(zscwValue); + leftTop = "dZSCW +"; + } else if (zscwType === "3004") { + leftTopValue = Number(zscwValue) + boxHeight * 2; + leftTop = "dZSCW + W * 2 +"; + } else if (zscwType === "3005") { + leftTopValue = boxHeight * 2; + leftTop = "W * 2 +"; + } + if (yxcwType === "7001" || yxcwType === "7006" || yxcwType === "7007") { + rightBottomValue = Number(yxcwValue) + boxHeight; + rightBottom = "+ dYXCW + W"; + } else if (yxcwType === "7002" || yxcwType === "7003") { + rightBottomValue = Number(yxcwValue); + rightBottom = "+ dYXCW "; + } else if (yxcwType === "7004") { + rightBottomValue = Number(yxcwValue) + boxHeight * 2; + rightBottom = "+ dYXCW + W * 2"; + } else if (yxcwType === "7005") { + rightBottomValue = boxHeight * 2; + rightBottom = "+ W * 2"; + } + sWidthFormula = + (leftTopValue > rightTopValue ? leftTop : rightTop) + + "D" + + (hdzj ? " + dHDC" : leftBottomValue > rightBottomValue ? leftBottom : rightBottom); + } else if (boxType && boxType === "2") { + // 单折 + const ztbw = boxList.find(x => x.sName === "左贴边位")?.type && boxList.find(x => x.sName === "左贴边位")?.value; + const ytbw = boxList.find(x => x.sName === "右贴边位")?.type && boxList.find(x => x.sName === "右贴边位")?.value; + sLengthFormula = (ztbw ? "dZTBW+ " : "") + "L * 2 + W" + (ytbw ? " +dYTBW" : ""); + if (zxcwType === "4001" || zxcwType === "4006" || zxcwType === "4007") { + leftBottomValue = Number(zxcwValue) + boxHeight; + leftBottom = " + dZXCW + W"; + } else if (zxcwType === "4002" || zxcwType === "4003") { + leftBottomValue = Number(zxcwValue); + leftBottom = " + dZXCW"; + } else if (zxcwType === "4004") { + leftBottomValue = Number(zxcwValue) + boxHeight * 2; + leftBottom = " + dZXCW + W * 2"; + } else if (zxcwType === "4005") { + leftBottomValue = boxHeight * 2; + leftBottom = "+ W * 2"; + } + if (yscwType === "6001" || yscwType === "6006" || yscwType === "6007") { + rightTopValue = Number(yscwValue) + boxHeight; + rightTop = "dYSCW + W + "; + } else if (yscwType === "6002" || yscwType === "6003") { + rightTopValue = Number(yscwValue); + rightTop = "dYSCW + "; + } else if (yscwType === "6004") { + rightTopValue = Number(yscwValue) + boxHeight * 2; + rightTop = "dYSCW + W * 2+ "; + } else if (yscwType === "6005") { + rightTopValue = boxHeight * 2; + rightTop = "W * 2+ "; + } + if (zscwType === "3001" || zscwType === "3006" || zscwType === "3007") { + leftTopValue = Number(zscwValue) + boxHeight; + leftTop = "dZSCW + W +"; + } else if (zscwType === "3002" || zscwType === "3003") { + leftTopValue = Number(zscwValue); + leftTop = "dZSCW +"; + } else if (zscwType === "3004") { + leftTopValue = Number(zscwValue) + boxHeight * 2; + leftTop = "dZSCW + W * 2 +"; + } else if (zscwType === "3005") { + leftTopValue = boxHeight * 2; + leftTop = "W * 2 +"; + } + if (yxcwType === "7001" || yxcwType === "7006" || yxcwType === "7007") { + rightBottomValue = Number(yxcwValue) + boxHeight; + rightBottom = "+ dYXCW + W"; + } else if (yxcwType === "7002" || yxcwType === "7003") { + rightBottomValue = Number(yxcwValue); + rightBottom = "+ dYXCW "; + } else if (yxcwType === "7004") { + rightBottomValue = Number(yxcwValue) + boxHeight * 2; + rightBottom = "+ dYXCW + W * 2"; + } else if (yxcwType === "7005") { + rightBottomValue = boxHeight * 2; + rightBottom = "+ W * 2"; + } + sWidthFormula = (leftTopValue > rightTopValue ? leftTop : rightTop) + "D" + (leftBottomValue > rightBottomValue ? leftBottom : rightBottom); + } else if (boxType && boxType === "3") { + const ztbw = boxList.find(x => x.sName === "左贴边位")?.type && boxList.find(x => x.sName === "左贴边位")?.value; + const ytbw = boxList.find(x => x.sName === "右贴边位")?.type && boxList.find(x => x.sName === "右贴边位")?.value; + sLengthFormula = (ztbw ? "dZTBW+ " : "") + "L + W * 2" + (ytbw ? " +dYTBW" : ""); + if (zxcwType === "4001" || zxcwType === "4006" || zxcwType === "4007") { + leftBottomValue = Number(zxcwValue) + boxHeight; + leftBottom = " + dZXCW + W"; + } else if (zxcwType === "4002" || zxcwType === "4003") { + leftBottomValue = Number(zxcwValue); + leftBottom = " + dZXCW"; + } else if (zxcwType === "4004") { + leftBottomValue = Number(zxcwValue) + boxHeight * 2; + leftBottom = " + dZXCW + W * 2"; + } else if (zxcwType === "4005") { + leftBottomValue = boxHeight * 2; + leftBottom = "+ W * 2"; + } + if (yscwType === "6001" || yscwType === "6006" || yscwType === "6007") { + rightTopValue = Number(yscwValue) + boxHeight; + rightTop = "dYSCW + W + "; + } else if (yscwType === "6002" || yscwType === "6003") { + rightTopValue = Number(yscwValue); + rightTop = "dYSCW + "; + } else if (yscwType === "6004") { + rightTopValue = Number(yscwValue) + boxHeight * 2; + rightTop = "dYSCW + W * 2+ "; + } else if (yscwType === "6005") { + rightTopValue = boxHeight * 2; + rightTop = "W * 2+ "; + } + if (zscwType === "3001" || zscwType === "3006" || zscwType === "3007") { + leftTopValue = Number(zscwValue) + boxHeight; + leftTop = "dZSCW + W +"; + } else if (zscwType === "3002" || zscwType === "3003") { + leftTopValue = Number(zscwValue); + leftTop = "dZSCW +"; + } else if (zscwType === "3004") { + leftTopValue = Number(zscwValue) + boxHeight * 2; + leftTop = "dZSCW + W * 2 +"; + } else if (zscwType === "3005") { + leftTopValue = boxHeight * 2; + leftTop = "W * 2 +"; + } + if (yxcwType === "7001" || yxcwType === "7006" || yxcwType === "7007") { + rightBottomValue = Number(yxcwValue) + boxHeight; + rightBottom = "+ dYXCW + W"; + } else if (yxcwType === "7002" || yxcwType === "7003") { + rightBottomValue = Number(yxcwValue); + rightBottom = "+ dYXCW "; + } else if (yxcwType === "7004") { + rightBottomValue = Number(yxcwValue) + boxHeight * 2; + rightBottom = "+ dYXCW + W * 2"; + } else if (yxcwType === "7005") { + rightBottomValue = boxHeight * 2; + rightBottom = "+ W * 2"; + } + sWidthFormula = (leftTopValue > rightTopValue ? leftTop : rightTop) + "D" + (leftBottomValue > rightBottomValue ? leftBottom : rightBottom); + } else if (boxType && boxType === "4") { + // 天地盒 + const zxcw = boxList.find(x => x.sName === "左(下)插位组件"); + const zscw = boxList.find(x => x.sName === "左(上)插位组件"); + const yscw = boxList.find(x => x.sName === "右(上)插位组件"); + const yxcw = boxList.find(x => x.sName === "右(下)插位组件"); + const zxcwType = zxcw?.type; + const zxcwValue = zxcw?.value; + const zscwType = zscw?.type; + const zscwValue = zscw?.value; + const yscwType = yscw?.type; + const yscwValue = yscw?.value; + const yxcwType = yxcw?.type; + const yxcwValue = yxcw?.value; + let leftValue = ""; + let rightValue = ""; + let topValue = ""; + let bottomValue = ""; + if (zxcwType === "4001" || zxcwType === "4006" || zxcwType === "4007") { + // leftValue = leftValue + Number(zxcwValue) + boxHeight * 2; + leftValue = "dZXCW + D * 2 +"; + } else if (zxcwType === "4002" || zxcwType === "4003") { + leftValue = "dZXCW + D +"; + } else if (zxcwType === "4004") { + leftValue = "dZXCW + D * 3 +"; + } else if (zxcwType === "4005") { + leftValue = "D * 3 +"; + } + if (yscwType === "6001" || yscwType === "6006" || yscwType === "6007") { + rightValue = "+ dYSCW + D * 2"; + } else if (yscwType === "6002" || yscwType === "6003") { + rightValue = "+ dYSCW + D"; + } else if (yscwType === "6004") { + rightValue = "+ dYSCW + D * 3"; + } else if (yscwType === "6005") { + rightValue = " + D * 3"; + } + if (zscwType === "3001" || zscwType === "3006" || zscwType === "3007") { + topValue = "dZSCW + D * 2 +"; + } else if (zscwType === "3002" || zscwType === "3003") { + topValue = "dZSCW + D +"; + } else if (zscwType === "3004") { + topValue = "dZSCW + D * 3 +"; + } else if (zscwType === "3005") { + topValue = "D * 3+"; + } + if (yxcwType === "7001" || yxcwType === "7006" || yxcwType === "7007") { + bottomValue = "+ dYXCW + D * 2"; + } else if (yxcwType === "7002" || yxcwType === "7003") { + bottomValue = "+ dYXCW + D "; + } else if (yxcwType === "7004") { + bottomValue = "+ dYXCW + D * 3"; + } else if (yxcwType === "7005") { + bottomValue = "+ D * 3"; + } + // viewBoxWidth = Number(boxLength) + leftValue + rightValue; + // viewBoxHeight = Number(boxWidth) + topValue + bottomValue; + sLengthFormula = leftValue + "L" + rightValue; + sWidthFormula = topValue + "W" + bottomValue; + } else if (boxType && boxType === "5") { + // 飞机盒 + const ztbw = boxList.find(x => x.sName === "左贴边位")?.type && boxList.find(x => x.sName === "左贴边位")?.value; + const ytbw = boxList.find(x => x.sName === "右贴边位")?.type && boxList.find(x => x.sName === "右贴边位")?.value; + sLengthFormula = (ztbw ? "dZTBW+ " : "") + "D * 2 + W * 2" + (ytbw ? " +dYTBW" : ""); + if (zxcwType === "4001" || zxcwType === "4006" || zxcwType === "4007") { + leftBottomValue = Number(zxcwValue) + boxHeight; + leftBottom = " + dZXCW + D"; + } else if (zxcwType === "4002" || zxcwType === "4003") { + leftBottomValue = Number(zxcwValue); + leftBottom = " + dZXCW"; + } else if (zxcwType === "4004") { + leftBottomValue = Number(zxcwValue) + boxHeight * 2; + leftBottom = " + dZXCW + D * 2"; + } else if (zxcwType === "4005") { + leftBottomValue = boxHeight * 2; + leftBottom = "+ D * 2"; + } + if (yscwType === "6001" || yscwType === "6006" || yscwType === "6007") { + rightTopValue = Number(yscwValue) + boxHeight; + rightTop = "dYSCW + D + "; + } else if (yscwType === "6002" || yscwType === "6003") { + rightTopValue = Number(yscwValue); + rightTop = "dYSCW + "; + } else if (yscwType === "6004") { + rightTopValue = Number(yscwValue) + boxHeight * 2; + rightTop = "dYSCW + D * 2+ "; + } else if (yscwType === "6005") { + rightTopValue = boxHeight * 2; + rightTop = "D * 2+ "; + } + if (zscwType === "3001" || zscwType === "3006" || zscwType === "3007") { + leftTopValue = Number(zscwValue) + boxHeight; + leftTop = "dZSCW + D +"; + } else if (zscwType === "3002" || zscwType === "3003") { + leftTopValue = Number(zscwValue); + leftTop = "dZSCW +"; + } else if (zscwType === "3004") { + leftTopValue = Number(zscwValue) + boxHeight * 2; + leftTop = "dZSCW + D * 2 +"; + } else if (zscwType === "3005") { + leftTopValue = boxHeight * 2; + leftTop = "D * 2 +"; + } + if (yxcwType === "7001" || yxcwType === "7006" || yxcwType === "7007") { + rightBottomValue = Number(yxcwValue) + boxHeight; + rightBottom = "+ dYXCW + D"; + } else if (yxcwType === "7002" || yxcwType === "7003") { + rightBottomValue = Number(yxcwValue); + rightBottom = "+ dYXCW "; + } else if (yxcwType === "7004") { + rightBottomValue = Number(yxcwValue) + boxHeight * 2; + rightBottom = "+ dYXCW + D * 2"; + } else if (yxcwType === "7005") { + rightBottomValue = boxHeight * 2; + rightBottom = "+ D * 2"; + } + sWidthFormula = (leftTopValue > rightTopValue ? leftTop : rightTop) + "L" + (leftBottomValue > rightBottomValue ? leftBottom : rightBottom); } - sWidthFormula = (leftTopValue > rightTopValue ? leftTop : rightTop) + "L" + (leftBottomValue > rightBottomValue ? leftBottom : rightBottom); } + // const sDoubleSize = JSON.stringify([headLength,headWidth,orderLength,orderWidth]) // 存储盒身数据 主表 const newMasterData = { ...masterData, @@ -902,13 +952,13 @@ const BoxDesignCompontent = baseProps => { ))} {boxType === "8" && - topDoubleBoxList.map((topItem, index) => ( -
-
{topItem.sName}
- {topItem?.selectImage ? ( + topDoubleBoxList.map((item, index) => ( +
+
{doubleTitlieList[index]}
+ {item?.selectImage ? ( {topItem.value} ) : ( @@ -920,31 +970,30 @@ const BoxDesignCompontent = baseProps => { className="mySelects" style={{ width: 180 }} defaultValue={options.length ? options[0].value : ""} - onSelect={(value, option) => handleSelect(value, option, index, 0)} + onSelect={(value, option) => handleSelect(value, option, findIndexBySname(item.sName), 0)} onDropdownVisibleChange={async open => { if (open) { - props.getSqlOptions(4); // 在下拉菜单打开时调用 getSqlOptions + props.getSqlOptions(index + 11); // 在下拉菜单打开时调用 getSqlOptions } }} > {!loading ? options.map(option => renderOptionWithImage(option)) : ""}
- {/*
参数:
*/} handleChangeName(e, index)} - onFocus={e => handleFocus(e, index)} - onBlur={e => handleBlur(e, index)} - readOnly={!topItem?.isEditable} + value={item?.showName} + onChange={e => handleChangeName(e, findIndexBySname(item.sName))} + onFocus={e => handleFocus(e, findIndexBySname(item.sName))} + onBlur={e => handleBlur(e, findIndexBySname(item.sName))} + readOnly={!item?.isEditable} className={styles.text} /> handleChange(e, index)} - onFocus={e => handleFocus(e, index)} - onBlur={e => handleBlur(e, index)} - readOnly={!topItem?.isEditable} + value={item?.value} + onChange={e => handleChange(e, findIndexBySname(item.sName))} + onFocus={e => handleFocus(e, findIndexBySname(item.sName))} + onBlur={e => handleBlur(e, findIndexBySname(item.sName))} + readOnly={!item?.isEditable} style={{ width: " 80%" }} />
@@ -1013,20 +1062,24 @@ const BoxDesignCompontent = baseProps => {
{doubleTitlieList[index + 3]}
- + {index !== 0 ? ( + + ) : ( + "" + )}
{item?.selectImage ? ( {
{doubleTitlieList[index + 6]}
- + {index !== 0 ? ( + + ) : ( + "" + )}
{item?.selectImage ? ( { - console.log("🚀 ~ SvgBox:", props); const svgContainerRef = useRef(null); const svgRef = useRef(null); const [boxKey, setBoxKey] = useState(new Date().getTime()); @@ -100,7 +99,6 @@ const SvgBox = props => { orderLength = Number(boxList.find(x => x.sName === "次盒长")?.value) || 0; orderWidth = Number(boxList.find(x => x.sName === "次盒宽")?.value) || 0; } - console.log(headLength, headWidth, orderLength, orderWidth, props.showNew, "orderWidth"); // 计算视口宽度和高度 const zbtb = boxList.find(x => x.sName === "左贴边位"); @@ -129,9 +127,15 @@ const SvgBox = props => { // 展宽 if (boxList && boxList.length) { // 如果存在部件和盒舌 取最大的 + const top = topOffect(boxList, boxLength, boxWidth, boxHeight); const bottom = bottomOffect(boxList, boxLength, boxWidth, boxHeight); max = Number(top) + Number(bottom); + if (Number(svgType) === 8) { + const top = topOffect(boxList, headLength, headWidth); + const bottom = bottomOffect(boxList, orderLength, orderWidth); + max = Number(top) + Number(bottom); + } } let viewBoxHeight = Number(boxHeight) + max; @@ -264,10 +268,40 @@ const SvgBox = props => { // viewBoxWidth = boxWidth + leftValue + rightValue; // viewBoxHeight = boxLength + dZSCW + dYXCW; } else if (Number(svgType) === 8) { - - viewBoxWidth = Number(headLength); - viewBoxHeight = Number(headWidth) + Number(orderWidth); + const getTop = (item, offset = 0) => { + const map = { + 10001: headWidth + Number(item?.value), + 10002: Number(item?.value), + 10003: Number(item?.value), + 10004: Number(item?.value) + headWidth * 2, + 10005: headWidth * 2, + 10006: Number(item?.value) + headWidth, + 10007: Number(item?.value) + headWidth, + }; + return map[item?.type - offset] ?? 0; // 根据偏移量统一处理 + }; + + const topLeft = getTop(boxList.find(x => x.sName === "左上插位组件")); + const topRight = getTop( + boxList.find(x => x.sName === "右上插位组件"), + 2000 + ); + const topLength = headLength + topLeft + topRight; + const bottomLeft = getTop( + boxList.find(x => x.sName === "左插位组件"), + 3000 + ); + const bottomRight = getTop( + boxList.find(x => x.sName === "右插位组件"), + 5000 + ); + const bottomLength = orderLength * 2 + bottomLeft + bottomRight; + const leftOffect = boxList.find(x => x.sName === "左偏移")?.value || 0; + const rightOffect = boxList.find(x => x.sName === "右偏移")?.value || 0; + viewBoxWidth = Math.max(topLength, bottomLength) + Number(leftOffect) + Number(rightOffect); + viewBoxHeight = Number(headWidth) + Number(orderWidth) + max; } + // 计算缩放比例 let scale = 1; if (props.showNew === 0) { @@ -278,14 +312,44 @@ const SvgBox = props => { let ySvg = dSvgBoxHeight ? topOffect(boxList, boxLength, boxWidth, boxHeight) * scale : topOffect(boxList, boxLength, boxWidth, boxHeight) * scale; - const bottom = bottomOffect(boxList, boxLength, boxWidth, boxHeight); + let bottom = 0; + if (Number(svgType) !== 8) { + bottom = bottomOffect(boxList, boxLength, boxWidth, boxHeight); + } else { + bottom = bottomOffect(boxList, orderLength, orderWidth); + } if (Number(svgType) === 4) { ySvg = ySvg + boxHeight * scale; + } else if (Number(svgType) === 8) { + ySvg = topOffect(boxList, headLength, headWidth) * scale; } ySvg = ySvg + 50 * scale; let xSvg = 0; - if (Number(svgType === 7)) { + if (Number(svgType) === 7) { xSvg = scaledWidth + dZXCW * scale; + } else if (Number(svgType) === 8) { + const leftOffect = boxList.find(x => x.sName === "左偏移")?.value || 0; + // 计算首盒部件与次盒部件尺寸 + const getTop = (item, offset = 0) => { + const map = { + 10001: headWidth + Number(item?.value), + 10002: Number(item?.value), + 10003: Number(item?.value), + 10004: Number(item?.value) + headWidth * 2, + 10005: headWidth * 2, + 10006: Number(item?.value) + headWidth, + 10007: Number(item?.value) + headWidth, + }; + return map[item?.type - offset] ?? 0; // 根据偏移量统一处理 + }; + const topLeft = getTop(boxList.find(x => x.sName === "左上插位组件")); + const topLength = headLength + topLeft; + const bottomLeft = getTop( + boxList.find(x => x.sName === "左插位组件"), + 3000 + ); + const bottomLength = headLength / 2 - orderLength + -bottomLeft - Number(leftOffect); + xSvg = Math.max(Math.abs(bottomLength), Math.abs(topLength)); } else { xSvg = zbtb?.value; } @@ -304,16 +368,39 @@ const SvgBox = props => { let ySvg = topOffect(boxList, boxLength, boxWidth, boxHeight) * scale; if (Number(svgType) === 4) { ySvg = ySvg + boxHeight; + } else if (Number(svgType) === 8) { + ySvg = topOffect(boxList, headLength, headWidth) * scale; } ySvg = ySvg + 50 * scale; let xSvg = 0; - if (Number(svgType === 7)) { + if (Number(svgType) === 7) { xSvg = scaledWidth + dZXCW * scale; + } else if (Number(svgType) === 8) { + const leftOffect = boxList.find(x => x.sName === "左偏移")?.value || 0; + // 计算首盒部件与次盒部件尺寸 + const getTop = (item, offset = 0) => { + const map = { + 10001: headWidth + Number(item?.value), + 10002: Number(item?.value), + 10003: Number(item?.value), + 10004: Number(item?.value) + headWidth * 2, + 10005: headWidth * 2, + 10006: Number(item?.value) + headWidth, + 10007: Number(item?.value) + headWidth, + }; + return map[item?.type - offset] ?? 0; // 根据偏移量统一处理 + }; + const topLeft = getTop(boxList.find(x => x.sName === "左上插位组件")); + const topLength = headLength + topLeft; + const bottomLeft = getTop( + boxList.find(x => x.sName === "左插位组件"), + 3000 + ); + const bottomLength = headLength / 2 - orderLength + -bottomLeft - Number(leftOffect); + xSvg = Math.max(Math.abs(bottomLength), Math.abs(topLength)); } else { xSvg = zbtb?.value; } - console.log(xSvg, viewBoxWidth / 2, viewBoxWidth, "viewBoxWidth / 2"); - svg.setAttribute( "viewBox", `${-(dSvgBoxWidth ? xSvg : viewBoxWidth / 2)} ${dSvgBoxWidth ? -0 : -ySvg} ${dSvgBoxWidth ? dSvgBoxWidth : 500} ${ @@ -357,9 +444,34 @@ const SvgBox = props => { ySvg = topSize; } else if (Number(svgType) === 6) { leftSize = 0; + } else if (Number(svgType) === 8) { + const leftOffect = boxList.find(x => x.sName === "左偏移")?.value || 0; + // 计算首盒部件与次盒部件尺寸 + const getTop = (item, offset = 0) => { + const map = { + 10001: headWidth + Number(item?.value), + 10002: Number(item?.value), + 10003: Number(item?.value), + 10004: Number(item?.value) + headWidth * 2, + 10005: headWidth * 2, + 10006: Number(item?.value) + headWidth, + 10007: Number(item?.value) + headWidth, + }; + return map[item?.type - offset] ?? 0; // 根据偏移量统一处理 + }; + const topLeft = getTop(boxList.find(x => x.sName === "左上插位组件")); + const topLength = topLeft; + const bottomLeft = getTop( + boxList.find(x => x.sName === "左插位组件"), + 3000 + ); + const bottomLength = headLength / 2 - orderLength + -bottomLeft - Number(leftOffect); + leftSize = Math.max(Math.abs(bottomLength), Math.abs(topLength)); + ySvg = topOffect(boxList, headLength, headWidth); } else { leftSize = zbtb?.value; } + svg.setAttribute("viewBox", `${-(leftSize * scale) || 0} ${-ySvg} ${viewBoxWidth + 2} ${viewBoxHeight + 2}`); svg.setAttribute("width", `${viewBoxWidth}px`); svg.setAttribute("height", `${viewBoxHeight}px`); @@ -408,6 +520,30 @@ const SvgBox = props => { ySvg = topSize; } else if (Number(svgType) === 6) { leftSize = 0; + } else if (Number(svgType) === 8) { + const leftOffect = boxList.find(x => x.sName === "左偏移")?.value || 0; + // 计算首盒部件与次盒部件尺寸 + const getTop = (item, offset = 0) => { + const map = { + 10001: headWidth + Number(item?.value), + 10002: Number(item?.value), + 10003: Number(item?.value), + 10004: Number(item?.value) + headWidth * 2, + 10005: headWidth * 2, + 10006: Number(item?.value) + headWidth, + 10007: Number(item?.value) + headWidth, + }; + return map[item?.type - offset] ?? 0; // 根据偏移量统一处理 + }; + const topLeft = getTop(boxList.find(x => x.sName === "左上插位组件")); + const topLength = topLeft; + const bottomLeft = getTop( + boxList.find(x => x.sName === "左插位组件"), + 3000 + ); + const bottomLength = headLength / 2 - orderLength + -bottomLeft - Number(leftOffect); + leftSize = Math.max(Math.abs(bottomLength), Math.abs(topLength)); + ySvg = topOffect(boxList, headLength, headWidth); } else { leftSize = zbtb?.value; } @@ -1164,32 +1300,7 @@ const SvgBox = props => { } // 右下部件 pathList.push(createDynamicTopLeft(yxbj?.type, scaledWidth, scaledHeight, dYXCW * scale, 0, scaledHeight)); - // if ((yxbj?.type === "7001" && yxbj?.value) || (yxbj?.type === "7006" && yxbj?.value) || (yxbj?.type === "7007" && yxbj?.value)) { - // pathList.push(createDoubleArrow(scaledHeight, scaledWidth + scaledHeight + scaledWidth * 0.2, scaledDeep + scaledHeight / 2, scales)); - // pathList.push(createText(scaledWidth + scaledHeight + scaledWidth * 0.2 + 10 * scales, scaledDeep + scaledHeight / 2, 10 * scales, "W")); - // pathList.push(createText(scaledWidth + scaledHeight + scaledWidth * 0.5, scaledDeep + scaledHeight + dYXCW / 2 - 4, 10 * scales, dYXCW)); - // } else if (yxbj?.type === "7004" && yxbj?.value) { - // pathList.push(createDoubleArrow(scaledHeight, scaledWidth + scaledHeight + scaledWidth * 0.2, scaledDeep + scaledHeight / 2, scales)); - // pathList.push(createText(scaledWidth + scaledHeight + scaledWidth * 0.2 - 10 * scales, scaledDeep + scaledHeight / 2, 10 * scales, "W")); - // pathList.push( - // createDoubleArrow(scaledHeight, scaledWidth + scaledHeight + scaledWidth * 0.85, scaledDeep + (scaledHeight + scaledHeight / 2), scales) - // ); - // pathList.push( - // createText(scaledWidth + scaledHeight + scaledWidth * 0.85 + 10 * scales, scaledDeep + (scaledHeight + scaledHeight / 2), 10 * scales, "W") - // ); - // pathList.push(createText(scaledWidth + scaledHeight + scaledWidth * 0.3, scaledDeep + scaledHeight * 2 + dYXCW / 2 - 4, 10 * scales, dYXCW)); - // } else if (yxbj?.type === "7005" && yxbj?.value) { - // pathList.push(createDoubleArrow(scaledHeight, scaledWidth + scaledHeight + scaledWidth * 0.1, scaledDeep + scaledHeight / 2, scales)); - // pathList.push(createText(scaledWidth + scaledHeight + scaledWidth * 0.1 + 10 * scales, scaledDeep + scaledHeight / 2, 10 * scales, "W")); - // pathList.push( - // createDoubleArrow(scaledHeight, scaledWidth + scaledHeight + scaledWidth * 0.8, scaledDeep + (scaledHeight + scaledHeight / 2), scales) - // ); - // pathList.push( - // createText(scaledWidth + scaledHeight + scaledWidth * 0.8 + 10 * scale, scaledDeep + (scaledHeight + scaledHeight / 2), 10 * scale, "W") - // ); - // } else if (dYXCW && yxbj?.type) { - // pathList.push(createText(scaledWidth + scaledHeight + scaledWidth * 0.5, scaledDeep + dYXCW / 2 - 4, 10 * scales, dYXCW)); - // } + // 右边 pathList.push(createFull(ysbj?.type, scaledWidth, scaledHeight, dYSCW * scale, scaledWidth, 0)); pathList.push(createFull(zxbj?.type, scaledWidth, -scaledHeight, -dZXCW * scale, 0, 0)); @@ -1199,18 +1310,20 @@ const SvgBox = props => { }); svg.appendChild(g); } else if (Number(svgType) === 8) { - const scaleHeadLength = headLength * scale - const scaleHeadWidth = headWidth * scale - const scaleOrderLength = orderLength * scale - const scaleOrderWidth = orderWidth * scale + const scaleHeadLength = headLength * scale; + const scaleHeadWidth = headWidth * scale; + const scaleOrderLength = orderLength * scale; + const scaleOrderWidth = orderWidth * scale; // 获取他的偏移距离 - const leftOffect = boxList.find(x=>x.sName === "左偏移")?.value || 0 - const rightOffect = boxList.find(x=>x.sName === "右偏移")?.value || 0 + const leftOffect = boxList.find(x => x.sName === "左偏移")?.value || 0; + const rightOffect = boxList.find(x => x.sName === "右偏移")?.value || 0; const rectangles = [{ x: 0, y: 0, width: scaleHeadLength, height: scaleHeadWidth }]; rectangles.forEach(rect => { g.appendChild(createPathElement(rect.x, rect.y, rect.width, rect.height)); }); - const rectanglesLeft = [{ x: scaleHeadLength / 2 - scaleOrderLength - Number(leftOffect), y: scaleHeadWidth, width: scaleOrderLength, height: scaleOrderWidth }]; + const rectanglesLeft = [ + { x: scaleHeadLength / 2 - scaleOrderLength - Number(leftOffect), y: scaleHeadWidth, width: scaleOrderLength, height: scaleOrderWidth }, + ]; rectanglesLeft.forEach(rect => { g.appendChild(createPathElement(rect.x, rect.y, rect.width, rect.height)); }); @@ -1218,583 +1331,309 @@ const SvgBox = props => { rectanglesRight.forEach(rect => { g.appendChild(createPathElement(rect.x, rect.y, rect.width, rect.height)); }); + // 处理双盒的插位组件 + let pathList = []; + // 获取左上 + const scw = boxList.find(x => x.sName === "上插位组件"); + const zscw = boxList.find(x => x.sName === "左上插位组件"); + const yscw = boxList.find(x => x.sName === "右上插位组件"); + const zcw = boxList.find(x => x.sName === "左插位组件"); + const ycw = boxList.find(x => x.sName === "右插位组件"); + const zxcw = boxList.find(x => x.sName === "左下插位组件"); + const yxcw = boxList.find(x => x.sName === "右下插位组件"); + const dSCW = scw?.value; + const dZSCW = zscw?.value; + const dYSCW = yscw?.value; + const dZCW = zcw?.value; + const dYCW = ycw?.value; + const dZXCW = zxcw?.value; + const dYXCW = yxcw?.value; + // 上插位 + pathList.push(createDynamicTopLeft(scw?.type, scaleHeadLength, -scaleHeadWidth, -dSCW * scale, 0, 0)); + // 左上插位 + pathList.push(createFull(zscw?.type, scaleHeadWidth, -scaleHeadWidth, -dZSCW * scale, 0, 0)); + // 左插位 + pathList.push( + createFull( + zcw?.type, + scaleOrderWidth, + -scaleOrderWidth, + -dZCW * scale, + scaleHeadLength / 2 - scaleOrderLength - Number(leftOffect), + scaleHeadWidth + ) + ); + // 左下 + pathList.push( + createDynamicTopLeft( + zxcw?.type, + scaleOrderLength, + scaleOrderWidth, + dZXCW * scale, + scaleHeadLength / 2 - scaleOrderLength - Number(leftOffect), + scaleHeadWidth + scaleOrderWidth + ) + ); + // 右上 + pathList.push(createFull(yscw?.type, scaleHeadWidth, scaleHeadWidth, dYSCW * scale, scaleHeadLength, 0)); + // 右插位 + pathList.push( + createFull( + ycw?.type, + scaleOrderWidth, + scaleOrderWidth, + dYCW * scale, + scaleHeadLength / 2 + Number(rightOffect) + scaleOrderLength, + scaleHeadWidth + ) + ); + // 右下 + pathList.push( + createDynamicTopLeft( + yxcw?.type, + scaleOrderLength, + scaleOrderWidth, + dYXCW * scale, + scaleHeadLength / 2 + Number(rightOffect), + scaleHeadWidth + scaleOrderWidth + ) + ); + + pathList.forEach(x => { + g.appendChild(x); + }); svg.appendChild(g); } }; // 计算头部偏移 const topOffect = (list, length, width, height) => { - // 判断code - const valueList = list.filter(x => x.type !== ("" || null)); - // const titleList = ['上方盒舌','左(上)插位组件','右(上)插位组件'] - const sfhs = valueList.find(x => x.sName === "上方盒舌"); - const zscw = valueList.find(x => x.sName === "左(上)插位组件"); - const yscw = valueList.find(x => x.sName === "右(上)插位组件"); - const svgType = valueList.find(x => x.sName === "盒身")?.type; - let top = 0; + const val = list.filter(x => x.type); + const sfhs = val.find(x => x.sName === "上方盒舌"); + const zscw = val.find(x => x.sName === "左(上)插位组件"); + const yscw = val.find(x => x.sName === "右(上)插位组件"); + const box = val.find(x => x.sName === "盒身"); + const svg = Number(box?.type); + if (svg === 6) return 0; + + const dZ = Number(zscw?.value) || 0; + const dY = Number(yscw?.value) || 0; + + if (svg === 8) { + const scw = val.find(x => x.sName === "上插位组件"); + const topsMap = { + 11001: width + Number(scw?.value), + 11002: Number(scw?.value), + 11003: Number(scw?.value), + 11004: Number(scw?.value) + width * 2, + 11005: width * 2, + 11006: Number(scw?.value) + width, + 11007: Number(scw?.value) + width, + }; + return topsMap[scw?.type] ?? 0; + } const one = ["6001", "3001", "4001", "7001", "3006", "4006", "6006", "7006", "3007", "4007", "6007", "7007"]; const four = ["6004", "3004", "4004", "7004"]; const five = ["6005", "3005", "4005", "7005"]; - const dYSCW = Number(yscw?.value) || 0; - const dZSCW = Number(zscw?.value) || 0; - if (Number(svgType) === 6) return 0; - // 如果存在插位就不计算盒舌 - if (zscw?.type && yscw?.type) { - const max = Math.max(dZSCW, dYSCW); - if (five.includes(zscw?.type) || five.includes(yscw?.type)) { - top = svgType === "5" ? height * 2 : width * 2; - } else if (four.includes(zscw?.type) || four.includes(yscw?.type)) { - const z = four.includes(zscw?.type) ? (svgType === "5" ? height * 2 + dZSCW : width * 2 + dZSCW) : dZSCW; - const y = four.includes(yscw?.type) ? (svgType === "5" ? height * 2 + dYSCW : width * 2 + dYSCW) : dYSCW; - const max = Math.max(z, y); - if (max > (sfhs?.value || 0)) { - top = max; - } else { - top = sfhs?.value; - } - } else if (one.includes(zscw?.type) || one.includes(yscw?.type)) { - const z = one.includes(zscw?.type) ? (svgType === "5" ? height + dZSCW : width + dZSCW) : dZSCW; - const y = one.includes(yscw?.type) ? (svgType === "5" ? height + dYSCW : width + dYSCW) : dYSCW; + const coef = box?.type === "5" ? height : width; - const max = Math.max(z, y); + const pick = (cw, d) => { + const t = cw?.type; + if (five.includes(t)) return 2 * coef; + if (four.includes(t)) return 2 * coef + d; + if (one.includes(t)) return coef + d; + return d; + }; - if (max > (sfhs?.value || 0)) { - top = max; - } else { - top = sfhs?.value; - } - } else { - top = max; - } + let top = 0; + if (zscw?.type && yscw?.type) { + const z = pick(zscw, dZ); + const y = pick(yscw, dY); + top = Math.max(z, y, sfhs?.value || 0); } else if (yscw?.type) { - const max = dYSCW; - if ( - five.includes(zscw?.type) || - five.includes(yscw?.type) || - four.includes(zscw?.type) || - four.includes(yscw?.type) || - one.includes(zscw?.type) || - one.includes(yscw?.type) - ) { - const coefficient = svgType === "5" ? height : width; - let addValue = 0; - if (five.includes(zscw?.type) || five.includes(yscw?.type)) { - addValue = 2 * coefficient; - } else if (four.includes(zscw?.type) || four.includes(yscw?.type)) { - addValue = 2 * coefficient + max; - } else { - addValue = coefficient + max; - } - top = addValue > sfhs?.value ? addValue : sfhs?.value; - } else { - top = (addValue || 0) > sfhs?.value ? max : sfhs?.value; - } + top = Math.max(pick(yscw, dY), sfhs?.value || 0); } else if (zscw?.type) { - const max = dZSCW; - if ( - five.includes(zscw?.type) || - five.includes(yscw?.type) || - four.includes(zscw?.type) || - four.includes(yscw?.type) || - one.includes(zscw?.type) || - one.includes(yscw?.type) - ) { - const coefficient = svgType === "5" ? height : width; - let addValue = 0; - if (five.includes(zscw?.type) || five.includes(yscw?.type)) { - addValue = 2 * coefficient; - } else if (four.includes(zscw?.type) || four.includes(yscw?.type)) { - addValue = 2 * coefficient + max; - } else { - addValue = coefficient + max; - } - top = addValue > sfhs?.value ? addValue : sfhs?.value; - } else { - top = max > sfhs?.value ? max : sfhs?.value; - } + top = Math.max(pick(zscw, dZ), sfhs?.value || 0); } else { - top = sfhs?.value; + top = sfhs?.value || 0; } - // 处理天地盒默认加上高 - if (Number(svgType) === 4) { - top = top + height; - } + if (svg === 4) top += height; return isNaN(top) ? 0 : top; }; const bottomOffect = (list, length, width, height) => { - // 判断code - const valueList = list.filter(x => x.type !== ("" || null)); - // const titleList = ['上方盒舌','左(上)插位组件','右(上)插位组件'] - const sfhs = valueList.find(x => x.sName === "下方盒舌"); - const zscw = valueList.find(x => x.sName === "左(下)插位组件"); - const yscw = valueList.find(x => x.sName === "右(下)插位组件"); - const hdzj = valueList.find(x => x.sName === "盒底组件"); - const svgType = valueList.find(x => x.sName === "盒身")?.type; - // 将找到的对象放入数组中,并过滤掉 undefined 值 - // 使用 reduce 方法比较 value 属性,找出最大的对象 - let top = 0; + const val = list.filter(x => x.type); + const sfhs = val.find(x => x.sName === "下方盒舌"); + const zscw = val.find(x => x.sName === "左(下)插位组件"); + const yscw = val.find(x => x.sName === "右(下)插位组件"); + const hdzj = val.find(x => x.sName === "盒底组件"); + const box = val.find(x => x.sName === "盒身"); + const svg = Number(box?.type); + + if (svg === 6) return 0; + if (hdzj?.type) return Number(hdzj.value); + + const dZ = Number(zscw?.value) || 0; + const dY = Number(yscw?.value) || 0; + if (svg === 8) { + const zxcw = val.find(x => x.sName === "左下插位组件"); + const yxcw = val.find(x => x.sName === "右下插位组件"); + const topsMap = { + 14001: width + Number(zxcw?.value), + 14002: Number(zxcw?.value), + 14003: Number(zxcw?.value), + 14004: Number(zxcw?.value) + width * 2, + 14005: width * 2, + 14006: Number(zxcw?.value) + width, + 14007: Number(zxcw?.value) + width, + }; + const topsMapRight = { + 16001: width + Number(yxcw?.value), + 16002: Number(yxcw?.value), + 16003: Number(yxcw?.value), + 16004: Number(yxcw?.value) + width * 2, + 16005: width * 2, + 16006: Number(yxcw?.value) + width, + 16007: Number(yxcw?.value) + width, + }; + return Math.max(topsMap[zxcw?.type], topsMapRight[yxcw?.type]) ?? 0; + } const one = ["6001", "3001", "4001", "7001", "3006", "4006", "6006", "7006", "3007", "4007", "6007", "7007"]; const four = ["6004", "3004", "4004", "7004"]; const five = ["6005", "3005", "4005", "7005"]; - const dYSCW = Number(yscw?.value) || 0; - const dZSCW = Number(zscw?.value) || 0; - if (Number(svgType) === 6) return 0; - if (hdzj?.type) { - return Number(hdzj?.value); - } + + const coef = box?.type === "5" ? height : width; + + const pick = (cw, d) => { + const t = cw?.type; + if (five.includes(t)) return 2 * coef; + if (four.includes(t)) return 2 * coef + d; + if (one.includes(t)) return coef + d; + return d; + }; + + let top = 0; if (zscw?.type && yscw?.type) { - const max = Math.max(dZSCW, dYSCW); - if (five.includes(zscw?.type) || five.includes(yscw?.type)) { - top = svgType === "5" ? height * 2 : width * 2; - } else if (four.includes(zscw?.type) || four.includes(yscw?.type)) { - const z = four.includes(zscw?.type) ? (svgType === "5" ? height * 2 + dZSCW : width * 2 + dZSCW) : dZSCW; - const y = four.includes(yscw?.type) ? (svgType === "5" ? height * 2 + dYSCW : width * 2 + dYSCW) : dYSCW; - const max = Math.max(z, y); - if (max > (sfhs?.value || 0)) { - top = max; - } else { - top = sfhs?.value; - } - } else if (one.includes(zscw?.type) || one.includes(yscw?.type)) { - const z = one.includes(zscw?.type) ? (svgType === "5" ? height + dZSCW : width + dZSCW) : dZSCW; - const y = one.includes(yscw?.type) ? (svgType === "5" ? height + dYSCW : width + dYSCW) : dYSCW; - const max = Math.max(z, y); - if (max > (sfhs?.value || 0)) { - top = max; - } else { - top = sfhs?.value; - } - } else { - top = max; - } + const z = pick(zscw, dZ); + const y = pick(yscw, dY); + top = Math.max(z, y, sfhs?.value || 0); } else if (yscw?.type) { - const max = dYSCW; - if ( - five.includes(zscw?.type) || - five.includes(yscw?.type) || - four.includes(zscw?.type) || - four.includes(yscw?.type) || - one.includes(zscw?.type) || - one.includes(yscw?.type) - ) { - const coefficient = svgType === "5" ? height : width; - let addValue = 0; - if (five.includes(zscw?.type) || five.includes(yscw?.type)) { - addValue = 2 * coefficient; - } else if (four.includes(zscw?.type) || four.includes(yscw?.type)) { - addValue = 2 * coefficient + max; - } else { - addValue = coefficient + max; - } - top = addValue > sfhs?.value ? addValue : sfhs?.value; - } else { - top = sfhs?.value ? max : sfhs?.value; - } + top = Math.max(pick(yscw, dY), sfhs?.value || 0); } else if (zscw?.type) { - const max = dZSCW; - if ( - five.includes(zscw?.type) || - five.includes(yscw?.type) || - four.includes(zscw?.type) || - four.includes(yscw?.type) || - one.includes(zscw?.type) || - one.includes(yscw?.type) - ) { - const coefficient = svgType === "5" ? height : width; - let addValue = 0; - if (five.includes(zscw?.type) || five.includes(yscw?.type)) { - addValue = 2 * coefficient; - } else if (four.includes(zscw?.type) || four.includes(yscw?.type)) { - addValue = 2 * coefficient + max; - } else { - addValue = coefficient + max; - } - top = addValue > sfhs?.value ? addValue : sfhs?.value; - } else { - top = max > sfhs?.value ? max : sfhs?.value; - } + top = Math.max(pick(zscw, dZ), sfhs?.value || 0); } else { - top = sfhs?.value; - } - // if (five.includes(zscw?.type) || five.includes(yscw?.type)) { - // top = width * 2; - // } else if (four.includes(zscw?.type) || four.includes(yscw?.type)) { - // if (dZSCW && dYSCW) { - // const max = Math.max(dZSCW, dYSCW); - // top = width * 2 + max; - // } else if (dZSCW && !dYSCW) { - // top = width * 2 + dZSCW; - // } else if (!dZSCW && dYSCW) { - // top = width * 2 + dYSCW; - // } - // } else if (one.includes(zscw?.type) || one.includes(yscw?.type)) { - // if (dZSCW && dYSCW) { - // const max = Math.max(dZSCW, dYSCW); - // top = width + max; - // } else if (dZSCW && !dYSCW) { - // top = width + dZSCW; - // } else if (!dZSCW && dYSCW) { - // top = width + dYSCW; - // } - // } else { - // if (dZSCW && !dYSCW) { - // top = Number(dZSCW); - // } else if (!dZSCW && dYSCW) { - // top = Number(dYSCW); - // } else { - // top = Number(sfhs?.value); - // } - // } - // 处理天地盒默认加上高 - if (Number(svgType) === 4) { - top = top + height; + top = sfhs?.value || 0; } + + if (svg === 4) top += height; return isNaN(top) ? 0 : top; }; // 上方盒舌左边 - const createUpperBoxTongueLeft = (upperBoxTongueType, width, height, offsetX, offsetY) => { - if (!height) return createNoneProject(); - // 根据不同类型创建不同形状的盒舌 upperBoxTongueType 如果null则返回 - let data = {}; - switch (upperBoxTongueType) { - case "1001": - data = createLineWeltTop(width, height, offsetX, offsetY); - break; - case "1002": - data = createIsoscelesTrapezoidWeltTop(width, height, offsetX, offsetY); - break; - case "1003": - data = createTrapezoidWeltTop(width, height, offsetX, offsetY); - break; - case "1004": - data = createFoldWeltTop(width, height, offsetX, offsetY); - break; - case "1005": - data = createRoundedCornersWeltTop(width, height, offsetX, offsetY); - break; - case "2001": - data = createLineWeltTop(width, height, offsetX, offsetY); - break; - case "2002": - data = createIsoscelesTrapezoidWeltTop(width, height, offsetX, offsetY); - break; - case "2003": - data = createTrapezoidWeltTop(width, height, offsetX, offsetY); - break; - case "2004": - data = createFoldWeltTop(width, height, offsetX, offsetY); - break; - case "2005": - data = createRoundedCornersWeltTop(width, height, offsetX, offsetY); - break; - default: - data = createNoneProject(); - break; - } - return data; - }; - // 右上方盒舌 - const createUpperBoxTongueRight = (upperBoxTongueType, width, height, deep, size, offsetX, offsetY) => { - if (!size) return createNoneProject(); - // 根据不同类型创建不同形状的盒舌 upperBoxTongueType 如果null则返回 - let data = {}; - switch (upperBoxTongueType) { - case "1001": - data = createTopTongueType1(-deep, offsetX, offsetY, -size, -3, -2); - break; - case 1: - data = createTopTongueType1(-deep, offsetX, offsetY, -size, -3, -2); - break; - default: - data = createNoneProject(); - break; - } - return data; + const createUpperBoxTongueLeft = (type, w, h, ox, oy) => { + if (!h) return createNoneProject(); + const fnMap = { + 1001: createLineWeltTop, + 1002: createIsoscelesTrapezoidWeltTop, + 1003: createTrapezoidWeltTop, + 1004: createFoldWeltTop, + 1005: createRoundedCornersWeltTop, + 2001: createLineWeltTop, + 2002: createIsoscelesTrapezoidWeltTop, + 2003: createTrapezoidWeltTop, + 2004: createFoldWeltTop, + 2005: createRoundedCornersWeltTop, + }; + return (fnMap[type] || createNoneProject)(w, h, ox, oy); }; + // 右上方盒舌 - const createBottomBoxTongueRight = (upperBoxTongueType, width, height, deep, size, offsetX, offsetY) => { - if (!size) return createNoneProject(); - // 根据不同类型创建不同形状的盒舌 upperBoxTongueType 如果null则返回 - let data = {}; - switch (upperBoxTongueType) { - case 0: - data = createTopTongue(-deep, offsetX, offsetY, size, -2, 5, 0, true); - break; - case 1: - data = createTopTongueType1(-deep, offsetX, offsetY, -size, -3, -2); - break; - default: - data = createNoneProject(); - break; - } - return data; - }; - const createBottomBoxTongueLeft = (upperBoxTongueType, width, height, deep, size, offsetX, offsetY) => { - if (!size) return createNoneProject(); - // 根据不同类型创建不同形状的盒舌 upperBoxTongueType 如果null则返回 - let data = {}; - switch (upperBoxTongueType) { - case 0: - data = createTopTongue(deep, offsetX, offsetY, size, 2, 5, 1, false); - break; - case 1: - data = createTopTongueType1(deep, offsetX, offsetY, -size, 3, 2); - break; - default: - data = createNoneProject(); - break; - } - return data; - }; // 左边贴位 const createTrapezoidLeft = (trapezoidLeftType, height, size, offsetX, offsetY, dSFHS, dXFHS) => { if (!size) return createNoneProject(); - let data = {}; - switch (trapezoidLeftType) { - case "8001": - data = createWelt(height, size, offsetX, offsetY); - break; - case "8002": - data = createWelt1(height, size, offsetX, offsetY); - break; - case "8003": - data = createWelt2(height, size, offsetX, offsetY); - break; - case "8004": - data = createWelt3(height, size, offsetX, offsetY); - break; - case "8005": - data = createWelt4(height, size, offsetX, offsetY, dSFHS, dXFHS); - break; - default: - data = createNoneProject(); - break; - } - return data; + const fnMap = { + 8001: createWelt, + 8002: createWelt1, + 8003: createWelt2, + 8004: createWelt3, + 8005: createWelt4, + }; + const fn = fnMap[trapezoidLeftType]; + return fn + ? trapezoidLeftType === "8005" + ? fn(height, size, offsetX, offsetY, dSFHS, dXFHS) + : fn(height, size, offsetX, offsetY) + : createNoneProject(); }; // 右边贴位 const createTrapezoidRight = (trapezoidLeftType, height, size, offsetX, offsetY, dSFHS, dXFHS) => { - if (!size) return createNoneProject(); - let data = {}; - switch (trapezoidLeftType) { - case "9001": - data = createWelt(height, size, offsetX, offsetY); - break; - case "9002": - data = createWelt1(height, size, offsetX, offsetY); - break; - case "9003": - data = createWelt2Right(height, size, offsetX, offsetY); - break; - case "9004": - data = createWelt3Right(height, size, offsetX, offsetY); - break; - case "9005": - data = createWelt4Right(height, size, offsetX, offsetY, dSFHS, dXFHS); - break; - default: - data = createNoneProject(); - break; - } - return data; + const suffix = trapezoidLeftType; + const fnMap = { + 9001: createWelt, + 9002: createWelt1, + 9003: createWelt2Right, + 9004: createWelt3Right, + 9005: createWelt4Right, + }; + const fn = fnMap[suffix]; + return fn ? (suffix === "9005" ? fn(height, size, offsetX, offsetY, dSFHS, dXFHS) : fn(height, size, offsetX, offsetY)) : createNoneProject(); }; // 左上部件 const createDynamicTopLeft = (trapezoidLeftType, width, height, size, offsetX, offsetY) => { if (!size) return createNoneProject(); - let data = {}; - switch (trapezoidLeftType) { - case "3001": - data = createBoxComponentNew(width, height, size, offsetX, offsetY); - break; - case "3002": - data = createBoxComponentNew1(width, height, size, offsetX, offsetY); - break; - case "3003": - data = createBoxComponentNew2(width, height, size, offsetX, offsetY); - break; - case "3004": - data = createBoxComponentNew3(width, height, size, offsetX, offsetY); - break; - case "3005": - data = createBoxComponentNew4(width, height, size, offsetX, offsetY); - break; - case "3006": - data = createBoxComponentNew5(width, height, size, offsetX, offsetY); - break; - case "3007": - data = createBoxComponentNew6(width, height, size, offsetX, offsetY); - break; - case "4001": - data = createBoxComponentNew(width, height, size, offsetX, offsetY); - break; - case "4002": - data = createBoxComponentNew1(width, height, size, offsetX, offsetY); - break; - case "4003": - data = createBoxComponentNew2(width, height, size, offsetX, offsetY); - break; - case "4004": - data = createBoxComponentNew3(width, height, size, offsetX, offsetY); - break; - case "4005": - data = createBoxComponentNew4(width, height, size, offsetX, offsetY); - break; - case "4006": - data = createBoxComponentNew5(width, height, size, offsetX, offsetY); - break; - case "4007": - data = createBoxComponentNew6(width, height, size, offsetX, offsetY); - break; - case "6001": - data = createBoxComponentNew(width, height, size, offsetX, offsetY); - break; - case "6002": - data = createBoxComponentNew1(width, height, size, offsetX, offsetY); - break; - case "6003": - data = createBoxComponentNew2(width, height, size, offsetX, offsetY); - break; - case "6004": - data = createBoxComponentNew3(width, height, size, offsetX, offsetY); - break; - case "6005": - data = createBoxComponentNew4(width, height, size, offsetX, offsetY); - break; - case "6006": - data = createBoxComponentNew5(width, height, size, offsetX, offsetY); - break; - case "6007": - data = createBoxComponentNew6(width, height, size, offsetX, offsetY); - break; - case "7001": - data = createBoxComponentNew(width, height, size, offsetX, offsetY); - break; - case "7002": - data = createBoxComponentNew1(width, height, size, offsetX, offsetY); - break; - case "7003": - data = createBoxComponentNew2(width, height, size, offsetX, offsetY); - break; - case "7004": - data = createBoxComponentNew3(width, height, size, offsetX, offsetY); - break; - case "7005": - data = createBoxComponentNew4(width, height, size, offsetX, offsetY); - break; - case "7006": - data = createBoxComponentNew5(width, height, size, offsetX, offsetY); - break; - case "7007": - data = createBoxComponentNew6(width, height, size, offsetX, offsetY); - break; - default: - data = createNoneProject(); - break; - } - return data; - }; - // 右上部件 - const createDynamicTopRight = (trapezoidLeftType, width, height, size, offsetX, offsetY) => { - if (!size) return createNoneProject(); - let data = {}; - switch (trapezoidLeftType) { - case "6001": - data = createBoxComponentNew(width, height, size, offsetX, offsetY); - break; - case 1: - break; - default: - data = createNoneProject(); - break; - } - return data; + + const suffix = trapezoidLeftType?.slice(-2); + const fnMap = { + "01": createBoxComponentNew, + "02": createBoxComponentNew1, + "03": createBoxComponentNew2, + "04": createBoxComponentNew3, + "05": createBoxComponentNew4, + "06": createBoxComponentNew5, + "07": createBoxComponentNew6, + }; + + const fn = fnMap[suffix]; + return fn ? fn(width, height, size, offsetX, offsetY) : createNoneProject(); }; + // 盒底组件 特殊的盒底组件 const createBoxBottomComponent = (trapezoidLeftType, width, deep, size, offsetX, offsetY) => { - let data = {}; - switch (trapezoidLeftType) { - case "5001": - data = createRightAngleBoxBottomComponent(width, deep, size, offsetX, offsetY); - break; - case "5002": - data = createBoxBottomComponent1(width, deep, size, offsetX, offsetY); - break; - case "5003": - data = createBoxBottomComponent2(width, deep, size, offsetX, offsetY); - break; - case "5004": - data = createBoxBottomComponent3(width, deep, size, offsetX, offsetY); - break; - case "5005": - data = createBoxBottomComponent4(width, deep, size, offsetX, offsetY); - break; - case "5006": - data = createBoxBottomComponent5(width, deep, size, offsetX, offsetY); - break; - case "5007": - data = createBoxBottomComponent6(width, deep, size, offsetX, offsetY); - break; - default: - data = createNoneProject(); - break; - } - return data; + const suffix = trapezoidLeftType?.slice(-2); + const fnMap = { + "01": createRightAngleBoxBottomComponent, + "02": createBoxBottomComponent1, + "03": createBoxBottomComponent2, + "04": createBoxBottomComponent3, + "05": createBoxBottomComponent4, + "06": createBoxBottomComponent5, + "07": createBoxBottomComponent6, + }; + return (fnMap[suffix] || createNoneProject)(width, deep, size, offsetX, offsetY); }; - // 天地盒部件 const createFull = (trapezoidLeftType, width, deep, size, offsetX, offsetY) => { - let data = {}; if (!size) return createNoneProject(); - switch (trapezoidLeftType) { - case "4001": - data = createBoxComponentNewFull(width, deep, size, offsetX, offsetY); - break; - case "4002": - data = createBoxComponentNewFull1(width, size, offsetX, offsetY); - break; - case "4003": - data = createBoxComponentNewFull2(width, size, offsetX, offsetY); - break; - case "4004": - data = createBoxComponentNewFul3(width, deep, size, offsetX, offsetY); - break; - case "4005": - data = createBoxComponentNewFul4(width, deep, size, offsetX, offsetY); - break; - case "4006": - data = createBoxComponentNewFul5(width, deep, size, offsetX, offsetY); - break; - case "4007": - data = createBoxComponentNewFul6(width, deep, size, offsetX, offsetY); - break; - case "6001": - data = createBoxComponentNewFull(width, deep, size, offsetX, offsetY); - break; - case "6002": - data = createBoxComponentNewFull1(width, size, offsetX, offsetY); - break; - case "6003": - data = createBoxComponentNewFull2(width, size, offsetX, offsetY); - break; - case "6004": - data = createBoxComponentNewFul3(width, deep, size, offsetX, offsetY); - break; - case "6005": - data = createBoxComponentNewFul4(width, deep, size, offsetX, offsetY); - break; - case "6006": - data = createBoxComponentNewFul5(width, deep, size, offsetX, offsetY); - break; - case "6007": - data = createBoxComponentNewFul6(width, deep, size, offsetX, offsetY); - break; + + const suffix = trapezoidLeftType?.slice(-2); + switch (suffix) { + case "01": // 4001,10001,12001,13001,15001,6001 + return createBoxComponentNewFull(width, deep, size, offsetX, offsetY); + case "02": // 4002,10002,11002,12002,13002,15002,6002 + return createBoxComponentNewFull1(width, size, offsetX, offsetY); + case "03": // 4003,6003 + return createBoxComponentNewFull2(width, size, offsetX, offsetY); + case "04": // 4004,6004 + return createBoxComponentNewFul3(width, deep, size, offsetX, offsetY); + case "05": // 4005,6005 + return createBoxComponentNewFul4(width, deep, size, offsetX, offsetY); + case "06": // 4006,6006 + return createBoxComponentNewFul5(width, deep, size, offsetX, offsetY); + case "07": // 4007,6007 + return createBoxComponentNewFul6(width, deep, size, offsetX, offsetY); default: - data = createNoneProject(); - break; + return createNoneProject(); } - return data; }; return (
- - {imageUrl ? ( - avatar - + + {imageUrl ? ( + avatar ) : (
上传
)} -
- +
+
); } @@ -1326,10 +1335,28 @@ export default class CommonComponent extends Component { { name: "右贴边位", value: "dYTBW" }, { name: "右(下)插位组件", value: "dYXCW" }, ]; - slaveData.forEach(x => { + const doubleTitlieList1 = [ + { name: "左上插位组件", value: "dZSCW" }, + { name: "上插位组件", value: "dSCW" }, + { name: "右上插位组件", value: "dYSCW" }, + { name: "左偏移", value: "dZPY" }, + { name: "左插位组件", value: "dZCW" }, + { name: "左下插位组件", value: "dZXCW" }, + { name: "右偏移", value: "dYPY" }, + { name: "右插位组件", value: "dYCW" }, + { name: "右下插位组件", value: "dYXCW" }, + { name: "首盒长", value: "dSHC" }, + { name: "首盒宽", value: "dSHK" }, + { name: "次盒长", value: "dCHC" }, + { name: "次盒宽", value: "dCHK" }, + ]; + const boxTypes = this.props.record.sTypes; + const srcList = Number(boxTypes) === 8 ? doubleTitlieList1 : titleList1; + + slaveData.forEach(x => boxList.push({ value: x.iValue, - sName: titleList1.find(item => item.value === x.sCode)?.name || "", + sName: srcList.find(item => item.value === x.sCode)?.name || "", isEditable: true, isSelect: false, selectValue: null, @@ -1337,9 +1364,10 @@ export default class CommonComponent extends Component { selectImage: null, type: x.sTypes || null, show: true, - showName: x.sName, // 参数名称 - }); - }); + showName: x.sName, + }) + ); + tables.forEach(x => { boxList.push({ value: x.value, @@ -1354,6 +1382,23 @@ export default class CommonComponent extends Component { showName: x.name, // 参数名称 }); }); + // if (sDoubleSizeList && sDoubleSizeList.length) { + // const titles = ["首盒长", "首盒宽", "次盒长", "次盒宽"]; + // sDoubleSizeList.forEach((x, i) => { + // boxList.push({ + // value: x, + // sName: titles[i], + // isEditable: true, + // isSelect: false, + // selectValue: null, + // selectLabel: "", + // selectImage: null, + // type: null, + // show: true, + // showName: titles[i], // 参数名称 + // }); + // }); + // } const svgProps = { ...this.props, boxList, @@ -1361,6 +1406,7 @@ export default class CommonComponent extends Component { dSvgBoxHeight: 100, showNew: 1, }; + return (
@@ -2928,7 +2974,7 @@ export default class CommonComponent extends Component { const [changeData] = dropDownDataNew.filter(item => (!commonUtils.isEmpty(res) ? item[res] : item.sId) === value.toString()); if (!commonUtils.isEmpty(sAssignField)) { /* 赋值数组 */ - + const sAssignFieldObj = sAssignField.split(","); if (commonUtils.isNotEmptyObject(changeData)) { for (const child of sAssignFieldObj) { @@ -3526,7 +3572,7 @@ export default class CommonComponent extends Component { ? `${commonConfig.file_host}file/download?savePathStr=${picAddr[0]}&scale=0.1&sModelsId=100&token=${token}` : picAddr[0]; /* 缩略图 */ // const dataPriviewUrl = `${commonConfig.server_host}file/download?savePathStr=${picAddr}&width=800&&height=500&sModelsId=100&token=${token}`; /* 预览 */ - const officeFileTypeList = ['PDF', 'DOCX', 'XLSX', 'MP4', 'WEBM', 'OGG']; + const officeFileTypeList = ["PDF", "DOCX", "XLSX", "MP4", "WEBM", "OGG"]; const imgTypeList = ["PNG", "SVG", "JPG", "JPEG", "GIF", "BMP", "TIFF", "ICO"]; const officeFileType = picAddr[0].split(".").pop().toUpperCase(); let fileIcon = ; @@ -3534,7 +3580,7 @@ export default class CommonComponent extends Component { fileIcon = ; } else if (officeFileType === "XLSX") { fileIcon = ; - } else if (['MP4', 'WEBM', 'OGG'].includes(officeFileType)) { + } else if (["MP4", "WEBM", "OGG"].includes(officeFileType)) { fileIcon = ; } let imgBox1 = ""; diff --git a/src/components/Common/Typesetting/typesetting.js b/src/components/Common/Typesetting/typesetting.js index 07498c8..aec3e59 100644 --- a/src/components/Common/Typesetting/typesetting.js +++ b/src/components/Common/Typesetting/typesetting.js @@ -143,6 +143,22 @@ const Typesetting = props => { { name: "右贴边位", value: "dYTBW" }, { name: "右(下)插位组件", value: "dYXCW" }, ]; + const doubleTitlieList1 = [ + { name: "左上插位组件", value: "dZSCW" }, + { name: "上插位组件", value: "dSCW" }, + { name: "右上插位组件", value: "dYSCW" }, + { name: "左偏移", value: "dZPY" }, + { name: "左插位组件", value: "dZCW" }, + { name: "左下插位组件", value: "dZXCW" }, + { name: "右偏移", value: "dYPY" }, + { name: "右插位组件", value: "dYCW" }, + { name: "右下插位组件", value: "dYXCW" }, + { name: "首盒长", value: "dSHC" }, + { name: "首盒宽", value: "dSHK" }, + { name: "次盒长", value: "dCHC" }, + { name: "次盒宽", value: "dCHK" }, + ]; + const srcList = Number(slaveRowData.sTypes) === 8 ? doubleTitlieList1 : titleList1; slaveNewData.forEach(x => { let key = 0; if (x.sAssignFormula) { @@ -152,7 +168,7 @@ const Typesetting = props => { } boxList.push({ value: key, - sName: titleList1.find(item => item.value === x.sName)?.name || "", + sName: srcList.find(item => item.value === x.sName)?.name || "", isEditable: true, isSelect: false, selectValue: null, @@ -160,7 +176,7 @@ const Typesetting = props => { selectImage: null, type: x.sTypes || null, show: true, - sCode: titleList1.find(item => item.value === x.sName)?.value || "", + sCode: srcList.find(item => item.value === x.sName)?.value || "", showName: x.showName, // 参数名称 }); }); @@ -455,12 +471,12 @@ const Typesetting = props => { const calculateLeftPosition = (col, reference, isVertical, leftPosition, dYBJJ, dSLengthOffset) => { if (isVertical) { if (reference) { - return col === 0 ? leftPosition : leftPosition + (dYBJJ * col); + return col === 0 ? leftPosition : leftPosition + dYBJJ * col; } return col === 0 ? leftPosition : leftPosition + (boxLengthOffset + dYBJJ) * col; } else { if (reference) { - return col === 0 ? leftPosition : leftPosition + (dYBJJ * col); + return col === 0 ? leftPosition : leftPosition + dYBJJ * col; } return col === 0 ? leftPosition : leftPosition + (boxLengthOffset + dYBJJ) * col + dSLengthOffset * col; } @@ -549,9 +565,8 @@ const Typesetting = props => { leftPosition = cols * (innerWidthCombined + boxLengthOffset); } else { topPosition = index * (innerHeightCombined + boxWidthOffset + dSWidthOffset); - - leftPosition = cols * (innerWidthCombined + boxLengthOffset + dSLengthOffset+dYBJJ) ; + leftPosition = cols * (innerWidthCombined + boxLengthOffset + dSLengthOffset + dYBJJ); } innerDivs.push(createDiv(cols - 1, index, 3, leftPosition, topPosition, iFAngle, DisableMateriallIcon)); } @@ -576,7 +591,9 @@ const Typesetting = props => { // 判断列是否是单独的 const newMaterialLength = parseFloat(propsDataLeft + (remaining ? jInnerWidth : innerWidthCombined) + dZBLB + dYBLB).toFixed(2); // 原纸长 - const newMaterialWidth = parseFloat(propsDataTop + propsDataHeight + dSBLB + dXBLB - (isVertical ? 0 : rows >= 1 ? (remaining ? 0 : dXBJJ) : 0)).toFixed(2); + const newMaterialWidth = parseFloat( + propsDataTop + propsDataHeight + dSBLB + dXBLB - (isVertical ? 0 : rows >= 1 ? (remaining ? 0 : dXBJJ) : 0) + ).toFixed(2); // 计算开数 let dSinglePQty = isVertical @@ -1085,7 +1102,7 @@ const Typesetting = props => { width: `${modalWidth}`, padding: "1px", }} - style={{top: 0}} + style={{ top: 0 }} onCancel={handleCancel} >
{ } const UlToolPosition = commonFunc.showLocalMessage(props, "UlToolPosition", "上下刀位"); const RLToolPosition = commonFunc.showLocalMessage(props, "RLToolPosition", "左右刀位"); - const LeftMargin = commonFunc.showLocalMessage(props, "LeftMargin", "左右刀位"); + const LeftMargin = commonFunc.showLocalMessage(props, "LeftMargin", "左右留白"); boxConfigList = boxConfig?.gdsconfigformslave?.filter(item => item.bVisible && showNameKeyList.includes(item.sName)) || []; if (selectedNode.sTypeKey === "juantong") { const mappings = { @@ -2304,6 +2304,7 @@ const BoxComponent = props => { { name: "盒宽", value: slaveRowData.dW ? slaveRowData.dW : masterData.dWidth ? Number(masterData.dWidth) : 0, type: null }, { name: "盒高", value: masterData.dHeight ? Number(masterData.dHeight) : 0, type: null }, ]; + const boxTypes = slaveRowData.sTypes; const titleList1 = [ { name: "上方盒舌", value: "dSFHS" }, { name: "盒底组件", value: "dHDC" }, @@ -2315,6 +2316,22 @@ const BoxComponent = props => { { name: "右贴边位", value: "dYTBW" }, { name: "右(下)插位组件", value: "dYXCW" }, ]; + const doubleTitlieList1 = [ + { name: "左上插位组件", value: "dZSCW" }, + { name: "上插位组件", value: "dSCW" }, + { name: "右上插位组件", value: "dYSCW" }, + { name: "左偏移", value: "dZPY" }, + { name: "左插位组件", value: "dZCW" }, + { name: "左下插位组件", value: "dZXCW" }, + { name: "右偏移", value: "dYPY" }, + { name: "右插位组件", value: "dYCW" }, + { name: "右下插位组件", value: "dYXCW" }, + { name: "首盒长", value: "dSHC" }, + { name: "首盒宽", value: "dSHK" }, + { name: "次盒长", value: "dCHC" }, + { name: "次盒宽", value: "dCHK" }, + ]; + const srcList = Number(boxTypes) === 8 ? doubleTitlieList1 : titleList1; const evaluateFormula = (formula, variables) => { if (!formula) return 0; // 如果公式为空,返回0 try { @@ -2357,7 +2374,7 @@ const BoxComponent = props => { } boxList.push({ value: key, - sName: titleList1.find(item => item.value === x.sName)?.name || "", + sName: srcList.find(item => item.value === x.sName)?.name || "", isEditable: true, isSelect: false, selectValue: null, @@ -2383,7 +2400,6 @@ const BoxComponent = props => { }); }); } - const svgProps = { ...props, boxList, @@ -3229,10 +3245,26 @@ const BoxModelSelectedModal = props => { { name: "右贴边位", value: "dYTBW" }, { name: "右(下)插位组件", value: "dYXCW" }, ]; + const doubleTitlieList1 = [ + { name: "左上插位组件", value: "dZSCW" }, + { name: "上插位组件", value: "dSCW" }, + { name: "右上插位组件", value: "dYSCW" }, + { name: "左偏移", value: "dZPY" }, + { name: "左插位组件", value: "dZCW" }, + { name: "左下插位组件", value: "dZXCW" }, + { name: "右偏移", value: "dYPY" }, + { name: "右插位组件", value: "dYCW" }, + { name: "右下插位组件", value: "dYXCW" }, + { name: "首盒长", value: "dSHC" }, + { name: "首盒宽", value: "dSHK" }, + { name: "次盒长", value: "dCHC" }, + { name: "次盒宽", value: "dCHK" }, + ]; + const srcList = Number(sTypes) === 8 ? doubleTitlieList1 : titleList1; slaveData.forEach(x => { boxList.push({ value: x.iValue || x.sDefault, - sName: titleList1.find(item => item.value === x.sCode || item.value === x.sName)?.name || "", + sName: srcList.find(item => item.value === x.sCode || item.value === x.sName)?.name || "", isEditable: true, isSelect: false, selectValue: null, @@ -3264,6 +3296,7 @@ const BoxModelSelectedModal = props => { dSvgBoxHeight: 100, showNew: 1, }; + return svgProps; }; const selectBoxList = boxData.filter(item => (boxTypeSelected === "全部" ? true : (item.sBoxType || "其它") === boxTypeSelected)); @@ -3586,6 +3619,7 @@ const GetBestAlgorithm = props => { { name: "盒宽", value: W, type: null }, { name: "盒高", value: D, type: null }, ]; + const boxTypes = slaveRowData.sTypes; const titleList1 = [ { name: "上方盒舌", value: "dSFHS" }, { name: "盒底组件", value: "dHDC" }, @@ -3597,6 +3631,22 @@ const GetBestAlgorithm = props => { { name: "右贴边位", value: "dYTBW" }, { name: "右(下)插位组件", value: "dYXCW" }, ]; + const doubleTitlieList1 = [ + { name: "左上插位组件", value: "dZSCW" }, + { name: "上插位组件", value: "dSCW" }, + { name: "右上插位组件", value: "dYSCW" }, + { name: "左偏移", value: "dZPY" }, + { name: "左插位组件", value: "dZCW" }, + { name: "左下插位组件", value: "dZXCW" }, + { name: "右偏移", value: "dYPY" }, + { name: "右插位组件", value: "dYCW" }, + { name: "右下插位组件", value: "dYXCW" }, + { name: "首盒长", value: "dSHC" }, + { name: "首盒宽", value: "dSHK" }, + { name: "次盒长", value: "dCHC" }, + { name: "次盒宽", value: "dCHK" }, + ]; + const srcList = Number(boxTypes) === 8 ? doubleTitlieList1 : titleList1; slaveNewData.forEach(x => { let key = 0; if (x.sAssignFormula) { @@ -3606,7 +3656,7 @@ const GetBestAlgorithm = props => { } boxList.push({ value: key, - sName: titleList1.find(item => item.value === x.sName)?.name || "", + sName: srcList.find(item => item.value === x.sName)?.name || "", isEditable: true, isSelect: false, selectValue: null, @@ -3614,7 +3664,7 @@ const GetBestAlgorithm = props => { selectImage: null, type: x.sTypes || null, show: true, - sCode: titleList1.find(item => item.value === x.sName)?.value || "", + sCode: srcList.find(item => item.value === x.sName)?.value || "", showName: x.showName, // 参数名称 }); });