diff --git a/src/mes/common/commonModelComponent/index.js b/src/mes/common/commonModelComponent/index.js index 959c20d..d1fc4a2 100644 --- a/src/mes/common/commonModelComponent/index.js +++ b/src/mes/common/commonModelComponent/index.js @@ -2621,17 +2621,28 @@ const CommonTableComponent = props => { // 拆分为C、M、Y、K四个单独选项 const colors = item.sName.split("+"); colors.forEach(color => { + // 根据颜色获取对应的板数值,如果没有保存过则默认为1 + let plateNum = 1; + if (color === 'C' && item.cPlateNum !== undefined) plateNum = item.cPlateNum; + else if (color === 'M' && item.mPlateNum !== undefined) plateNum = item.mPlateNum; + else if (color === 'Y' && item.yPlateNum !== undefined) plateNum = item.yPlateNum; + else if (color === 'K' && item.kPlateNum !== undefined) plateNum = item.kPlateNum; + processedColorList.push({ ...item, sId: `${item.sId}_${color}`, // 生成唯一ID sName: color, - dColor: 1, // 每个颜色板数为1 + dColor: plateNum, // 使用保存的板数值 bSelected: item.bSelected || false, isSplitFromCMYK: true // 标记为从CMYK拆分 }); }); } else { - processedColorList.push(item); + // 非CMYK颜色,使用保存的dColor值,如果没有则默认为1 + processedColorList.push({ + ...item, + dColor: item.dColor !== undefined ? item.dColor : 1 + }); } }); @@ -3488,11 +3499,16 @@ const SisColorChooseComponent = props => { originalColorList.forEach(item => { if (item.sName === 'C+M+Y+K') { // 处理CMYK颜色 - // 检查C、M、Y、K是否被选中 - const cSelected = rightData.some(item => item.sName === 'C' && item.isSplitFromCMYK); - const mSelected = rightData.some(item => item.sName === 'M' && item.isSplitFromCMYK); - const ySelected = rightData.some(item => item.sName === 'Y' && item.isSplitFromCMYK); - const kSelected = rightData.some(item => item.sName === 'K' && item.isSplitFromCMYK); + // 检查C、M、Y、K是否被选中,并获取对应的dColor值 + const cItem = rightData.find(item => item.sName === 'C' && item.isSplitFromCMYK); + const mItem = rightData.find(item => item.sName === 'M' && item.isSplitFromCMYK); + const yItem = rightData.find(item => item.sName === 'Y' && item.isSplitFromCMYK); + const kItem = rightData.find(item => item.sName === 'K' && item.isSplitFromCMYK); + + const cSelected = !!cItem; + const mSelected = !!mItem; + const ySelected = !!yItem; + const kSelected = !!kItem; // 计算选中的CMYK颜色数量 const selectedCount = [cSelected, mSelected, ySelected, kSelected].filter(Boolean).length; @@ -3505,14 +3521,21 @@ const SisColorChooseComponent = props => { cSelected, mSelected, ySelected, - kSelected + kSelected, + // 保存每个颜色的板数 + cPlateNum: cItem?.dColor || 0, + mPlateNum: mItem?.dColor || 0, + yPlateNum: yItem?.dColor || 0, + kPlateNum: kItem?.dColor || 0, }); } else { // 处理非CMYK的颜色 - const i = rightData.findIndex(rightItem => rightItem.sId === item.sId); + const rightItem = rightData.find(rightItem => rightItem.sId === item.sId); colorList.push({ ...item, - bSelected: i > -1 + bSelected: !!rightItem, + // 保存板数到JSON中 + dColor: rightItem?.dColor || item.dColor || 0 }); } }); @@ -3596,8 +3619,40 @@ const SisColorChooseComponent = props => { }, ]; + const handlePlateNumChange = (value, record) => { + const newData = rightData.map(item => { + if (item.sId === record.sId) { + return { ...item, dColor: Number(value) || 0 }; + } + return item; + }); + setRightData(newData); + }; + const rightColumns = [ - ...baseColumns.map(col => ({ ...col })), + ...baseColumns.map(col => { + if (col.dataIndex === 'dColor') { + return { + ...col, + render: (text, record) => ( + handlePlateNumChange(e.target.value, record)} + style={{ + width: '80px', + padding: '4px 8px', + border: '1px solid #d9d9d9', + borderRadius: '4px', + fontSize: '14px' + }} + /> + ) + }; + } + return { ...col }; + }), { title: '操作', key: 'action',