|
@@ -74,20 +74,58 @@ export const selectBodyPositionWithFullLogic = async (
|
|
|
|
|
|
/**
|
|
|
* 自动选中第一个体位(通常在进入exam时调用)
|
|
|
+ * - exam 模式:自动选择第一个未曝光的体位
|
|
|
+ * - process 模式:自动选择第一个已曝光的体位
|
|
|
+ * - 其他模式:选择第一个体位
|
|
|
*/
|
|
|
export const autoSelectFirstBodyPosition = async (
|
|
|
bodyPositions: ExtendedBodyPosition[],
|
|
|
dispatch: AppDispatch,
|
|
|
currentKey: string
|
|
|
): Promise<void> => {
|
|
|
- if (bodyPositions.length > 0) {
|
|
|
- console.log('[bodyPositionSelection] Auto-selecting first body position');
|
|
|
+ if (bodyPositions.length === 0) {
|
|
|
+ console.log('[bodyPositionSelection] No body positions available');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 根据当前业务流程选择合适的体位
|
|
|
+ let targetBodyPosition: ExtendedBodyPosition | undefined;
|
|
|
+
|
|
|
+ if (currentKey === 'exam') {
|
|
|
+ // exam 模式:选择第一个未曝光的体位
|
|
|
+ targetBodyPosition = bodyPositions.find(
|
|
|
+ (bp) => bp.dview.expose_status === 'Unexposed'
|
|
|
+ );
|
|
|
+ console.log(
|
|
|
+ '[bodyPositionSelection] Auto-selecting first unexposed body position in exam mode'
|
|
|
+ );
|
|
|
+ } else if (currentKey === 'process') {
|
|
|
+ // process 模式:选择第一个已曝光的体位
|
|
|
+ targetBodyPosition = bodyPositions.find(
|
|
|
+ (bp) => bp.dview.expose_status === 'Exposed'
|
|
|
+ );
|
|
|
+ console.log(
|
|
|
+ '[bodyPositionSelection] Auto-selecting first exposed body position in process mode'
|
|
|
+ );
|
|
|
+ } else {
|
|
|
+ // 其他模式:默认选择第一个
|
|
|
+ targetBodyPosition = bodyPositions[0];
|
|
|
+ console.log(
|
|
|
+ `[bodyPositionSelection] Auto-selecting first body position in ${currentKey} mode`
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ if (targetBodyPosition) {
|
|
|
await selectBodyPositionWithFullLogic(
|
|
|
- bodyPositions[0],
|
|
|
+ targetBodyPosition,
|
|
|
dispatch,
|
|
|
currentKey,
|
|
|
false // 自动选中时不显示用户消息
|
|
|
);
|
|
|
+ } else {
|
|
|
+ console.warn(
|
|
|
+ `[bodyPositionSelection] No suitable body position found for ${currentKey} mode`
|
|
|
+ );
|
|
|
}
|
|
|
};
|
|
|
|