From 484c5ff1806918db5e4fc851670a24f1491d8abd Mon Sep 17 00:00:00 2001 From: 陈鑫涛 <10125295+chen-xintao97@user.noreply.gitee.com> Date: Mon, 14 Jul 2025 17:16:21 +0800 Subject: [PATCH] 修复快速报价 --- src/components/Common/BoxDesignCompontent/index.js | 230 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------------------------------------------------------- src/components/QuickQuote/index.jsx | 6 +----- 2 files changed, 134 insertions(+), 102 deletions(-) diff --git a/src/components/Common/BoxDesignCompontent/index.js b/src/components/Common/BoxDesignCompontent/index.js index 97ee569..6773435 100644 --- a/src/components/Common/BoxDesignCompontent/index.js +++ b/src/components/Common/BoxDesignCompontent/index.js @@ -81,90 +81,77 @@ const BoxDesignCompontent = baseProps => { const [boxBodyList, setBoxBodyList] = useState([]); // 盒身信息 const [isDefaultValue, setIsDefaultValue] = useState(true); // 是否默认值 const [topBoxList, setTopBoxList] = useState([]); // 盒身信息 + const [topDoubleBoxList, setTopDoubleBoxList] = useState([]); // 盒身信息 const [leftBoxList, setLeftBoxList] = useState([]); // 左边 const [rightBoxList, setRightBoxList] = useState([]); const [boxKey, setBoxKey] = useState(new Date().getTime()); - const [doubleLayerList,setDoubleLayerList] = useState([]) + const [doubleLayerList, setDoubleLayerList] = useState([]); if (!boxVisible) return ""; -// 1️⃣ 只负责 tableColum -useEffect(() => { - if (!tableData?.length) return; + // 1️⃣ 只负责 tableColum + useEffect(() => { + if (!tableData?.length) return; - const newTableColum = tableData - .filter(item => item.bVisible) // 先过滤可见 - .map(item => ({ - ...item, - isEditable: true, - isSelect: false, - selectImage: null, - value: '', - })) - .filter( - item => - !( - item.showName.includes('盒长') || - item.showName.includes('盒高') || - item.showName.includes('盒宽') || - item.showName.includes('盒身') - ) - ) - .map(item => - item.showName === '盒型类别' - ? { ...item, showName: '盒型名称' } - : item - ); + const newTableColum = tableData + .filter(item => item.bVisible) // 先过滤可见 + .map(item => ({ + ...item, + isEditable: true, + isSelect: false, + selectImage: null, + value: "", + })) + .filter( + item => + !(item.showName.includes("盒长") || item.showName.includes("盒高") || item.showName.includes("盒宽") || item.showName.includes("盒身")) + ) + .map(item => (item.showName === "盒型类别" ? { ...item, showName: "盒型名称" } : item)); - setTableColum(newTableColum); -}, [tableData]); + setTableColum(newTableColum); + }, [tableData]); -// 2️⃣ 只负责 boxBodyList -useEffect(() => { - if (!tableData?.length) return; + // 2️⃣ 只负责 boxBodyList + useEffect(() => { + if (!tableData?.length) return; - const bodyList = tableData - .filter(item => item.bVisible) - .map(item => ({ - ...item, - isEditable: true, - isSelect: false, - selectImage: null, - value: '', - })) - .filter(item => item.showName.includes('盒身')); + const bodyList = tableData + .filter(item => item.bVisible) + .map(item => ({ + ...item, + isEditable: true, + isSelect: false, + selectImage: null, + value: "", + })) + .filter(item => item.showName.includes("盒身")); - setBoxBodyList(bodyList); -}, [tableData]); + setBoxBodyList(bodyList); + }, [tableData]); -// 3️⃣ 只负责 tableDataList 和 tableDataLists -useEffect(() => { - if (!tableData?.length) return; + // 3️⃣ 只负责 tableDataList 和 tableDataLists + useEffect(() => { + if (!tableData?.length) return; - const newList = tableData - .filter(item => item.bVisible) - .map(item => ({ - ...item, - isEditable: true, - isSelect: false, - selectImage: null, - value: '', - })) - .filter( - item => - item.showName.includes('盒长') || - item.showName.includes('盒高') || - item.showName.includes('盒宽') - ) - .map(item => { - let name = ''; - if (item.showName === '盒长') name = '盒长(L)'; - if (item.showName === '盒宽') name = '盒宽(W)'; - if (item.showName === '盒高') name = '盒高(D)'; - return { ...item, sName: name }; - }); + const newList = tableData + .filter(item => item.bVisible) + .map(item => ({ + ...item, + isEditable: true, + isSelect: false, + selectImage: null, + value: "", + })) + .filter(item => item.showName.includes("盒长") || item.showName.includes("盒高") || item.showName.includes("盒宽")) + .map(item => { + let name = ""; + if (item.showName === "盒长") name = "盒长(L)"; + if (item.showName === "盒宽") name = "盒宽(W)"; + if (item.showName === "盒高") name = "盒高(D)"; + return { ...item, sName: name }; + }); - setTableDataList(newList); - setTableDataLists(newList); -}, [tableData]); + setTableDataList(newList); + setTableDataLists(newList); + }, [tableData]); const titleList = [ "上方盒舌", "盒底组件", @@ -187,6 +174,7 @@ useEffect(() => { { name: "右贴边位", value: "dYTBW" }, { name: "右(下)插位组件", value: "dYXCW" }, ]; + const newBoxList = []; // const boxs = titleList.length + tableData.length; @@ -200,7 +188,7 @@ useEffect(() => { titleList.push(item.showName); }); // 这里处理双盒的初始数据 - titleList.push(...["首盒长", "首盒宽", "次盒长", "次盒宽"]) + titleList.push(...["首盒长", "首盒宽", "次盒长", "次盒宽"]); // 盒身信息 titleList.forEach((item, index) => { newBoxList.push({ @@ -219,21 +207,25 @@ useEffect(() => { }); // 部件信息 if (slaveData && slaveData.length) { - slaveData.forEach((item, index) => { - const i = titleList1.findIndex(i => { - return i.value === item.sCode; + if (boxType !== "8") { + slaveData.forEach((item, index) => { + const i = titleList1.findIndex(i => { + return i.value === item.sCode; + }); + if (i !== -1) { + const x = newBoxList.findIndex(z => z.sName === titleList1[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 = titleList1[i].name; + newBoxList[x].sAssignFormula = item.sAssignFormula; + newBoxList[x].bVisible = item.bVisible; + } }); - if (i !== -1) { - const x = newBoxList.findIndex(z => z.sName === titleList1[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 = titleList1[i].name; - newBoxList[x].sAssignFormula = item.sAssignFormula; - newBoxList[x].bVisible = item.bVisible; - } - }); + } else { + // 双盒盒型单独处理 + } } // 盒身信息 if (masterData) { @@ -260,7 +252,6 @@ useEffect(() => { } }, [newBoxList]); - const arraysAreEqual = (arr1, arr2) => { if (arr1.length !== arr2.length) return false; return arr1.every((item, index) => item.sName === arr2[index].sName); @@ -343,12 +334,9 @@ useEffect(() => { sAssignFormula: null, }); }); - // boxList.push() - setDoubleLayerList(box) + setDoubleLayerList(box); } else { } - console.log(boxList,'boxList'); - }, [boxType]); const handleFocus = (e, index) => { if (boxList && boxList.length) { @@ -844,7 +832,55 @@ useEffect(() => {