biochemistry_test.dart 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. import 'dart:math';
  2. import 'package:flutter/material.dart';
  3. import 'package:get/get.dart';
  4. import 'package:vitalapp/pages/medical/controller.dart';
  5. import 'package:vitalapp/pages/medical/views/table_input_dialog/index.dart';
  6. import 'table_input_dialog/mock_data.dart';
  7. class BiochemistryTest extends GetView<MedicalController> {
  8. const BiochemistryTest({super.key});
  9. @override
  10. Widget build(BuildContext context) {
  11. return Scaffold(
  12. resizeToAvoidBottomInset: false,
  13. body: Container(
  14. height: double.maxFinite,
  15. color: Colors.white,
  16. child: Center(
  17. // FIXME 示例代码
  18. child: Column(
  19. mainAxisSize: MainAxisSize.min,
  20. children: [
  21. ElevatedButton(
  22. onPressed: () async {
  23. TableInputResult? result = await Get.dialog<TableInputResult>(
  24. TableInputDialog(
  25. tableDataConfig: MockData.mockBiochemistryTestData,
  26. title: '检验科-生化数据',
  27. ),
  28. );
  29. // 如果不为空,print出来
  30. if (result != null) {
  31. result.data.forEach((key, value) {
  32. print('$key: $value');
  33. });
  34. } else {
  35. print('已取消,无返回值');
  36. }
  37. },
  38. child: const Text('填写生化数据'),
  39. ),
  40. SizedBox(height: 20),
  41. ElevatedButton(
  42. onPressed: () async {
  43. List<TableElementConfig> tableDataConfig = [];
  44. MockData.mockBiochemistryTestData.forEach((element) {
  45. tableDataConfig.add(
  46. TableElementConfig(
  47. id: element.id,
  48. unit: element.unit,
  49. name: element.name,
  50. initValue: Random().nextDouble().toStringAsFixed(2),
  51. ),
  52. );
  53. });
  54. TableInputResult? result = await Get.dialog<TableInputResult>(
  55. TableInputDialog(
  56. tableDataConfig: tableDataConfig,
  57. title: '检验科-生化数据',
  58. ),
  59. );
  60. // 如果不为空,print出来
  61. if (result != null) {
  62. result.data.forEach((key, value) {
  63. print('$key: $value');
  64. });
  65. } else {
  66. print('已取消,无返回值');
  67. }
  68. },
  69. child: const Text('修改已有生化数据'),
  70. ),
  71. ],
  72. ),
  73. ),
  74. ),
  75. );
  76. }
  77. }