Commit 6a1b51da4fbf7bfe190a846b39e3f3c6b0b1f6f2

Authored by chenxt
1 parent 4a6c3427

颜色选择可以修改板数

src/mes/common/commonModelComponent/index.js
... ... @@ -2621,17 +2621,28 @@ const CommonTableComponent = props => {
2621 2621 // 拆分为C、M、Y、K四个单独选项
2622 2622 const colors = item.sName.split("+");
2623 2623 colors.forEach(color => {
  2624 + // 根据颜色获取对应的板数值,如果没有保存过则默认为1
  2625 + let plateNum = 1;
  2626 + if (color === 'C' && item.cPlateNum !== undefined) plateNum = item.cPlateNum;
  2627 + else if (color === 'M' && item.mPlateNum !== undefined) plateNum = item.mPlateNum;
  2628 + else if (color === 'Y' && item.yPlateNum !== undefined) plateNum = item.yPlateNum;
  2629 + else if (color === 'K' && item.kPlateNum !== undefined) plateNum = item.kPlateNum;
  2630 +
2624 2631 processedColorList.push({
2625 2632 ...item,
2626 2633 sId: `${item.sId}_${color}`, // 生成唯一ID
2627 2634 sName: color,
2628   - dColor: 1, // 每个颜色板数为1
  2635 + dColor: plateNum, // 使用保存的板数值
2629 2636 bSelected: item.bSelected || false,
2630 2637 isSplitFromCMYK: true // 标记为从CMYK拆分
2631 2638 });
2632 2639 });
2633 2640 } else {
2634   - processedColorList.push(item);
  2641 + // 非CMYK颜色,使用保存的dColor值,如果没有则默认为1
  2642 + processedColorList.push({
  2643 + ...item,
  2644 + dColor: item.dColor !== undefined ? item.dColor : 1
  2645 + });
2635 2646 }
2636 2647 });
2637 2648  
... ... @@ -3488,11 +3499,16 @@ const SisColorChooseComponent = props => {
3488 3499 originalColorList.forEach(item => {
3489 3500 if (item.sName === 'C+M+Y+K') {
3490 3501 // 处理CMYK颜色
3491   - // 检查C、M、Y、K是否被选中
3492   - const cSelected = rightData.some(item => item.sName === 'C' && item.isSplitFromCMYK);
3493   - const mSelected = rightData.some(item => item.sName === 'M' && item.isSplitFromCMYK);
3494   - const ySelected = rightData.some(item => item.sName === 'Y' && item.isSplitFromCMYK);
3495   - const kSelected = rightData.some(item => item.sName === 'K' && item.isSplitFromCMYK);
  3502 + // 检查C、M、Y、K是否被选中,并获取对应的dColor值
  3503 + const cItem = rightData.find(item => item.sName === 'C' && item.isSplitFromCMYK);
  3504 + const mItem = rightData.find(item => item.sName === 'M' && item.isSplitFromCMYK);
  3505 + const yItem = rightData.find(item => item.sName === 'Y' && item.isSplitFromCMYK);
  3506 + const kItem = rightData.find(item => item.sName === 'K' && item.isSplitFromCMYK);
  3507 +
  3508 + const cSelected = !!cItem;
  3509 + const mSelected = !!mItem;
  3510 + const ySelected = !!yItem;
  3511 + const kSelected = !!kItem;
3496 3512  
3497 3513 // 计算选中的CMYK颜色数量
3498 3514 const selectedCount = [cSelected, mSelected, ySelected, kSelected].filter(Boolean).length;
... ... @@ -3505,14 +3521,21 @@ const SisColorChooseComponent = props => {
3505 3521 cSelected,
3506 3522 mSelected,
3507 3523 ySelected,
3508   - kSelected
  3524 + kSelected,
  3525 + // 保存每个颜色的板数
  3526 + cPlateNum: cItem?.dColor || 0,
  3527 + mPlateNum: mItem?.dColor || 0,
  3528 + yPlateNum: yItem?.dColor || 0,
  3529 + kPlateNum: kItem?.dColor || 0,
3509 3530 });
3510 3531 } else {
3511 3532 // 处理非CMYK的颜色
3512   - const i = rightData.findIndex(rightItem => rightItem.sId === item.sId);
  3533 + const rightItem = rightData.find(rightItem => rightItem.sId === item.sId);
3513 3534 colorList.push({
3514 3535 ...item,
3515   - bSelected: i > -1
  3536 + bSelected: !!rightItem,
  3537 + // 保存板数到JSON中
  3538 + dColor: rightItem?.dColor || item.dColor || 0
3516 3539 });
3517 3540 }
3518 3541 });
... ... @@ -3596,8 +3619,40 @@ const SisColorChooseComponent = props => {
3596 3619 },
3597 3620 ];
3598 3621  
  3622 + const handlePlateNumChange = (value, record) => {
  3623 + const newData = rightData.map(item => {
  3624 + if (item.sId === record.sId) {
  3625 + return { ...item, dColor: Number(value) || 0 };
  3626 + }
  3627 + return item;
  3628 + });
  3629 + setRightData(newData);
  3630 + };
  3631 +
3599 3632 const rightColumns = [
3600   - ...baseColumns.map(col => ({ ...col })),
  3633 + ...baseColumns.map(col => {
  3634 + if (col.dataIndex === 'dColor') {
  3635 + return {
  3636 + ...col,
  3637 + render: (text, record) => (
  3638 + <input
  3639 + type="number"
  3640 + min={0}
  3641 + value={text || 0}
  3642 + onChange={(e) => handlePlateNumChange(e.target.value, record)}
  3643 + style={{
  3644 + width: '80px',
  3645 + padding: '4px 8px',
  3646 + border: '1px solid #d9d9d9',
  3647 + borderRadius: '4px',
  3648 + fontSize: '14px'
  3649 + }}
  3650 + />
  3651 + )
  3652 + };
  3653 + }
  3654 + return { ...col };
  3655 + }),
3601 3656 {
3602 3657 title: '操作',
3603 3658 key: 'action',
... ...