From 2e2a2b3b361d2c57360a2eacdd6eb03237f4d636 Mon Sep 17 00:00:00 2001 From: 陈鑫涛 <10125295+chen-xintao97@user.noreply.gitee.com> Date: Wed, 23 Jul 2025 14:50:11 +0800 Subject: [PATCH] 双盒 --- src/components/Common/BoxDesignCompontent/index.js | 20 ++++++++++++++------ src/components/Common/BoxDesignCompontent/svg.js | 191 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------- src/components/Common/CommonComponent/index.js | 91 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------- src/components/Common/Typesetting/typesetting.js | 33 +++++++++++++++++++++++++-------- src/components/QuickQuote/index.jsx | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++----- 5 files changed, 340 insertions(+), 56 deletions(-) diff --git a/src/components/Common/BoxDesignCompontent/index.js b/src/components/Common/BoxDesignCompontent/index.js index cd3e858..837c82c 100644 --- a/src/components/Common/BoxDesignCompontent/index.js +++ b/src/components/Common/BoxDesignCompontent/index.js @@ -197,6 +197,10 @@ const BoxDesignCompontent = baseProps => { { name: "右偏移", value: "dYPY" }, { name: "右插位组件", value: "dYCW" }, { name: "右下插位组件", value: "dYXCW" }, + { name: "首盒长", value: "dSHC" }, + { name: "首盒宽", value: "dSHK" }, + { name: "次盒长", value: "dCHC" }, + { name: "次盒宽", value: "dCHK" }, ]; const newBoxList = []; @@ -269,8 +273,10 @@ const BoxDesignCompontent = baseProps => { } // 盒身信息 if (masterData) { - console.log(masterData,'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; @@ -285,13 +291,13 @@ const BoxDesignCompontent = baseProps => { } else if (item.sName === "盒型名称") { newBoxList[index].value = masterData.sName; } else if (item.sName === "首盒长") { - // newBoxList[index].value = masterData.sName; + newBoxList[index].value = headLength; } else if (item.sName === "首盒宽") { - // newBoxList[index].value = masterData.sName; + newBoxList[index].value = headWidth; } else if (item.sName === "次盒长") { - // newBoxList[index].value = masterData.sName; + newBoxList[index].value = orderLength; } else if (item.sName === "次盒宽") { - // newBoxList[index].value = masterData.sName; + newBoxList[index].value = orderWidth; } }); } @@ -530,6 +536,7 @@ const BoxDesignCompontent = baseProps => { let sWidthFormula = ""; const boxType = boxList.find(item => item.sName === "盒身")?.type; if (boxType === "8") { + } else { const boxLength = Number(boxList.find(item => item.sName === "盒长")?.value); const boxWidth = Number(boxList.find(item => item.sName === "盒宽")?.value); @@ -852,6 +859,7 @@ const BoxDesignCompontent = baseProps => { } } + // const sDoubleSize = JSON.stringify([headLength,headWidth,orderLength,orderWidth]) // 存储盒身数据 主表 const newMasterData = { ...masterData, diff --git a/src/components/Common/BoxDesignCompontent/svg.js b/src/components/Common/BoxDesignCompontent/svg.js index aaefb2b..af6dca0 100644 --- a/src/components/Common/BoxDesignCompontent/svg.js +++ b/src/components/Common/BoxDesignCompontent/svg.js @@ -127,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; @@ -262,11 +268,40 @@ const SvgBox = props => { // viewBoxWidth = boxWidth + leftValue + rightValue; // viewBoxHeight = boxLength + dZSCW + dYXCW; } else if (Number(svgType) === 8) { - const top = topOffect(boxList, headLength, headWidth); - viewBoxWidth = Number(headLength); - viewBoxHeight = Number(headWidth) + Number(orderWidth) + top; - console.log("🚀 ~ initSVG ~ viewBoxHeight:", viewBoxHeight); + 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) { @@ -277,7 +312,12 @@ 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) { @@ -285,8 +325,31 @@ const SvgBox = props => { } 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; } @@ -310,12 +373,34 @@ const SvgBox = props => { } 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; } - svg.setAttribute( "viewBox", `${-(dSvgBoxWidth ? xSvg : viewBoxWidth / 2)} ${dSvgBoxWidth ? -0 : -ySvg} ${dSvgBoxWidth ? dSvgBoxWidth : 500} ${ @@ -359,9 +444,35 @@ 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; } + console.log(viewBoxWidth, viewBoxHeight, "viewBoxHeight"); + svg.setAttribute("viewBox", `${-(leftSize * scale) || 0} ${-ySvg} ${viewBoxWidth + 2} ${viewBoxHeight + 2}`); svg.setAttribute("width", `${viewBoxWidth}px`); svg.setAttribute("height", `${viewBoxHeight}px`); @@ -410,6 +521,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; } @@ -1286,13 +1421,17 @@ const SvgBox = props => { if (svg === 8) { const scw = val.find(x => x.sName === "上插位组件"); - let tops = 0; - if (scw?.type === "11001") { - tops = width + Number(scw.value); - } - return tops; + 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"]; @@ -1337,7 +1476,29 @@ const SvgBox = props => { 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"]; diff --git a/src/components/Common/CommonComponent/index.js b/src/components/Common/CommonComponent/index.js index 91d8530..178bf16 100644 --- a/src/components/Common/CommonComponent/index.js +++ b/src/components/Common/CommonComponent/index.js @@ -23,7 +23,16 @@ import { Tooltip, Modal, } from "antd-v4"; -import {DeleteOutlined, EyeOutlined, FilePdfOutlined, FileWordOutlined, FileExcelOutlined, FileOutlined, RightOutlined, PlaySquareOutlined } from "@ant-design/icons"; +import { + DeleteOutlined, + EyeOutlined, + FilePdfOutlined, + FileWordOutlined, + FileExcelOutlined, + FileOutlined, + RightOutlined, + PlaySquareOutlined, +} from "@ant-design/icons"; import * as commonUtils from "@/utils/utils"; import styles from "@/index.less"; import Provinces from "@/assets/provinces.json"; @@ -1282,26 +1291,26 @@ export default class CommonComponent extends Component { showUploadList: false, openFileDialogOnClick: this.props.enabled, }; - const imageUrl = sName === "sPackPath" ? this.props.record.sPackPath : sName === "sPackDetailPathUpLoad" ? this.props.record.sPackDetailPathUpLoad : this.props.record.sSvgPath; + const imageUrl = + sName === "sPackPath" + ? this.props.record.sPackPath + : sName === "sPackDetailPathUpLoad" + ? this.props.record.sPackDetailPathUpLoad + : this.props.record.sSvgPath; return (