measure_search_input.dart 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. import 'package:fis_jsonrpc/rpc.dart';
  2. import 'package:fis_measure/interfaces/process/workspace/application.dart';
  3. import 'package:fis_measure/process/workspace/measure_data_controller.dart';
  4. import 'package:fis_measure/process/workspace/measure_handler.dart';
  5. import 'package:fis_measure/utils/prompt_box.dart';
  6. import 'package:fis_measure/view/measure/tool_chest_title.dart';
  7. import 'package:fis_ui/index.dart';
  8. import 'package:flutter/material.dart';
  9. import 'package:get/get.dart';
  10. class LeftSelectInput extends FStatefulWidget {
  11. @override
  12. FState<LeftSelectInput> createState() => _LeftSelectInputState();
  13. }
  14. class _LeftSelectInputState extends FState<LeftSelectInput> {
  15. late final application = Get.find<IApplication>();
  16. /// 数据
  17. late final measureData = Get.find<MeasureDataController>();
  18. late final measureHandler = Get.find<MeasureHandler>();
  19. String commentItem = '';
  20. /// 注释获取
  21. void getNoteCommentsList() async {
  22. List<String> commentsList = [];
  23. var measureCommentItemResult =
  24. await measureData.getCommentsByApplicationAsync(
  25. application.applicationName,
  26. application.categoryName,
  27. );
  28. measureData.measureCommentItemResult =
  29. measureCommentItemResult?.commentItems ?? [];
  30. measureCommentItemResult?.commentItems?.forEach((element) {
  31. commentsList.add(element.text ?? '');
  32. });
  33. measureData.getCommentsList = commentsList;
  34. }
  35. @override
  36. FWidget build(BuildContext context) {
  37. return FContainer(
  38. padding: const EdgeInsets.only(
  39. left: 15,
  40. right: 15,
  41. bottom: 5,
  42. ),
  43. child: FRow(
  44. crossAxisAlignment: CrossAxisAlignment.center,
  45. children: [
  46. FBorderInput(
  47. height: 38,
  48. hintSize: 16,
  49. contentSize: 16,
  50. maxLength: 20,
  51. fillColor: Colors.white,
  52. borderColor: const Color.fromARGB(255, 187, 180, 180),
  53. suffixIcon: FMaterial(
  54. color: Colors.transparent,
  55. child: FIconButton(
  56. onPressed: () async {
  57. /// TODO 翻译
  58. List<CommentItemDTO> measureCommentItemList =
  59. measureData.measureCommentItemResult;
  60. if (commentItem.isEmpty) {
  61. PromptBox.toast("请添加新注释");
  62. } else {
  63. measureCommentItemList.add(
  64. CommentItemDTO(text: commentItem),
  65. );
  66. var result = await measureData.saveUserDefinedCommentsAsync(
  67. application.applicationName,
  68. application.categoryName,
  69. measureCommentItemList,
  70. );
  71. if (result ?? false) {
  72. measureHandler.changedTab = TagEnum.MeasureTool;
  73. measureHandler.changedTab = TagEnum.NodesTool;
  74. getNoteCommentsList();
  75. } else {
  76. PromptBox.toast("添加注释失败");
  77. }
  78. }
  79. },
  80. icon: const FIcon(
  81. Icons.add,
  82. ),
  83. ),
  84. ),
  85. /// TODO 翻译
  86. hintText: "请添加新注释",
  87. onChanged: (value) {
  88. commentItem = value;
  89. },
  90. ),
  91. ],
  92. ),
  93. );
  94. }
  95. }