123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150 |
- import 'package:flutter/material.dart';
- import 'package:vitalapp/components/dialog_input.dart';
- import 'package:vitalapp/pages/check/widgets/exam_configurable/exam_card.dart';
- /// 尿常规
- class ExamUrinalysis extends StatefulWidget {
- const ExamUrinalysis({
- super.key,
- required this.currentValue,
- required this.urinalysis,
- });
- final Map currentValue;
- final Function(Map) urinalysis;
- @override
- State<ExamUrinalysis> createState() => _ExamUrinalysisState();
- }
- class _ExamUrinalysisState extends State<ExamUrinalysis> {
- List<Map<String, String>> urinalysis = [
- {"name": '尿白细胞', "key": 'LEU'},
- {"name": '红细胞/潜血', "key": 'BLD'},
- {"name": '尿亚硝酸盐', "key": 'NIT'},
- {"name": '酮体', "key": 'KET'},
- {"name": '尿胆原', "key": 'UBG'},
- {"name": '胆红素', "key": 'BIL'},
- {"name": '尿蛋白', "key": 'PRO'},
- {"name": '葡萄糖', "key": 'GLU'},
- {"name": '酸碱度', "key": 'PH'},
- {"name": '尿比重', "key": 'SG'},
- {"name": '维生素C', "key": 'VC'},
- ];
- Map _value = {};
- @override
- void initState() {
- initData();
- super.initState();
- }
- @override
- void didUpdateWidget(ExamUrinalysis oldWidget) {
- initData();
- super.didUpdateWidget(oldWidget);
- }
- void initData() {
- _value = widget.currentValue;
- setState(() {});
- }
- @override
- void dispose() {
- super.dispose();
- }
- @override
- Widget build(BuildContext context) {
- return Stack(
- children: [
- _buildUrinalysis(),
- ],
- );
- }
- Widget _buildUrinalysis() {
- return ExamCard(
- title: '尿常规',
- // clickCard: () {
- // _input();
- // },
- content: Container(
- width: double.infinity,
- alignment: Alignment.center,
- padding: const EdgeInsets.only(
- bottom: 20,
- right: 30,
- left: 40,
- ),
- // constraints: const BoxConstraints(minHeight: 50),
- child: GridView.count(
- shrinkWrap: true,
- childAspectRatio: 12,
- crossAxisCount: 2, // 列数为2,即两列布局
- children: urinalysis.map((item) {
- return _buildUrineItem(item);
- }).toList(),
- ),
- ),
- );
- }
- Widget _buildUrineItem(Map<String, String> urine) {
- return InkWell(
- onTap: () {
- _input(urine['name']!, urine['key']!);
- },
- child: Container(
- child: Row(
- mainAxisAlignment: MainAxisAlignment.start,
- crossAxisAlignment: CrossAxisAlignment.center,
- children: [
- Container(
- alignment: Alignment.center,
- width: 180,
- child: Row(
- children: [
- Text(
- urine['key']!,
- style: const TextStyle(
- fontSize: 22,
- color: Colors.black,
- ),
- ),
- Text(
- '(${urine['name']!})',
- // text: _value.isEmpty ? '--' : _value,
- textAlign: TextAlign.center,
- style: const TextStyle(
- fontSize: 22,
- ),
- ),
- ],
- ),
- ),
- Text(
- _value[urine['key']!] ?? '',
- // text: _value.isEmpty ? '--' : _value,
- style: const TextStyle(
- fontSize: 26,
- ),
- )
- ],
- ),
- ),
- );
- }
- Future<void> _input(String name, String key) async {
- String? result = await VDialogInput(
- title: name,
- initialValue: _value[key],
- ).show();
- if (result?.isNotEmpty ?? false) {
- _value[key] = result ?? '';
- }
- widget.urinalysis(_value);
- setState(() {});
- }
- }
|