Browse Source

屏蔽不支持的PSAD #0011949

gavin.chen 1 year ago
parent
commit
c5a17cfcda

+ 11 - 5
.vscode/settings.json

@@ -1,6 +1,12 @@
 {
-    "editor.detectIndentation": false,
-    "editor.tabSize": 4,
-    "editor.formatOnPaste": true,
-    "editor.formatOnSave": true
-}
+  "editor.detectIndentation": false,
+  "editor.tabSize": 4,
+  "editor.formatOnPaste": true,
+  "editor.formatOnSave": true
+  //** 保存时自动修正 **// (需要时开启)
+  //   "editor.codeActionsOnSave": {
+  //     "source.fixAll": true,
+  //     "source.organizeImports": true,
+  //     "source.sortMembers": true
+  //   }
+}

+ 305 - 301
lib/view/mobile_view/mobile_right_panel/mobile_measure_tool.dart

@@ -21,6 +21,14 @@ import 'package:get/get.dart';
 import 'package:vid/us/vid_us_unit.dart';
 import 'package:vid/us/vid_us_visual_area_type.dart';
 
+class MobileBaseMeasureItemBtn {
+  ItemMeta itemMeta;
+  String displayName;
+  IconData icon;
+  MobileBaseMeasureItemBtn(
+      {required this.itemMeta, required this.displayName, required this.icon});
+}
+
 /// 移动端测量项选择器(继承自 测量项页面)
 class MobileMeasureSelector extends FStatefulWidget {
   const MobileMeasureSelector({Key? key}) : super(key: key);
@@ -29,6 +37,16 @@ class MobileMeasureSelector extends FStatefulWidget {
   FState<MobileMeasureSelector> createState() => _MobileMeasureSelector();
 }
 
+class MobileMoreMeasureItemModesModel {
+  String modeName;
+  String displayName;
+  List<MeasureItemModel> availableItems;
+  MobileMoreMeasureItemModesModel(
+      {required this.modeName,
+      required this.displayName,
+      required this.availableItems});
+}
+
 class _MobileMeasureSelector extends FState<MobileMeasureSelector> {
   late final application = Get.find<IApplication>();
 
@@ -109,10 +127,6 @@ class _MobileMeasureSelector extends FState<MobileMeasureSelector> {
     VidUsVisualAreaType.Flow,
   ];
 
-  /// 是否允许使用基础测量项
-  bool get _isEnableBaseMeasureItems =>
-      _supportBasicMeasureAreaTypes.contains(_currentAreaType);
-
   /// 是否已初始化完成所有测量项数据
   bool _isInitAllMeasureItems = false;
 
@@ -125,6 +139,27 @@ class _MobileMeasureSelector extends FState<MobileMeasureSelector> {
   /// 判断是否为特殊测量项
   bool get isSpecial => MeasurespecialsupportedTerms.items.contains(activeName);
 
+  /// 是否允许使用基础测量项
+  bool get _isEnableBaseMeasureItems =>
+      _supportBasicMeasureAreaTypes.contains(_currentAreaType);
+
+  @override
+  FWidget build(BuildContext context) {
+    return FSizedBox(
+      width: 100,
+      child: showMore
+          ? _buildExtraMeasureItemPanel()
+          : _buildBaseMeasureItemPanel(),
+    );
+  }
+
+  /// 切换子测量项
+  void changeChildItem(int index) {
+    if (isCombo && topMeasureItem != null) {
+      topMeasureItem!.switchChild(index);
+    }
+  }
+
   /// 切换测量项
   bool changeItem(ItemMeta itemMeta) {
     if (mounted) {
@@ -141,80 +176,6 @@ class _MobileMeasureSelector extends FState<MobileMeasureSelector> {
     return success;
   }
 
-  /// 切换子测量项
-  void changeChildItem(int index) {
-    if (isCombo && topMeasureItem != null) {
-      topMeasureItem!.switchChild(index);
-    }
-  }
-
-  /// 子测量项变化事件监听
-  void _onWorkingChildChanged(sender, int e) {
-    setState(() {
-      activeChildItemIndex = e;
-    });
-  }
-
-  /// 测量项变化事件监听
-  /// 需要重新绑定子测量项
-  void _onActiveMeasureItemChanged(sender, IMeasureItem? e) {
-    if (e != null) {
-      final item = application.activeMeasureItem!;
-      if (item is ITopMeasureItem) {
-        topMeasureItem = item;
-        isCombo = true;
-        item.switchChild(0);
-        activeChildItemIndex = 0;
-        item.workingChildChanged.addListener(_onWorkingChildChanged);
-        childItemLabels = item.childItems.map((e) => (e.description)).toList();
-      } else {
-        isCombo = false;
-      }
-      if (mounted) {
-        setState(() {});
-      }
-    } else {
-      /// 如果为空测量项
-      isCombo = false;
-      activeChildItemIndex = 0;
-      showMore = false;
-      activeName = "";
-      if (mounted) {
-        setState(() {});
-      }
-    }
-  }
-
-  void _visualAreaChanged(sender, IVisualArea e) {
-    _cancelCurrSelect();
-    _currentAreaType = e.visualAreaType;
-  }
-
-  @override
-  FWidget build(BuildContext context) {
-    return FSizedBox(
-      width: 100,
-      child: showMore
-          ? _buildExtraMeasureItemPanel()
-          : _buildBaseMeasureItemPanel(),
-    );
-  }
-
-  @override
-  void initState() {
-    super.initState();
-    _cancelCurrSelect();
-    application.activeMeasureItemChanged
-        .addListener(_onActiveMeasureItemChanged);
-    application.visualAreaChanged.addListener(_visualAreaChanged);
-    _currentAreaType = application.currentVisualArea.visualAreaType;
-    _initMeasureItemsListAsync();
-  }
-
-  void _initMeasureItemsListAsync() async {
-    _availableModes = await _initMeasureItemsList();
-  }
-
   @override
   void dispose() {
     super.dispose();
@@ -227,68 +188,15 @@ class _MobileMeasureSelector extends FState<MobileMeasureSelector> {
     }
   }
 
-  /// 构建基础测量项面板
-  FWidget _buildBaseMeasureItemPanel() {
-    return FColumn(
-      mainAxisAlignment: MainAxisAlignment.center,
-      mainAxisSize: MainAxisSize.max,
-      children: [
-        ..._mobileBasicMeasureItemsList.map((e) {
-          return _buildBaseMeasureBtn(
-              e.itemMeta, e.itemMeta.name == activeName, e.displayName, e.icon);
-        }).toList(),
-        if (!application.isThirdPart) _buildChangeMoreMeasureItem(),
-      ],
-    );
-  }
-
-  /// 构建更多测量项面板
-  FWidget _buildExtraMeasureItemPanel() {
-    return FColumn(
-      mainAxisAlignment: MainAxisAlignment.center,
-      mainAxisSize: MainAxisSize.max,
-      children: [
-        const FSizedBox(
-          height: 50,
-        ),
-        ..._buildCurrentMeasureItem(),
-        const FSizedBox(
-          height: 10,
-        ),
-        FExpanded(child: _buildChildItemBtns()),
-        _buildCancelCurrMeasureItemBtn(),
-        _buildChangeMoreMeasureItem(),
-      ],
-    );
-  }
-
-  List<FWidget> _buildCurrentMeasureItem() {
-    final measureLanguage = MeasureLanguage();
-    final displayName = measureLanguage.t('measure', activeName);
-    return [
-      FText(
-        i18nBook.measure.currentMeasureTool.t,
-        textAlign: TextAlign.center,
-        style: const TextStyle(color: Colors.grey, fontSize: 14),
-      ),
-      const FSizedBox(
-        height: 10,
-      ),
-      FText(
-        activeName,
-        textAlign: TextAlign.center,
-        style: const TextStyle(color: Colors.white),
-      ),
-      const FSizedBox(
-        height: 5,
-      ),
-      if (i18nBook.isCurrentChinese)
-        FText(
-          displayName,
-          textAlign: TextAlign.center,
-          style: const TextStyle(color: Colors.grey, fontSize: 12),
-        ),
-    ];
+  @override
+  void initState() {
+    super.initState();
+    _cancelCurrSelect();
+    application.activeMeasureItemChanged
+        .addListener(_onActiveMeasureItemChanged);
+    application.visualAreaChanged.addListener(_visualAreaChanged);
+    _currentAreaType = application.currentVisualArea.visualAreaType;
+    _initMeasureItemsListAsync();
   }
 
   /// 构建基础测量项按钮
@@ -340,12 +248,30 @@ class _MobileMeasureSelector extends FState<MobileMeasureSelector> {
     );
   }
 
-  /// 构建打开更多测量项按钮
-  FWidget _buildChangeMoreMeasureItem() {
+  /// 构建基础测量项面板
+  FWidget _buildBaseMeasureItemPanel() {
+    return FColumn(
+      mainAxisAlignment: MainAxisAlignment.center,
+      mainAxisSize: MainAxisSize.max,
+      children: [
+        ..._mobileBasicMeasureItemsList.map((e) {
+          return _buildBaseMeasureBtn(
+              e.itemMeta, e.itemMeta.name == activeName, e.displayName, e.icon);
+        }).toList(),
+        if (!application.isThirdPart) _buildChangeMoreMeasureItem(),
+      ],
+    );
+  }
+
+  /// 构建取消当前测量项按钮
+  FWidget _buildCancelCurrMeasureItemBtn() {
     return FInkWell(
-      onTap: () async {
+      onTap: () {
+        _cancelCurrSelect();
+        setState(() {
+          showMore = false;
+        });
         HapticFeedback.mediumImpact();
-        await _openMoreMeasureItemDialog();
       },
       child: Container(
         margin: const EdgeInsets.fromLTRB(0, 10, 10, 10),
@@ -358,11 +284,11 @@ class _MobileMeasureSelector extends FState<MobileMeasureSelector> {
         child: FColumn(
           children: [
             const FIcon(
-              Icons.format_list_bulleted,
+              Icons.cancel_outlined,
               color: Colors.grey,
             ),
             FText(
-              i18nBook.measure.expandGroup.t,
+              i18nBook.common.cancel.t,
               style: const TextStyle(
                 color: Colors.grey,
               ),
@@ -373,15 +299,12 @@ class _MobileMeasureSelector extends FState<MobileMeasureSelector> {
     );
   }
 
-  /// 构建取消当前测量项按钮
-  FWidget _buildCancelCurrMeasureItemBtn() {
+  /// 构建打开更多测量项按钮
+  FWidget _buildChangeMoreMeasureItem() {
     return FInkWell(
-      onTap: () {
-        _cancelCurrSelect();
-        setState(() {
-          showMore = false;
-        });
+      onTap: () async {
         HapticFeedback.mediumImpact();
+        await _openMoreMeasureItemDialog();
       },
       child: Container(
         margin: const EdgeInsets.fromLTRB(0, 10, 10, 10),
@@ -394,11 +317,11 @@ class _MobileMeasureSelector extends FState<MobileMeasureSelector> {
         child: FColumn(
           children: [
             const FIcon(
-              Icons.cancel_outlined,
+              Icons.format_list_bulleted,
               color: Colors.grey,
             ),
             FText(
-              i18nBook.common.cancel.t,
+              i18nBook.measure.expandGroup.t,
               style: const TextStyle(
                 color: Colors.grey,
               ),
@@ -409,21 +332,6 @@ class _MobileMeasureSelector extends FState<MobileMeasureSelector> {
     );
   }
 
-  /// 构建子测量项选择器
-  FWidget _buildChildItemBtns() {
-    if (isSpecial) {
-      //是否为特殊组合测量项
-      return const SpecialItemHR();
-    }
-    if (!isCombo) return const FSizedBox();
-    return FListView(
-      children: List.generate(
-        childItemLabels.length,
-        (index) => _buildChildItemBtn(index, childItemLabels[index]),
-      ),
-    );
-  }
-
   /// 构建子测量项按钮
   FWidget _buildChildItemBtn(int index, String displayName) {
     final bool isActive = index == activeChildItemIndex;
@@ -451,56 +359,68 @@ class _MobileMeasureSelector extends FState<MobileMeasureSelector> {
     );
   }
 
-  /// 打开更多测量项选择器
-  Future<void> _openMoreMeasureItemDialog() async {
-    List<MobileMoreMeasureItemModesModel> modes = [];
-    if (_isInitAllMeasureItems) {
-      modes = _availableModes;
-    } else {
-      modes = await _initMeasureItemsList();
-      _availableModes = modes;
+  /// 构建子测量项选择器
+  FWidget _buildChildItemBtns() {
+    if (isSpecial) {
+      //是否为特殊组合测量项
+      return const SpecialItemHR();
     }
-    final List<String> _currModes =
-        _findModesByCurrArea(application.currentVisualArea);
-
-    final List<MobileMoreMeasureItemModesModel> activeModes = modes
-        .where((element) => _currModes.contains(element.modeName))
-        .toList();
+    if (!isCombo) return const FSizedBox();
+    return FListView(
+      children: List.generate(
+        childItemLabels.length,
+        (index) => _buildChildItemBtn(index, childItemLabels[index]),
+      ),
+    );
+  }
 
-    final MoreMeasureBackResult? result =
-        await Get.dialog<MoreMeasureBackResult>(MobileMoreMeasureItemDialog(
-      measureModeList: activeModes,
-      activeItemName: activeName,
-      initModeIndex: showMore ? moreMeasureBackResult?.currModeIndex : null,
-      initScrollOffset:
-          showMore ? moreMeasureBackResult?.currScrollOffset : null,
-    ));
-    if (result != null) {
-      moreMeasureBackResult = result;
-      bool success = changeItem(result.selectedMeasureItemMeta);
-      if (success) {
-        setState(() {
-          showMore = true;
-        });
-      } else {
-        PromptBox.toast(i18nBook.measure.temporarilyUnsupportedMeasurement.t);
-      }
-    }
+  List<FWidget> _buildCurrentMeasureItem() {
+    final measureLanguage = MeasureLanguage();
+    final displayName = measureLanguage.t('measure', activeName);
+    return [
+      FText(
+        i18nBook.measure.currentMeasureTool.t,
+        textAlign: TextAlign.center,
+        style: const TextStyle(color: Colors.grey, fontSize: 14),
+      ),
+      const FSizedBox(
+        height: 10,
+      ),
+      FText(
+        activeName,
+        textAlign: TextAlign.center,
+        style: const TextStyle(color: Colors.white),
+      ),
+      const FSizedBox(
+        height: 5,
+      ),
+      if (i18nBook.isCurrentChinese)
+        FText(
+          displayName,
+          textAlign: TextAlign.center,
+          style: const TextStyle(color: Colors.grey, fontSize: 12),
+        ),
+    ];
   }
 
-  /// 可能有些区域会重叠,无法手动区分,所以需要根据当前的区域来查找可以使用的测量项
-  List<String> _findModesByCurrArea(IVisualArea currArea) {
-    List<String> modes = [];
-    List<IVisualArea> visualAreas = application.visuals[0].visualAreas;
-    if (visualAreas.isEmpty) {
-      return modes;
-    }
-    for (IVisualArea element in visualAreas) {
-      if (element.displayRegion == currArea.displayRegion) {
-        modes.add(element.mode.modeType.toString().split('.')[1]);
-      }
-    }
-    return modes;
+  /// 构建更多测量项面板
+  FWidget _buildExtraMeasureItemPanel() {
+    return FColumn(
+      mainAxisAlignment: MainAxisAlignment.center,
+      mainAxisSize: MainAxisSize.max,
+      children: [
+        const FSizedBox(
+          height: 50,
+        ),
+        ..._buildCurrentMeasureItem(),
+        const FSizedBox(
+          height: 10,
+        ),
+        FExpanded(child: _buildChildItemBtns()),
+        _buildCancelCurrMeasureItemBtn(),
+        _buildChangeMoreMeasureItem(),
+      ],
+    );
   }
 
   /// 取消当前选中的测量项
@@ -517,73 +437,6 @@ class _MobileMeasureSelector extends FState<MobileMeasureSelector> {
     );
   }
 
-  /// 获取当前帧信息来初始化当前测量项
-  Future<List<MobileMoreMeasureItemModesModel>> _initMeasureItemsList() async {
-    final vidImage = playerController.currentFrame;
-    if (vidImage == null) return [];
-    List<String> getModes = [];
-    List<String> displayModeNames = [];
-    for (var element in vidImage.visuals[0].modes) {
-      getModes.add(element.type.toString().split('.')[1]);
-      displayModeNames.add(element.displayName);
-    }
-    measureData.applicationModes = vidImage.visuals[0].modes;
-    measureData.currentMode = vidImage.visuals[0].modes.first.type.name;
-    var measureModeSelection = MeasureModeSelection(
-      application.applicationName,
-      application.categoryName,
-      application.isThirdPart ? ['TPPTissue'] : getModes,
-    );
-
-    /// 请求数据
-    final MeasureApplicationDTO? measureApplicationDTO =
-        await measureData.getMeasureApplication.call(measureModeSelection);
-    if (measureApplicationDTO == null ||
-        measureApplicationDTO.availableModes == null) return [];
-
-    /// 遍历 measureApplicationDTO.availableModes 拼装出新的 supportedModes
-    List<MobileMoreMeasureItemModesModel> supportedModes = [];
-    for (int i = 0; i < measureApplicationDTO.availableModes!.length; i++) {
-      MeasureModeDTO mode = measureApplicationDTO.availableModes![i];
-      List<ItemMetaDTO> supportedItems = _currSupportedItemFilter(mode);
-      String displayName =
-          displayModeNames.length > i ? displayModeNames[i] : '';
-      MobileMoreMeasureItemModesModel modeModel =
-          MobileMoreMeasureItemModesModel(
-              modeName: mode.modeName ?? '',
-              displayName: displayName,
-              availableItems: _itemConverter(supportedItems));
-      supportedModes.add(modeModel);
-    }
-    if (supportedModes.isNotEmpty) {
-      _isInitAllMeasureItems = true;
-    }
-    return supportedModes;
-  }
-
-  List<MeasureItemModel> _itemConverter(List<ItemMetaDTO> items) {
-    if (i18nBook.isCurrentChinese) {
-      return items.map((e) {
-        final cName = measureLanguage.t('measure', e.description ?? '');
-        return MeasureItemModel(
-          displayName: cName,
-          itemMeta: e,
-          category: e.categories?.first ?? '',
-          searchKey: "${e.name?.toLowerCase()}$cName",
-        );
-      }).toList();
-    } else {
-      return items.map((e) {
-        return MeasureItemModel(
-          displayName: e.name ?? '',
-          itemMeta: e,
-          category: e.categories?.first ?? '',
-          searchKey: "${e.name?.toLowerCase()}",
-        );
-      }).toList();
-    }
-  }
-
   /// 过滤出当前支持的所有测量项
   List<ItemMetaDTO> _currSupportedItemFilter(MeasureModeDTO mode) {
     final supportedMeasureTypeName = [
@@ -645,7 +498,6 @@ class _MobileMeasureSelector extends FState<MobileMeasureSelector> {
             }
           }
 
-          /// 筛选支持的组合测量项
           if (items.methodChildItems != null &&
               items.methodChildItems!.isNotEmpty) {
             bool isAdd = true;
@@ -659,6 +511,11 @@ class _MobileMeasureSelector extends FState<MobileMeasureSelector> {
             }
           }
 
+          /// 排除不支持的项
+          if (MeasureUnsupportedTerms.items.contains(items.name)) {
+            isSupported = false;
+          }
+
           // final cName = measureLanguage.t('measure', items.description ?? '');
           if (isSupported) {
             _supportedItems.add(items);
@@ -671,25 +528,172 @@ class _MobileMeasureSelector extends FState<MobileMeasureSelector> {
         }
       }
     }
-    print("${mode.modeName} 模式下过滤出 ${_supportedItems.length} 项");
+    // print("${mode.modeName} 模式下过滤出 ${_supportedItems.length} 项");
     return _supportedItems;
   }
-}
 
-class MobileBaseMeasureItemBtn {
-  ItemMeta itemMeta;
-  String displayName;
-  IconData icon;
-  MobileBaseMeasureItemBtn(
-      {required this.itemMeta, required this.displayName, required this.icon});
-}
+  /// 可能有些区域会重叠,无法手动区分,所以需要根据当前的区域来查找可以使用的测量项
+  List<String> _findModesByCurrArea(IVisualArea currArea) {
+    List<String> modes = [];
+    List<IVisualArea> visualAreas = application.visuals[0].visualAreas;
+    if (visualAreas.isEmpty) {
+      return modes;
+    }
+    for (IVisualArea element in visualAreas) {
+      if (element.displayRegion == currArea.displayRegion) {
+        modes.add(element.mode.modeType.toString().split('.')[1]);
+      }
+    }
+    return modes;
+  }
 
-class MobileMoreMeasureItemModesModel {
-  String modeName;
-  String displayName;
-  List<MeasureItemModel> availableItems;
-  MobileMoreMeasureItemModesModel(
-      {required this.modeName,
-      required this.displayName,
-      required this.availableItems});
+  /// 获取当前帧信息来初始化当前测量项
+  Future<List<MobileMoreMeasureItemModesModel>> _initMeasureItemsList() async {
+    final vidImage = playerController.currentFrame;
+    if (vidImage == null) return [];
+    List<String> getModes = [];
+    List<String> displayModeNames = [];
+    for (var element in vidImage.visuals[0].modes) {
+      getModes.add(element.type.toString().split('.')[1]);
+      displayModeNames.add(element.displayName);
+    }
+    measureData.applicationModes = vidImage.visuals[0].modes;
+    measureData.currentMode = vidImage.visuals[0].modes.first.type.name;
+    var measureModeSelection = MeasureModeSelection(
+      application.applicationName,
+      application.categoryName,
+      application.isThirdPart ? ['TPPTissue'] : getModes,
+    );
+
+    /// 请求数据
+    final MeasureApplicationDTO? measureApplicationDTO =
+        await measureData.getMeasureApplication.call(measureModeSelection);
+    if (measureApplicationDTO == null ||
+        measureApplicationDTO.availableModes == null) return [];
+
+    /// 遍历 measureApplicationDTO.availableModes 拼装出新的 supportedModes
+    List<MobileMoreMeasureItemModesModel> supportedModes = [];
+    for (int i = 0; i < measureApplicationDTO.availableModes!.length; i++) {
+      MeasureModeDTO mode = measureApplicationDTO.availableModes![i];
+      List<ItemMetaDTO> supportedItems = _currSupportedItemFilter(mode);
+      String displayName =
+          displayModeNames.length > i ? displayModeNames[i] : '';
+      MobileMoreMeasureItemModesModel modeModel =
+          MobileMoreMeasureItemModesModel(
+              modeName: mode.modeName ?? '',
+              displayName: displayName,
+              availableItems: _itemConverter(supportedItems));
+      supportedModes.add(modeModel);
+    }
+    if (supportedModes.isNotEmpty) {
+      _isInitAllMeasureItems = true;
+    }
+    return supportedModes;
+  }
+
+  void _initMeasureItemsListAsync() async {
+    _availableModes = await _initMeasureItemsList();
+  }
+
+  List<MeasureItemModel> _itemConverter(List<ItemMetaDTO> items) {
+    if (i18nBook.isCurrentChinese) {
+      return items.map((e) {
+        final cName = measureLanguage.t('measure', e.description ?? '');
+        return MeasureItemModel(
+          displayName: cName,
+          itemMeta: e,
+          category: e.categories?.first ?? '',
+          searchKey: "${e.name?.toLowerCase()}$cName",
+        );
+      }).toList();
+    } else {
+      return items.map((e) {
+        return MeasureItemModel(
+          displayName: e.name ?? '',
+          itemMeta: e,
+          category: e.categories?.first ?? '',
+          searchKey: "${e.name?.toLowerCase()}",
+        );
+      }).toList();
+    }
+  }
+
+  /// 测量项变化事件监听
+  /// 需要重新绑定子测量项
+  void _onActiveMeasureItemChanged(sender, IMeasureItem? e) {
+    if (e != null) {
+      final item = application.activeMeasureItem!;
+      if (item is ITopMeasureItem) {
+        topMeasureItem = item;
+        isCombo = true;
+        item.switchChild(0);
+        activeChildItemIndex = 0;
+        item.workingChildChanged.addListener(_onWorkingChildChanged);
+        childItemLabels = item.childItems.map((e) => (e.description)).toList();
+      } else {
+        isCombo = false;
+      }
+      if (mounted) {
+        setState(() {});
+      }
+    } else {
+      /// 如果为空测量项
+      isCombo = false;
+      activeChildItemIndex = 0;
+      showMore = false;
+      activeName = "";
+      if (mounted) {
+        setState(() {});
+      }
+    }
+  }
+
+  /// 子测量项变化事件监听
+  void _onWorkingChildChanged(sender, int e) {
+    setState(() {
+      activeChildItemIndex = e;
+    });
+  }
+
+  /// 打开更多测量项选择器
+  Future<void> _openMoreMeasureItemDialog() async {
+    List<MobileMoreMeasureItemModesModel> modes = [];
+    if (_isInitAllMeasureItems) {
+      modes = _availableModes;
+    } else {
+      modes = await _initMeasureItemsList();
+      _availableModes = modes;
+    }
+    final List<String> _currModes =
+        _findModesByCurrArea(application.currentVisualArea);
+
+    final List<MobileMoreMeasureItemModesModel> activeModes = modes
+        .where((element) => _currModes.contains(element.modeName))
+        .toList();
+
+    final MoreMeasureBackResult? result =
+        await Get.dialog<MoreMeasureBackResult>(MobileMoreMeasureItemDialog(
+      measureModeList: activeModes,
+      activeItemName: activeName,
+      initModeIndex: showMore ? moreMeasureBackResult?.currModeIndex : null,
+      initScrollOffset:
+          showMore ? moreMeasureBackResult?.currScrollOffset : null,
+    ));
+    if (result != null) {
+      moreMeasureBackResult = result;
+      bool success = changeItem(result.selectedMeasureItemMeta);
+      if (success) {
+        setState(() {
+          showMore = true;
+        });
+      } else {
+        PromptBox.toast(i18nBook.measure.temporarilyUnsupportedMeasurement.t);
+      }
+    }
+  }
+
+  void _visualAreaChanged(sender, IVisualArea e) {
+    _cancelCurrSelect();
+    _currentAreaType = e.visualAreaType;
+  }
 }

+ 147 - 147
lib/view/mobile_view/mobile_right_panel/mobile_more_measure_item_dialog.dart

@@ -9,23 +9,69 @@ import 'package:flutter/material.dart';
 import 'package:flutter/services.dart';
 import 'package:get/get.dart';
 
+class MeasureItemCategoryModel {
+  /// 类别名称
+  final String name;
+
+  /// 类别下的测量项
+  final List<MeasureItemModel> items;
+
+  MeasureItemCategoryModel({
+    required this.name,
+    required this.items,
+  });
+}
+
+class MeasureItemModel {
+  /// 外显名称(中文下只显示中文、英文下只显示英文)
+  final String displayName;
+
+  /// 测量项DTO
+  final ItemMetaDTO itemMeta;
+
+  /// 类别
+  final String category;
+
+  /// 搜索关键字
+  final String searchKey;
+
+  MeasureItemModel({
+    required this.displayName,
+    required this.itemMeta,
+    required this.category,
+    required this.searchKey,
+  });
+}
+
 class MobileMoreMeasureItemDialog extends FStatefulWidget {
+  final List<MobileMoreMeasureItemModesModel> measureModeList;
+  final String activeItemName;
+  final int? initModeIndex;
+  final double? initScrollOffset;
   const MobileMoreMeasureItemDialog(
       {super.key,
       required this.measureModeList,
       required this.activeItemName,
       this.initModeIndex,
       this.initScrollOffset});
-  final List<MobileMoreMeasureItemModesModel> measureModeList;
-  final String activeItemName;
-  final int? initModeIndex;
-  final double? initScrollOffset;
 
   @override
   FState<MobileMoreMeasureItemDialog> createState() =>
       _MobileMoreMeasureItemDialogState();
 }
 
+/// 更多测量项弹窗返回值
+class MoreMeasureBackResult {
+  final int currModeIndex;
+  final double currScrollOffset;
+  final ItemMeta selectedMeasureItemMeta;
+  MoreMeasureBackResult({
+    required this.currModeIndex,
+    required this.currScrollOffset,
+    required this.selectedMeasureItemMeta,
+  });
+}
+
 class _MobileMoreMeasureItemDialogState
     extends FState<MobileMoreMeasureItemDialog> {
   late final ScrollController scrollController;
@@ -46,6 +92,11 @@ class _MobileMoreMeasureItemDialogState
   /// 过滤后的展示结果
   List<MeasureItemModel> filteredItems = [];
 
+  @override
+  FWidget build(BuildContext context) {
+    return _buildMoreMeasureItemDialog();
+  }
+
   @override
   void initState() {
     super.initState();
@@ -67,41 +118,6 @@ class _MobileMoreMeasureItemDialogState
     );
   }
 
-  @override
-  FWidget build(BuildContext context) {
-    return _buildMoreMeasureItemDialog();
-  }
-
-  /// 构建更多测量项弹窗容器
-  FWidget _buildMoreMeasureItemDialog() {
-    return FDialog(
-      backgroundColor: const Color.fromARGB(255, 36, 36, 36),
-      shape: const RoundedRectangleBorder(
-        borderRadius: BorderRadius.all(
-          Radius.circular(7),
-        ),
-      ),
-      clipBehavior: Clip.hardEdge,
-      child: FColumn(
-        mainAxisSize: MainAxisSize.min,
-        children: [
-          _buildDialogTitle(),
-          FContainer(
-            color: const Color.fromARGB(255, 36, 36, 36),
-            width: Get.width,
-            height: Get.height * 0.6,
-            child: FContainer(
-              child: _buildMoreMeasureItemList(),
-            ),
-          ),
-          const FSizedBox(
-            height: 10,
-          )
-        ],
-      ),
-    );
-  }
-
   FWidget _buildDialogTitle() {
     return FPadding(
       padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 5),
@@ -133,61 +149,6 @@ class _MobileMoreMeasureItemDialogState
     );
   }
 
-  /// 构建更多测量项列表
-  FWidget _buildMoreMeasureItemList() {
-    if (currentModeMeasureItemList.isEmpty) {
-      return FContainer(
-        color: const Color.fromARGB(255, 36, 36, 36),
-        child: FCenter(
-          child: FText(
-            i18nBook.measure.unsupportedMeasurementMode.t,
-            style: const TextStyle(
-              color: Colors.grey,
-              fontSize: 16,
-            ),
-          ),
-        ),
-      );
-    }
-    if (filteredItems.isEmpty) {
-      return FContainer(
-        color: const Color.fromARGB(255, 36, 36, 36),
-        child: FCenter(
-          child: FText(
-            i18nBook.measure.noMatchingMeasurement.t,
-            style: const TextStyle(
-              color: Colors.grey,
-              fontSize: 16,
-            ),
-          ),
-        ),
-      );
-    }
-
-    final List<MeasureItemCategoryModel> categories =
-        _getClassifiedData(filteredItems);
-    return FContainer(
-      color: const Color.fromARGB(255, 36, 36, 36),
-      child: FScrollbar(
-        controller: scrollController,
-        isAlwaysShown: true,
-        child: FListView(
-          shrinkWrap: true,
-          controller: scrollController,
-          children: [
-            FColumn(
-              children: [
-                ...categories.map((e) {
-                  return _buildEachCategory(e);
-                }).toList(),
-              ],
-            )
-          ],
-        ),
-      ),
-    );
-  }
-
   /// 构建每个分类
   FWidget _buildEachCategory(MeasureItemCategoryModel category) {
     final List<MeasureItemModel> measureItemList = category.items;
@@ -319,6 +280,91 @@ class _MobileMoreMeasureItemDialogState
     );
   }
 
+  /// 构建更多测量项弹窗容器
+  FWidget _buildMoreMeasureItemDialog() {
+    return FDialog(
+      backgroundColor: const Color.fromARGB(255, 36, 36, 36),
+      shape: const RoundedRectangleBorder(
+        borderRadius: BorderRadius.all(
+          Radius.circular(7),
+        ),
+      ),
+      clipBehavior: Clip.hardEdge,
+      child: FColumn(
+        mainAxisSize: MainAxisSize.min,
+        children: [
+          _buildDialogTitle(),
+          FContainer(
+            color: const Color.fromARGB(255, 36, 36, 36),
+            width: Get.width,
+            height: Get.height * 0.6,
+            child: FContainer(
+              child: _buildMoreMeasureItemList(),
+            ),
+          ),
+          const FSizedBox(
+            height: 10,
+          )
+        ],
+      ),
+    );
+  }
+
+  /// 构建更多测量项列表
+  FWidget _buildMoreMeasureItemList() {
+    if (currentModeMeasureItemList.isEmpty) {
+      return FContainer(
+        color: const Color.fromARGB(255, 36, 36, 36),
+        child: FCenter(
+          child: FText(
+            i18nBook.measure.unsupportedMeasurementMode.t,
+            style: const TextStyle(
+              color: Colors.grey,
+              fontSize: 16,
+            ),
+          ),
+        ),
+      );
+    }
+    if (filteredItems.isEmpty) {
+      return FContainer(
+        color: const Color.fromARGB(255, 36, 36, 36),
+        child: FCenter(
+          child: FText(
+            i18nBook.measure.noMatchingMeasurement.t,
+            style: const TextStyle(
+              color: Colors.grey,
+              fontSize: 16,
+            ),
+          ),
+        ),
+      );
+    }
+
+    final List<MeasureItemCategoryModel> categories =
+        _getClassifiedData(filteredItems);
+    return FContainer(
+      color: const Color.fromARGB(255, 36, 36, 36),
+      child: FScrollbar(
+        controller: scrollController,
+        isAlwaysShown: true,
+        child: FListView(
+          shrinkWrap: true,
+          controller: scrollController,
+          children: [
+            FColumn(
+              children: [
+                ...categories.map((e) {
+                  return _buildEachCategory(e);
+                }).toList(),
+              ],
+            )
+          ],
+        ),
+      ),
+    );
+  }
+
   FWidget _buildSearchBar() {
     return FContainer(
       height: 40,
@@ -362,6 +408,13 @@ class _MobileMoreMeasureItemDialogState
     );
   }
 
+  void _changeCurrModeByIndex(int index) {
+    currentModeIndex = index;
+    currentModeMeasureItemList =
+        widget.measureModeList[currentModeIndex].availableItems;
+    _filterMeasureItems(searchWord);
+  }
+
   void _filterMeasureItems(String value) {
     searchWord = value;
     value = value.toLowerCase();
@@ -374,13 +427,6 @@ class _MobileMoreMeasureItemDialogState
     setState(() {});
   }
 
-  void _changeCurrModeByIndex(int index) {
-    currentModeIndex = index;
-    currentModeMeasureItemList =
-        widget.measureModeList[currentModeIndex].availableItems;
-    _filterMeasureItems(searchWord);
-  }
-
   List<MeasureItemCategoryModel> _getClassifiedData(
     List<MeasureItemModel> items,
   ) {
@@ -414,49 +460,3 @@ class _MobileMoreMeasureItemDialogState
     return classifiedData;
   }
 }
-
-class MeasureItemModel {
-  /// 外显名称(中文下只显示中文、英文下只显示英文)
-  final String displayName;
-
-  /// 测量项DTO
-  final ItemMetaDTO itemMeta;
-
-  /// 类别
-  final String category;
-
-  /// 搜索关键字
-  final String searchKey;
-
-  MeasureItemModel({
-    required this.displayName,
-    required this.itemMeta,
-    required this.category,
-    required this.searchKey,
-  });
-}
-
-class MeasureItemCategoryModel {
-  /// 类别名称
-  final String name;
-
-  /// 类别下的测量项
-  final List<MeasureItemModel> items;
-
-  MeasureItemCategoryModel({
-    required this.name,
-    required this.items,
-  });
-}
-
-/// 更多测量项弹窗返回值
-class MoreMeasureBackResult {
-  final int currModeIndex;
-  final double currScrollOffset;
-  final ItemMeta selectedMeasureItemMeta;
-  MoreMeasureBackResult({
-    required this.currModeIndex,
-    required this.currScrollOffset,
-    required this.selectedMeasureItemMeta,
-  });
-}