diff --git a/src/components/Common/BoxDesignCompontent/index.js b/src/components/Common/BoxDesignCompontent/index.js
index 150c9a0..e9ea7c6 100644
--- a/src/components/Common/BoxDesignCompontent/index.js
+++ b/src/components/Common/BoxDesignCompontent/index.js
@@ -22,18 +22,22 @@ const BoxDesignEvent = props => {
setLoading(true);
if (!type) {
setLoading(false);
+ if (!tableData?.length) return
+ const shape = tableData?.find(x => x.iTag === 70)?.showDropDown
+ const JsonShape = JSON.parse(shape)
+ const arr = Array.from(Object.values(JsonShape));
setOptions([
{
sId: "0",
sCode: "0",
- sName: "矩形",
+ sName: arr[0],
sMakeUpPath: "",
sTypes: "0",
},
{
sId: "1",
sCode: "1",
- sName: "梯形",
+ sName: arr[1],
sMakeUpPath: "",
sTypes: "1",
},
@@ -89,7 +93,7 @@ const BoxDesignEvent = props => {
};
const BoxDesignCompontent = baseProps => {
const props = BoxDesignEvent(baseProps);
- const { onCancel, onOk, title, loading, masterConfig, bFullScreen, tableData, options = [] } = props;
+ const { onCancel, onOk, title, loading, masterConfig, bFullScreen, tableData = [], options = [] } = props;
const { slaveData = {}, masterData = {} } = props.state;
const { boxVisible } = baseProps;
const [boxList, setBoxList] = useState([]);
@@ -106,18 +110,15 @@ const BoxDesignCompontent = baseProps => {
const [rightDoubleBoxList, setRightDoubleBoxList] = useState([]);
const [boxKey, setBoxKey] = useState(new Date().getTime());
const [doubleLayerList, setDoubleLayerList] = useState([]);
- if (!boxVisible) return "";
- const isEnglish = (str) => {
- return /^[A-Za-z]+$/.test(str);
- }
- // 1️⃣ 只负责 tableColum
+ const [shapeList, setShapeList] = useState([])
+ const [doublePrompt, setDoublePrompt] = useState([])
+
+ // if (!boxVisible) return "";
+ // 1️⃣ 只负责 tableColum 盒型名称
useEffect(() => {
if (!tableData?.length) return;
- const keywords = ["盒长", "盒高", "盒宽", "盒身","Box Length", "Box Width", "Box Height","Box Body"];
- // 判断是否是英文
- // isEnglish(item.showName) ? item.sEnglish : item.sChinese
const newTableColum = tableData
- .filter(item => item.bVisible) // 先过滤可见
+ .filter(item => item.bVisible).filter(item => item.iTag === 10) // 先过滤可见
.map(item => ({
...item,
isEditable: true,
@@ -125,32 +126,14 @@ const BoxDesignCompontent = baseProps => {
selectImage: null,
value: "",
}))
- .filter(
- item =>
- !keywords.some(keyword => item.showName.includes(keyword))
- )
- .map(item => {
- if (item.showName === '盒型类别') {
- return { ...item, showName: '盒型名称' };
- }
- if (item.showName.trim() === 'Box Type Category') {
- return { ...item, showName: 'Box Name' };
- }
- return item;
- }
- );
-
setTableColum(newTableColum);
- }, [tableData]);
+ }, [tableData.length]);
- // 2️⃣ 只负责 boxBodyList
+ // 2️⃣ 只负责 boxBodyList 盒身
useEffect(() => {
if (!tableData?.length) return;
-
- const keywords = ['盒身', 'Box Body'];
-
const bodyList = tableData
- .filter(item => item.bVisible)
+ .filter(item => item.bVisible).filter(item => item.iTag === 20)
.map(item => ({
...item,
isEditable: true,
@@ -158,17 +141,14 @@ const BoxDesignCompontent = baseProps => {
selectImage: null,
value: '',
}))
- .filter(item =>
- keywords.some(k => item.showName.trim().includes(k))
- );
-
setBoxBodyList(bodyList);
- }, [tableData]);
+ }, [tableData.length]);
// 3️⃣ 只负责 tableDataList 和 tableDataLists
+
useEffect(() => {
if (!tableData?.length) return;
- const keywords = ["盒长", "盒高", "盒宽", "Box Length", "Box Width", "Box Height"];
+ // const keywords = ["盒长", "盒高", "盒宽", "Box Length", "Box Width", "Box Height"];
const keywordMap = {
'盒长': 'L',
'盒宽': 'W',
@@ -179,28 +159,44 @@ const BoxDesignCompontent = baseProps => {
};
const newList = tableData
- .filter(item => item.bVisible)
+ .filter(item => item.bVisible).filter(item => item.iTag === 30)
.map(item => ({
...item,
isEditable: true,
isSelect: false,
selectImage: null,
value: "",
- }))
- .filter(item =>
- keywords.some(keyword => item.showName.includes(keyword))
- )
- .map(item => {
- const hitKey = keywords.find(k => item.showName.includes(k));
+ })).map(item => {
// 拼出新名字:原始关键字 + (后缀)
- const sName = hitKey
- ? `${hitKey} (${keywordMap[hitKey]})`
- : item.showName; // 兜底,理论上不会发生
+ const sName = `${item.showName} (${keywordMap[item.showName?.trim()]})`
return { ...item, sName };
});
setTableDataList(newList);
setTableDataLists(newList);
- }, [tableData]);
+ const shape = tableData.find(x => x.iTag === 70)?.showDropDown
+ if (!shape) return
+ const JsonShape = JSON.parse(shape)
+ const shapeLists = Array.from(Object.values(JsonShape))
+ setShapeList(shapeLists)
+ const prompt = tableData.filter(x => x.iTag === 80)
+ setDoublePrompt(prompt)
+ }, [tableData.length]);
+
+ // 获取itag为40的数据
+ const upViewPropsAll = Array.isArray(tableData)
+ ? tableData
+ .filter(item => item.bVisible)
+ .filter(item => [40, 50, 60].includes(item.iTag))
+ : [];
+ let titleListConfiguration = upViewPropsAll?.map(item => {
+ return item.showName
+ })
+ const btnName = Array.isArray(tableData)
+ ? tableData
+ .filter(item => item.bVisible) // 过滤出可见的项目
+ .find(item => [11].includes(item.iTag))?.showName || ''
+ : '';
+
const titleList = [
"上方盒舌",
"盒底组件",
@@ -211,7 +207,7 @@ const BoxDesignCompontent = baseProps => {
"右(上)插位组件",
"右贴边位",
"右(下)插位组件",
- ];
+ ]
const titleList1 = [
{ name: "上方盒舌", value: "dSFHS" },
{ name: "盒底组件", value: "dHDC" },
@@ -223,6 +219,12 @@ const BoxDesignCompontent = baseProps => {
{ name: "右贴边位", value: "dYTBW" },
{ name: "右(下)插位组件", value: "dYXCW" },
];
+ // const titleList1 = upViewPropsAll?.map(item=>{
+ // return {
+ // name:item.showName,
+ // value:item.sName
+ // }
+ // })
const doubleTitlieList = [
"左上插位组件",
"上插位组件",
@@ -275,7 +277,7 @@ const BoxDesignCompontent = baseProps => {
selectImage: null,
type: null,
show: true,
- showName: item, // 参数名称
+ showName: upViewPropsAll?.find(x => x.sName === titleList1.find(x => x.name === item)?.value)?.showName, // 参数名称
sAssignFormula: null,
sLength: null,
sWidth: null,
@@ -289,10 +291,11 @@ const BoxDesignCompontent = baseProps => {
cTypeName: null, // 盒型名称
cOffset: null, // 偏移
cQuantity: null, // 数量
+ sCode: titleList1.find(x => x.name === item)?.value,
+ showNames: upViewPropsAll?.find(x => x.sName === titleList1.find(x => x.name === item)?.value)?.showName
});
});
// 部件信息
-
const boxTypes = masterData.sTypes;
if (slaveData && slaveData.length) {
if (boxTypes !== "8") {
@@ -302,27 +305,31 @@ const BoxDesignCompontent = baseProps => {
});
if (i !== -1) {
const x = newBoxList.findIndex(z => z.sName === titleList1[i].name);
- Object.assign(newBoxList[x], {
- value: item.iValue,
- type: item.sTypes,
- showName: item.sName,
- selectImage: item.sMakeUpPath,
- sName: titleList1[i].name,
- sAssignFormula: item.sAssignFormula,
- bVisible: item.bVisible,
- sLength: item.iSLength,
- sWidth: item.iSWidth,
- sType: item.iSType,
- sTypeName: item.iSType !== null ? (Number(item.iSType) === 0 ? "矩形" : Number(item.iSType) === 1 ? "梯形" : null) : null,
- sOffset: item.sSOffset,
- sQuantity: item.iSQuantity,
- cLength: item.iCLength,
- cWidth: item.iCWidth,
- cType: item.iCType,
- cTypeName: item.iCType !== null ? (Number(item.iCType) === 0 ? "矩形" : Number(item.iCType) === 1 ? "梯形" : null) : null,
- cOffset: item.sCOffset,
- cQuantity: item.iCQuantity,
- });
+ if (x !== -1) {
+ Object.assign(newBoxList[x], {
+ value: item.iValue,
+ type: item.sTypes,
+ showName: item.sName,
+ selectImage: item.sMakeUpPath,
+ sName: titleList1[i].name,
+ sAssignFormula: item.sAssignFormula,
+ bVisible: item.bVisible,
+ sLength: item.iSLength,
+ sWidth: item.iSWidth,
+ sType: item.iSType,
+ sTypeName: item.iSType !== null ? shapeList[item.iSType] : null,
+ sOffset: item.sSOffset,
+ sQuantity: item.iSQuantity,
+ cLength: item.iCLength,
+ cWidth: item.iCWidth,
+ cType: item.iCType,
+ cTypeName: item.iCType !== null ? shapeList[item.iCType] : null,
+ cOffset: item.sCOffset,
+ cQuantity: item.iCQuantity,
+ showNames: upViewPropsAll?.find(x => x.sName === item.sCode)?.showName
+ });
+ }
+
}
});
} else {
@@ -351,17 +358,17 @@ const BoxDesignCompontent = baseProps => {
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.trim() === "盒身" || item.sName.trim() === "Box Body") {
+ if (item.sName?.trim() === "盒身" || item.sName?.trim() === "Box Body") {
newBoxList[index].value = masterData.sBoxBody;
newBoxList[index].selectImage = masterData.sMakeUpPath;
newBoxList[index].type = masterData.sTypes;
- } else if (item.sName.trim() === "盒长" || item.sName.trim() === "Box Length") {
+ } else if (item.sName?.trim() === "盒长" || item.sName?.trim() === "Box Length") {
newBoxList[index].value = masterData.dBoxLength;
- } else if (item.sName.trim() === "盒宽" || item.sName.trim() === "Box Width") {
+ } else if (item.sName?.trim() === "盒宽" || item.sName?.trim() === "Box Width") {
newBoxList[index].value = masterData.dBoxWidth;
- } else if (item.sName.trim() === "盒高" || item.sName.trim() === "Box Height") {
+ } else if (item.sName?.trim() === "盒高" || item.sName?.trim() === "Box Height") {
newBoxList[index].value = masterData.dBoxHeight;
- } else if (item.sName === "盒型名称" || item.sName.trim() === "Box Name") {
+ } else if (item.sName === "盒型名称" || item.sName?.trim() === "Box Name") {
newBoxList[index].value = masterData.sName;
} else if (item.sName === "首盒长") {
newBoxList[index].value = headLength;
@@ -386,7 +393,7 @@ const BoxDesignCompontent = baseProps => {
return arr1.every((item, index) => item.sName === arr2[index].sName);
};
useEffect(() => {
- const type = boxList.find(item => item.sName === "盒身")?.type;
+ const type = boxList.find(item => item.sName === boxBodyList[0]?.showName)?.type;
const updateLists = () => {
const topBoxFilter = item => item.sName === "上方盒舌" || item.sName === "盒底组件" || item.sName === "下方盒舌";
@@ -452,7 +459,7 @@ const BoxDesignCompontent = baseProps => {
updateLists();
}, [boxList]);
- const boxType = boxList.find(item => item.sName === "盒身")?.type;
+ const boxType = boxList.find(item => item.sName === boxBodyList[0]?.showName)?.type;
// 监听盒身类型
useEffect(() => {
if (!boxType) return;
@@ -552,10 +559,10 @@ const BoxDesignCompontent = baseProps => {
const handleSelects = (name, selectConfig, index, type, doubleType) => {
let updatedBoxList = [...boxList];
if (doubleType === 0) {
- updatedBoxList[index].sTypeName = Number(name) === 0 ? "矩形" : "梯形";
+ updatedBoxList[index].sTypeName = shapeList[Number(name)];
updatedBoxList[index].sType = Number(name)
} else {
- updatedBoxList[index].cTypeName = Number(name) === 0 ? "矩形" : "梯形";
+ updatedBoxList[index].cTypeName = shapeList[Number(name)];
updatedBoxList[index].cType = Number(name)
}
setBoxList(updatedBoxList);
@@ -603,6 +610,9 @@ const BoxDesignCompontent = baseProps => {
...props,
boxList,
showNew: 0,
+ tableColum,
+ boxBodyList,
+ tableDataList
// dSvgBoxWidth: 500,
// dSvgBoxHeight: 250,
};
@@ -617,7 +627,7 @@ const BoxDesignCompontent = baseProps => {
// 判断是新增还是修改
// 存储子表数据
- const boxTypes = boxList.find(item => item.sName === "盒身" || item.sName.trim() === 'Box Body')?.type;
+ const boxTypes = boxList.find(item => item.sName === boxBodyList[0]?.showName)?.type;
const findList = boxTypes === "8" ? doubleTitlieList1 : titleList1;
boxList.forEach((item, index) => {
const i = findList.findIndex(i => i.name === item.sName);
@@ -640,13 +650,13 @@ const BoxDesignCompontent = baseProps => {
iSLength: !item.sLength ? 0 : item.sLength,
iSWidth: !item.sWidth ? 0 : item.sWidth,
iSType: !item.sType ? 0 : item.sType,
- iSTypeName: item.sType !== null ? (Number(item.sType) === 0 ? "矩形" : Number(item.sType) === 1 ? "梯形" : null) : null,
+ iSTypeName: item.sType !== null ? shapeList[item.iSType] : null,
sSOffset: !item.sOffset ? 0 : item.sOffset,
iSQuantity: !item.sQuantity ? 0 : item.sQuantity,
iCLength: !item.cLength ? 0 : item.cLength,
iCWidth: !item.cWidth ? 0 : item.cWidth,
iCType: !item.cType ? 0 : item.cType,
- iCTypeName: item.cType !== null ? (Number(item.cType) === 0 ? "矩形" : Number(item.cType) === 1 ? "梯形" : null) : null,
+ iCTypeName: item.cType !== null ? shapeList[item.iCType] : null,
sCOffset: !item.cOffset ? 0 : item.cOffset,
iCQuantity: !item.cQuantity ? 0 : item.cQuantity,
};
@@ -668,12 +678,12 @@ const BoxDesignCompontent = baseProps => {
// 计算展长公式 sLengthFormula
let sLengthFormula = "";
let sWidthFormula = "";
- const boxType = boxList.find(item => item.sName === "盒身"|| item.sName.trim() === "Box Body")?.type;
+ const boxType = boxList.find(item => item.sName === boxBodyList[0]?.showName)?.type;
if (boxType === "8") {
} else {
- const boxLength = Number(boxList.find(item => item.sName === "盒长"|| item.sName.trim() === "Box Length")?.value);
- const boxWidth = Number(boxList.find(item => item.sName === "盒宽"|| item.sName.trim() === "Box Width")?.value);
- const boxHeight = Number(boxList.find(item => item.sName === "盒高"|| item.sName.trim() === "Box Height")?.value);
+ const boxLength = Number(boxList.find(item => item.sName === "盒长" || item.sName?.trim() === "Box Length")?.value);
+ const boxWidth = Number(boxList.find(item => item.sName === "盒宽" || item.sName?.trim() === "Box Width")?.value);
+ const boxHeight = Number(boxList.find(item => item.sName === "盒高" || item.sName?.trim() === "Box Height")?.value);
const zxcw = boxList.find(x => x.sName === "左(下)插位组件");
const zscw = boxList.find(x => x.sName === "左(上)插位组件");
const yscw = boxList.find(x => x.sName === "右(上)插位组件");
@@ -994,15 +1004,16 @@ const BoxDesignCompontent = baseProps => {
// const sDoubleSize = JSON.stringify([headLength,headWidth,orderLength,orderWidth])
// 存储盒身数据 主表
+ // boxList.find(item => item.sName === boxBodyList[0]?.showName)?.type;
const newMasterData = {
...masterData,
- sBoxBody: boxList.find(item => item.sName === "盒身" || item.sName.trim() === "Box Body")?.value || "",
- dBoxLength: boxList.find(item => item.sName === "盒长" || item.sName.trim() === "Box Length")?.value || "",
- dBoxWidth: boxList.find(item => item.sName === "盒宽" || item.sName.trim() === "Box Width")?.value || "",
- dBoxHeight: boxList.find(item => item.sName === "盒高" || item.sName.trim() === "Box Height")?.value || "",
- sName: boxList.find(item => item.sName === "盒型名称" || item.sName.trim() === "Box Name")?.value || "",
- sMakeUpPath: boxList.find(item => item.sName === "盒身" || item.sName.trim() === "Box Body") ?.selectImage || "",
- sTypes: boxList.find(item => item.sName === "盒身" || item.sName.trim() === "Box Body")?.type || "",
+ sBoxBody: boxList.find(item => item.sName.trim() === boxBodyList[0]?.showName)?.value || "",
+ dBoxLength: boxList.find(item => item.sName?.trim() === tableDataList[0].showName)?.value || "",
+ dBoxWidth: boxList.find(item => item.sName?.trim() === tableDataList[1].showName)?.value || "",
+ dBoxHeight: boxList.find(item => item.sName?.trim() === tableDataList[2].showName)?.value || "",
+ sName: boxList.find(item => item.sName?.trim() === tableColum[0].showName)?.value || "",
+ sMakeUpPath: boxList.find(item => item.sName === boxBodyList[0]?.showName)?.selectImage || "",
+ sTypes: boxList.find(item => item.sName.trim() === boxBodyList[0]?.showName)?.type || "",
sLengthFormula: masterData.sLengthFormula || sLengthFormula,
sWidthFormula: masterData.sWidthFormula || sWidthFormula,
};
@@ -1041,7 +1052,7 @@ const BoxDesignCompontent = baseProps => {
title={title}
visible={boxVisible}
onCancel={onCancel}
- okText="创建"
+ okText={btnName}
onOk={submit}
bodyStyle={{
height: "calc(95vh - 105px)",
@@ -1060,7 +1071,7 @@ const BoxDesignCompontent = baseProps => {
{boxType !== "8" &&
topBoxList.map((topItem, index) => (
-
{topItem.sName}
+
{topItem.showNames}
{topItem?.selectImage ? (

{