Commit e2c90a9899103f066c19fb13bf7e011cf0c608e0
1 parent
8ed6a56f
1.处理复制从工艺卡后,删除部件报错
Showing
1 changed file
with
20 additions
and
24 deletions
src/components/Manufacture/ProcessCardPackTableTreeNew/index.js
| @@ -2890,32 +2890,28 @@ const controlProps = props => { | @@ -2890,32 +2890,28 @@ const controlProps = props => { | ||
| 2890 | returnProps.onDataRowDel = ({ name }) => { | 2890 | returnProps.onDataRowDel = ({ name }) => { |
| 2891 | const { controlData, [`${name}SelectedRowKeys`]: tableSelectedRowKeys } = props; | 2891 | const { controlData, [`${name}SelectedRowKeys`]: tableSelectedRowKeys } = props; |
| 2892 | if (commonUtils.isNotEmptyArr(tableSelectedRowKeys)) { | 2892 | if (commonUtils.isNotEmptyArr(tableSelectedRowKeys)) { |
| 2893 | - /* 删除该节点及所有子节点 */ | ||
| 2894 | - const tableRow = controlData.find(item => item.sId === tableSelectedRowKeys[0]); | ||
| 2895 | - let controlChildData = []; | ||
| 2896 | - if(commonUtils.isNotEmptyObject(tableRow)) { | ||
| 2897 | - // 递归查找所有子节点 | ||
| 2898 | - const findChildren = (parentId, allNodes) => { | ||
| 2899 | - const children = allNodes.filter(node => node.sControlParentId === parentId); | ||
| 2900 | - let result = [...children]; | ||
| 2901 | - children.forEach(child => { | ||
| 2902 | - result = result.concat(findChildren(child.sNodeId, allNodes)); | ||
| 2903 | - }); | ||
| 2904 | - return result; | ||
| 2905 | - }; | ||
| 2906 | - | ||
| 2907 | - controlChildData = findChildren(tableRow.sNodeId, controlData); | ||
| 2908 | - } | ||
| 2909 | - if (commonUtils.isNotEmptyArr(controlData)) { | ||
| 2910 | - controlChildData.forEach(itemNew => { | ||
| 2911 | - tableSelectedRowKeys.push(itemNew.sId); | 2893 | + const firstId = tableSelectedRowKeys[0]; |
| 2894 | + const deleteIds = [firstId]; // 要删除的ID列表 | ||
| 2895 | + | ||
| 2896 | + let i = 0; | ||
| 2897 | + while (i < deleteIds.length) { | ||
| 2898 | + const currentId = deleteIds[i]; | ||
| 2899 | + // 找到所有子节点 | ||
| 2900 | + const children = controlData.filter(node => node.sControlParentId === currentId); | ||
| 2901 | + // 把子节点ID加入删除列表 | ||
| 2902 | + children.forEach(child => { | ||
| 2903 | + if (!deleteIds.includes(child.sId)) { | ||
| 2904 | + deleteIds.push(child.sId); | ||
| 2905 | + } | ||
| 2912 | }); | 2906 | }); |
| 2907 | + i++; | ||
| 2913 | } | 2908 | } |
| 2914 | - const materialsReturnData = props.otherTableDel("materials", tableSelectedRowKeys); | ||
| 2915 | - const materials0ReturnData = props.otherTableDel("materials0", tableSelectedRowKeys); | ||
| 2916 | - const processReturnData = props.otherTableDel("process", tableSelectedRowKeys); | ||
| 2917 | - const packReturnData = props.otherTableDel("pack", tableSelectedRowKeys); | ||
| 2918 | - const controlReturnData = props.onDataRowDel(name, true, tableSelectedRowKeys); | 2909 | + const materialsReturnData = props.otherTableDel("materials", deleteIds); |
| 2910 | + const materials0ReturnData = props.otherTableDel("materials0", deleteIds); | ||
| 2911 | + const processReturnData = props.otherTableDel("process", deleteIds); | ||
| 2912 | + const packReturnData = props.otherTableDel("pack", deleteIds); | ||
| 2913 | + const controlReturnData = props.onDataRowDel(name, true, deleteIds); | ||
| 2914 | + | ||
| 2919 | props.onSaveState({ | 2915 | props.onSaveState({ |
| 2920 | treeData: [], | 2916 | treeData: [], |
| 2921 | ...materialsReturnData, | 2917 | ...materialsReturnData, |