measure_search_input.dart 5.4 KB

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