Browse Source

词条页面显示优化

loki.wu 9 months ago
parent
commit
6efb0fe937

+ 11 - 3
lib/pages/vocabulary_entry/controller.dart

@@ -69,6 +69,7 @@ class VocabularyEntryController extends FControllerBase {
 
   /// 词条分类的选中
   void onNodeTap(String code) {
+    print("selectedKey 0:" + code);
     state.selectedKey = code;
     if (code.isEmpty) {
       state.vocabularyCard = [];
@@ -77,6 +78,7 @@ class VocabularyEntryController extends FControllerBase {
     state.vocabularyCard = state.allThesaurusItem
         .where((element) => element.parentItemCode == code)
         .toList();
+    update(['tree_view']);
   }
 
   /// 数据处理
@@ -122,6 +124,13 @@ class VocabularyEntryController extends FControllerBase {
         ),
       );
     }
+    if (treeView.isNotEmpty) {
+      if (treeView.first.children.isNotEmpty) {
+        var firstNodeKey = treeView.first.children.first.key;
+        print("selectedKey 1:" + firstNodeKey);
+        onNodeTap(firstNodeKey);
+      }
+    }
     return treeView;
   }
 
@@ -268,8 +277,6 @@ class VocabularyEntryController extends FControllerBase {
         thesaurusDTO.thesaurusType == ThesaurusTypeEnum.Personal;
 
     await getThesaurusItemsAsync();
-    state.selectedKey = "";
-    state.vocabularyCard = [];
   }
 
   /// 点击词条卡片 拉取所有的词条库
@@ -406,7 +413,8 @@ class VocabularyEntryController extends FControllerBase {
       state.activeEntryIndex = 0;
       state.thesaurusCode = state.entryInfos[0].thesaurusCode!;
       state.thesaurusName = state.entryInfos[0].thesaurusName!;
-      state.isEnableEdit = true;
+      state.isEnableEdit =
+          state.entryInfos.first.thesaurusType == ThesaurusTypeEnum.Personal;
     }
     onLoaded.emit(this, '');
     getThesaurusItemsAsync();

+ 2 - 1
lib/pages/vocabulary_entry/view.dart

@@ -1,6 +1,7 @@
 import 'package:fis_i18n/i18n.dart';
 import 'package:fis_ui/base_define/page.dart';
 import 'package:fis_ui/index.dart';
+import 'package:flutter/foundation.dart';
 import 'package:flutter/material.dart';
 import 'package:fis_ui/widgets/tree/flutter_treeview/lib/flutter_treeview.dart';
 import 'package:get/get.dart' hide Node;
