浏览代码

feat(exam): 防止删除检查中的最后一个体位

sw 1 周之前
父节点
当前提交
7e7095e698
共有 1 个文件被更改,包括 10 次插入2 次删除
  1. 10 2
      src/pages/exam/ContentAreaLarge.tsx

+ 10 - 2
src/pages/exam/ContentAreaLarge.tsx

@@ -324,8 +324,16 @@ const ContentAreaLarge = () => {
                 />
               }
               onClick={async () => {
-                const selectedBodyPosition =
-                  store.getState().bodyPositionList.selectedBodyPosition;
+                const state = store.getState().bodyPositionList;
+                const selectedBodyPosition = state.selectedBodyPosition;
+                const bodyPositions = state.bodyPositions;
+
+                // 检查体位数量,至少保留一个
+                if (bodyPositions.length <= 1) {
+                  message.warning('至少需要保留一个体位,无法删除');
+                  return;
+                }
+
                 console.log(
                   `选中的体位:${JSON.stringify(selectedBodyPosition)}`
                 );