measure_search_input.dart 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. import 'package:fis_i18n/i18n.dart';
  2. import 'package:fis_jsonrpc/rpc.dart';
  3. import 'package:fis_measure/interfaces/enums/operate.dart';
  4. import 'package:fis_measure/interfaces/process/workspace/application.dart';
  5. import 'package:fis_measure/process/workspace/measure_data_controller.dart';
  6. import 'package:fis_measure/process/workspace/measure_handler.dart';
  7. import 'package:fis_measure/utils/prompt_box.dart';
  8. import 'package:fis_measure/view/measure/operate_type_change_button.dart';
  9. import 'package:fis_measure/view/measure/measure_panel_head.dart';
  10. import 'package:fis_measure/view/menu_button_group/menu_button_group.dart';
  11. import 'package:fis_ui/base_define/page.dart';
  12. import 'package:fis_ui/index.dart';
  13. import 'package:fis_ui/interface/interactive_container.dart';
  14. import 'package:fis_ui/widgets/functional/text_tooltip.dart';
  15. import 'package:flutter/material.dart';
  16. import 'package:get/get.dart';
  17. class LeftSelectInput extends FStatefulWidget implements FInteractiveContainer {
  18. @override
  19. final String pageName = 'LeftSelectInput';
  20. const LeftSelectInput({super.key});
  21. @override
  22. FState<LeftSelectInput> createState() => _LeftSelectInputState();
  23. }
  24. class _LeftSelectInputState extends FState<LeftSelectInput> {
  25. late final application = Get.find<IApplication>();
  26. /// 数据
  27. late final measureData = Get.find<MeasureDataController>();
  28. late final measureHandler = Get.find<MeasureHandler>();
  29. String annotationItem = '';
  30. /// 添加操作后更新注释
  31. void getAnnotationList() async {
  32. List<String> annotationList = [];
  33. var measureCommentItemResult =
  34. await measureData.getCommentsByApplicationAsync(
  35. application.applicationName,
  36. application.categoryName,
  37. );
  38. measureData.measureCommentItemResult =
  39. measureCommentItemResult?.commentItems ?? [];
  40. measureCommentItemResult?.commentItems?.forEach((element) {
  41. annotationList.add(element.text ?? '');
  42. });
  43. measureData.annotationList = annotationList;
  44. }
  45. /// 添加操作后更新注释
  46. void resetUserCommentsAsync() async {
  47. var resetUserCommentsResult = await measureData.resetUserCommentsAsync(
  48. application.applicationName,
  49. application.categoryName,
  50. );
  51. if (resetUserCommentsResult ?? false) {
  52. PromptBox.toast(i18nBook.auth.toast4ResetSuccess.t);
  53. getAnnotationList();
  54. }
  55. }
  56. @override
  57. FWidget build(BuildContext context) {
  58. return FContainer(
  59. padding: const EdgeInsets.only(
  60. left: 15,
  61. right: 15,
  62. bottom: 5,
  63. ),
  64. child: FRow(
  65. crossAxisAlignment: CrossAxisAlignment.center,
  66. children: [
  67. FBorderInput(
  68. height: 38,
  69. hintSize: 16,
  70. contentSize: 16,
  71. maxLength: 20,
  72. fillColor: Colors.white,
  73. borderColor: const Color.fromARGB(255, 187, 180, 180),
  74. suffixIcon: FMaterial(
  75. color: Colors.transparent,
  76. child: FIconButton(
  77. name: "pleaseAddCcomment",
  78. onPressed: () async {
  79. //判断添加的注释不为空
  80. if (annotationItem.isEmpty ||
  81. annotationItem.replaceAll(" ", "").isEmpty) {
  82. PromptBox.toast(i18nBook.measure.annotationCannotBeEmpty.t);
  83. } else {
  84. var result = await measureData.addAnnotation(
  85. application,
  86. annotationItem,
  87. );
  88. if (result ?? false) {
  89. measureHandler.currOperateType =
  90. MeasureOperateType.measure;
  91. measureHandler.currOperateType =
  92. MeasureOperateType.annotation;
  93. getAnnotationList();
  94. }
  95. }
  96. },
  97. icon: const FIcon(
  98. Icons.add,
  99. ),
  100. businessParent: widget,
  101. ),
  102. ),
  103. hintText: i18nBook.measure.AddCcomment.t,
  104. onChanged: (value) {
  105. annotationItem = value;
  106. },
  107. ),
  108. const FSizedBox(width: 5),
  109. FTextTooltip(
  110. position: DisplayPosition.left,
  111. textStyle: const TextStyle(fontSize: 14, color: Colors.white),
  112. height: 32,
  113. message: i18nBook.measure.resetToDefaultAnnotation.t,
  114. margin: const EdgeInsets.only(right: 10),
  115. decoration: BoxDecoration(
  116. color: const Color.fromARGB(255, 238, 105, 95),
  117. borderRadius: BorderRadius.circular(4),
  118. ),
  119. child: FSizedBox(
  120. width: 40,
  121. height: 40,
  122. child: FElevatedButton(
  123. style: ButtonStyle(
  124. padding: const MaterialStatePropertyAll(EdgeInsets.all(0)),
  125. backgroundColor: MaterialStateProperty.all(Colors.grey),
  126. ),
  127. child: const FIcon(Icons.restart_alt),
  128. onPressed: resetUserCommentsAsync,
  129. businessParent: widget,
  130. name: "resetUserCommentsAsync"),
  131. ),
  132. ),
  133. ],
  134. ),
  135. );
  136. }
  137. }