@@ -62,7 +63,7 @@ class _EntryTreeViewState extends State<EntryTreeView> {
         child: Column(
           mainAxisAlignment: MainAxisAlignment.center,
           children: [
-            hovering
+            (!kIsWeb || hovering)
                 ? Container(
                     child: Row(
                       mainAxisAlignment: MainAxisAlignment.spaceBetween,

+ 27 - 22
lib/pages/vocabulary_entry/widgets/entries_class_ification_body.dart

@@ -125,29 +125,34 @@ class _Entries extends GetView<VocabularyEntryController> {
         ),
         child: controller.state.getTreeView.isEmpty
             ? VNoDataView()
-            : TreeView(
-                theme: TreeViewTheme(
-                  colorScheme: ColorScheme.dark(
-                    primary: Theme.of(Get.context!).primaryColor,
-                  ),
-                ),
-                onNodeTap: (code) {
-                  controller.onNodeTap(code);
-                },
-                onExpansionChanged: (code, isDrop) {
-                  controller.onExpansionChanged(
-                    code,
-                    isDrop,
+            : GetBuilder(
+                init: VocabularyEntryController(),
+                id: "tree_view",
+                builder: (_) {
+                  return TreeView(
+                    theme: TreeViewTheme(
+                      colorScheme: ColorScheme.dark(
+                        primary: Theme.of(Get.context!).primaryColor,
+                      ),
+                    ),
+                    onNodeTap: (code) {
+                      controller.onNodeTap(code);
+                    },
+                    onExpansionChanged: (code, isDrop) {
+                      controller.onExpansionChanged(
+                        code,
+                        isDrop,
+                      );
+                    },
+                    controller: TreeViewController(
+                      children: controller.state.getTreeView,
+                      selectedKey: controller.state.selectedKey,
+                    ),
+                    nodeBuilder: (buildContext, node) {
+                      return EntryTreeView(node: node);
+                    },
                   );
-                },
-                controller: TreeViewController(
-                  children: controller.state.getTreeView,
-                  selectedKey: controller.state.selectedKey,
-                ),
-                nodeBuilder: (buildContext, node) {
-                  return EntryTreeView(node: node);
-                },
-              ),
+                }),
       );
     });
   }

+ 97 - 97
lib/pages/vocabulary_entry/widgets/entry_classification_dialog.dart

@@ -46,12 +46,9 @@ class _EntryClassifcationDialogState extends State<EntryClassifcationDialog> {
       insetPadding: EdgeInsets.symmetric(vertical: 100),
       children: [
         Container(
+          color: Colors.white,
           width: 580,
           height: 250,
-          padding: EdgeInsets.only(
-            left: 25,
-            right: 25,
-          ),
           child: _EntryClassifcation(
             thesaurusInfoKey: widget.thesaurusInfoKey,
           ),
@@ -64,109 +61,112 @@ class _EntryClassifcationDialogState extends State<EntryClassifcationDialog> {
 ///词条分类词典对话框框内容页
 class _EntryClassifcation extends GetView<VocabularyEntryController> {
   _EntryClassifcation({this.thesaurusInfoKey});
-  String? thesaurusInfoKey;
+  final String? thesaurusInfoKey;
 
   @override
   Widget build(BuildContext context) {
-    return Column(
-      crossAxisAlignment: CrossAxisAlignment.center,
-      mainAxisAlignment: MainAxisAlignment.center,
-      children: [
-        _EntryClassifcationItem(
-          isRequire: true,
-          inputWidget: FRow(
-            children: [
-              FExpanded(
-                child: FContainer(
-                  height: 45,
-                  // color: Colors.red,
-                  child: FRow(
-                    crossAxisAlignment: CrossAxisAlignment.center,
-                    children: [
-                      FSizedBox(
-                        width: 25,
-                      ),
-                      FBorderInput(
-                        hintSize: 16,
-                        contentSize: 16,
-                        maxLength: 40,
-                        borderColor: Color(0xffdcdfe6),
-                        height: 40,
-                        hintText: i18nBook.remedical.inputCatName.t,
-                        controller: TextEditingController(
-                          text: controller
-                              .state.createClassification['thesaurusItemName'],
+    return Container(
+      child: Column(
+        crossAxisAlignment: CrossAxisAlignment.center,
+        mainAxisAlignment: MainAxisAlignment.center,
+        children: [
+          _EntryClassifcationItem(
+            isRequire: true,
+            inputWidget: FRow(
+              children: [
+                FExpanded(
+                  child: FContainer(
+                    height: 45,
+                    // color: Colors.red,
+                    child: FRow(
+                      crossAxisAlignment: CrossAxisAlignment.center,
+                      children: [
+                        FSizedBox(
+                          width: 25,
                         ),
-                        onChanged: (value) {
-                          controller.state
-                                  .createClassification['thesaurusItemName'] =
-                              value.toString().trim();
-                        },
-                      ),
-                      FSizedBox(
-                        width: 10,
-                      ),
-                    ],
-                  ),
-                ),
-              ),
-            ],
-          ),
-          title: i18nBook.remedical.categoryName.t,
-        ),
-        FSizedBox(
-          height: 20,
-        ),
-        _EntryClassifcationItem(
-          inputWidget: FRow(
-            children: [
-              FExpanded(
-                child: FContainer(
-                  height: 45,
-                  // color: Colors.red,
-                  child: FRow(
-                    crossAxisAlignment: CrossAxisAlignment.center,
-                    children: [
-                      FSizedBox(
-                        width: 25,
-                      ),
-                      FExpanded(
-                        child: FSelect<OrgModel, String>(
-                          source: thesaurusInfoKey != null
-                              ? controller.state.editClassification
-                              : controller.state.classification,
-                          hintText: i18nBook.remedical.selectUpperCat.t,
-                          value: controller
-                                  .state.createClassification['parentItemCode']
-                                  .toString()
-                                  .isEmpty
-                              ? null
-                              : controller
-                                  .state.createClassification['parentItemCode'],
-                          textColor: Colors.black,
-                          clearable: true,
-                          // isExpanded: true,
-                          height: 36,
-                          optionLabelExtractor: (data) => data.name,
-                          optionValueExtractor: (data) => data.code,
-                          onSelectChanged: (value, index) {
+                        FBorderInput(
+                          hintSize: 16,
+                          contentSize: 16,
+                          maxLength: 40,
+                          borderColor: Color(0xffdcdfe6),
+                          height: 40,
+                          hintText: i18nBook.remedical.inputCatName.t,
+                          controller: TextEditingController(
+                            text: controller.state
+                                .createClassification['thesaurusItemName'],
+                          ),
+                          onChanged: (value) {
                             controller.state
-                                .createClassification['parentItemCode'] = value;
+                                    .createClassification['thesaurusItemName'] =
+                                value.toString().trim();
                           },
                         ),
-                      ),
-                      FSizedBox(
-                        width: 10,
-                      ),
-                    ],
+                        FSizedBox(
+                          width: 10,
+                        ),
+                      ],
+                    ),
                   ),
                 ),
-              ),
-            ],
+              ],
+            ),
+            title: i18nBook.remedical.categoryName.t,
           ),
-          title: i18nBook.remedical.parentClass.t,
-        )
-      ],
+          FSizedBox(
+            height: 20,
+          ),
+          _EntryClassifcationItem(
+            inputWidget: FRow(
+              children: [
+                FExpanded(
+                  child: FContainer(
+                    height: 45,
+                    // color: Colors.red,
+                    child: FRow(
+                      crossAxisAlignment: CrossAxisAlignment.center,
+                      children: [
+                        FSizedBox(
+                          width: 25,
+                        ),
+                        FExpanded(
+                          child: FSelect<OrgModel, String>(
+                            source: thesaurusInfoKey != null
+                                ? controller.state.editClassification
+                                : controller.state.classification,
+                            hintText: i18nBook.remedical.selectUpperCat.t,
+                            value: controller.state
+                                    .createClassification['parentItemCode']
+                                    .toString()
+                                    .isEmpty
+                                ? null
+                                : controller.state
+                                    .createClassification['parentItemCode'],
+                            textColor: Colors.black,
+                            clearable: true,
+                            // isExpanded: true,
+                            height: 36,
+                            optionLabelExtractor: (data) => data.name,
+                            optionValueExtractor: (data) => data.code,
+                            onSelectChanged: (value, index) {
+                              controller.state
+                                      .createClassification['parentItemCode'] =
+                                  value;
+                            },
+                          ),
+                        ),
+                        FSizedBox(
+                          width: 10,
+                        ),
+                      ],
+                    ),
+                  ),
+                ),
+              ],
+            ),
+            title: i18nBook.remedical.parentClass.t,
+          )
+        ],
+      ),
     );
   }
 }