diff --git a/src/components/Common/CommonComponent/index.js b/src/components/Common/CommonComponent/index.js index e4dcaf8..9059053 100644 --- a/src/components/Common/CommonComponent/index.js +++ b/src/components/Common/CommonComponent/index.js @@ -2880,6 +2880,7 @@ export default class CommonComponent extends Component { /* 如果是选择空值,则将特殊字符过滤为空值 */ value = ""; } + console.log("🚀 ~ sAssignFieldObj:", 66666) /* 回带值声明 */ const returnValue = {}; @@ -2923,6 +2924,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) { diff --git a/src/components/Common/Typesetting/typesetting.js b/src/components/Common/Typesetting/typesetting.js index f1e134a..48a5979 100644 --- a/src/components/Common/Typesetting/typesetting.js +++ b/src/components/Common/Typesetting/typesetting.js @@ -59,7 +59,7 @@ const Typesetting = props => { const [materialWidth, setMaterialWidth] = useState(0); const [dProductQty, setDProductQty] = useState(0); const [materialName, setMaterialName] = useState(""); - const [dMaterialsKQty, setDMaterialsKQty] = useState(0); + // const [dMaterialsKQty, setDMaterialsKQty] = useState(0); const [dPartsLength, setDPartsLength] = useState(0); const [newDHorizontalType, setNewDHorizontalType] = useState(0); const [newDPortraitType, setNewDPortraitType] = useState(0); @@ -70,6 +70,8 @@ const Typesetting = props => { const boxsRef = useRef(null); const typesettingBox = useRef(null); const typesettingBoxs = useRef(null); + const svgBox = useRef(null); + const svgBoxs = useRef(null); // 获取外层盒子尺寸 const clientWidth = boxWidth || 400; const clientHeight = boxHeight || 300; @@ -92,23 +94,24 @@ const Typesetting = props => { const H = masterData?.dWidth || 0; const D = masterData?.dHeight || 0; // 动态计算公式值 - const evaluateFormula = (formula, variables) => { - if (!formula) return 0; // 如果公式为空,返回0 - try { - // 提取公式中的变量名 - const variableNames = formula.match(/\b[a-zA-Z_][a-zA-Z0-9_]*\b/g) || []; - // 构建函数参数 - const params = variableNames.join(","); - // 替换公式中的变量为实际值 - const func = new Function(params, `return ${formula}`); - // 提取变量值 - const args = variableNames.map(name => Number(variables[name]) || 0); - // 执行函数并返回结果 - return func(...args); - } catch (error) { - return 0; - } - }; + const evaluateFormula = (formula, variables) => { + if (!formula) return 0; // 如果公式为空,返回0 + try { + // 提取公式中的变量名 + const variableNames = formula.match(/\b[a-zA-Z_][a-zA-Z0-9_]*\b/g) || []; + // 构建函数参数 + const params = variableNames.join(","); + // 替换公式中的变量为实际值 + const func = new Function(params, `return ${formula}`); + // 提取变量值 + const args = variableNames.map(name => Number(variables[name]) || 0); + // 执行函数并返回结果 + return func(...args); + } catch (error) { + console.error("公式执行错误:", error); + return 0; + } +}; // 计算公式值 const variables = { L, @@ -119,7 +122,7 @@ const Typesetting = props => { }; const { sStripType = 0 } = props.state.selectedNode; let boxList = []; - if (sColumnNameConfig ) { + if (sColumnNameConfig) { const slaveNewData = JSON.parse(sColumnNameConfig); const tables = [ { name: "盒型类别", value: slaveRowData.sBoxType, type: null }, @@ -200,13 +203,14 @@ const Typesetting = props => { const boxWidthOffset = evaluateFormula(sSecondLongitudinalOffset, variabless); // 第二列纵向偏移 const isVertical = sSettingMethod === "从上到下"; // true 表示竖向排列,false 表示横向排列 sSettingMethod === '从上到下' const reference = sSGroupOffset === "首盒"; // 第三列参考 - console.log(innerWidth,innerHeight,dFWidthOffset,dFLengthOffset,dSWidthOffset,dSLengthOffset,boxLengthOffset,boxWidthOffset,'typeSetting'); - + console.log(innerWidth, innerHeight, dFWidthOffset, dFLengthOffset, dSWidthOffset, dSLengthOffset, boxLengthOffset, boxWidthOffset, "typeSetting"); + // 计算内层盒子尺寸 加上间距 let jInnerHeight = innerHeight; let jInnerWidth = innerWidth; let dSvgBoxWidth = innerWidth; let dSvgBoxHeight = innerHeight; + const isRrotate = iFAngle === 90 || iFAngle === 270 || iSAngle === 90 || iSAngle === 270; if (iFAngle === 90 || iFAngle === 270 || iSAngle === 90 || iSAngle === 270) { jInnerHeight = innerWidth; jInnerWidth = innerHeight; @@ -229,8 +233,8 @@ const Typesetting = props => { }; // 加上间距后的最大盒子长宽 计算每列可以放多少个组合 需要计算间距 // 每个盒子加上边距 和第二组偏移量 如果根据次盒再加上次盒偏移量 - const dSWidthOffsetCombined = (innerWidthCombined + boxLengthOffset + (reference ? 0 : dSLengthOffset)) - let cols = dSWidthOffsetCombined === 0 ? 0 : Math.floor(outerWidth / dSWidthOffsetCombined); + const dSWidthOffsetCombined = innerWidthCombined + boxLengthOffset + (reference ? 0 : dSLengthOffset); + let cols = dSWidthOffsetCombined === 0 ? 0 : Math.floor(outerWidth / dSWidthOffsetCombined); let rows = Math.floor(outerHeight / (innerHeightCombined + boxWidthOffset + (reference ? 0 : dSWidthOffset))); let colsMaxLength = (cols - 1) * (innerWidthCombined + boxLengthOffset + (reference ? 0 : dSLengthOffset)) + innerWidthCombined; while (colsMaxLength >= outerWidth && cols > 0) { @@ -373,11 +377,15 @@ const Typesetting = props => { alignItems: "center", position: "absolute", left: `${ - isVertical ? dSLengthOffset : iSAngle === 90 || iSAngle === 270 + isVertical + ? dSLengthOffset + : iSAngle === 90 || iSAngle === 270 ? innerHeight + dFLengthOffset + dSLengthOffset + dYBJJ : innerWidth + dFLengthOffset + dSLengthOffset + dYBJJ }px`, - top: `${isVertical ? jInnerHeight + dFWidthOffset + dSWidthOffset + dXBJJ: iSAngle === 90 || iSAngle === 270 ? dSWidthOffset : dSWidthOffset}px`, + top: `${ + isVertical ? jInnerHeight + dFWidthOffset + dSWidthOffset + dXBJJ : iSAngle === 90 || iSAngle === 270 ? dSWidthOffset : dSWidthOffset + }px`, }} >