123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198 |
- import 'package:flutter/material.dart';
- import 'package:get/get.dart';
- import 'package:vitalapp/architecture/types/index.dart';
- import 'package:vitalapp/components/button.dart';
- import 'package:vitalapp/pages/check/models/form.dart';
- import 'package:vitalapp/pages/check/prescription/examination_prescription.dart';
- import 'package:vitalapp/pages/check/prescription/prescription_form_keys.dart';
- import 'package:vitalapp/pages/check/widgets/exam_configurable/exam_radio_and_select.dart';
- import 'package:vitalapp/pages/check/widgets/exam_title.dart';
- class ExamCheckBoxGuidance extends StatelessWidget {
- static final _borderRadius = BorderRadius.circular(16.0);
- ExamCheckBoxGuidance({
- super.key,
- required this.currentFormObject,
- required this.options,
- required this.selectCheckBoxChange,
- required this.currentSelectedCheckBox,
- required this.physicalExamNumber,
- required this.patientCode,
- required this.createPrescription,
- required this.prescriptionList,
- this.disbaleOthers = false,
- });
- final FormObject currentFormObject;
- final List<Option> options;
- final Function selectCheckBoxChange;
- final List<dynamic> currentSelectedCheckBox;
- final String? physicalExamNumber;
- final String? patientCode;
- final ValueCallback<Map> createPrescription;
- final List prescriptionList;
- /// 禁用其他选项(除已选)
- final bool disbaleOthers;
- @override
- Widget build(BuildContext context) {
- String label = currentFormObject.label ?? '';
- return ExamCardRadioSelect(
- titleText: ExamTitle(
- label: label,
- titleType: '(多选)',
- ),
- title: label,
- content: Container(
- padding: EdgeInsets.symmetric(vertical: 16).copyWith(top: 0),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.end,
- children: [
- Container(
- width: 130,
- height: 54,
- alignment: Alignment.centerRight,
- child: VButton(
- onTap: () async {
- var prescription = await Get.dialog(
- ExaminationPrescription(
- physicalExamNumber: physicalExamNumber,
- patientCode: patientCode,
- prescription: "",
- prescriptionTitle: "",
- ),
- );
- if (prescription != null) {
- createPrescription.call(prescription);
- }
- },
- label: '新增处方',
- ),
- ),
- Center(
- child: Wrap(
- children: options
- .map(
- (e) => _buildItem(context, e),
- )
- .toList(),
- ),
- ),
- if (prescriptionList.isNotEmpty)
- Wrap(
- children: [
- SizedBox(width: 30),
- Container(
- margin: EdgeInsets.only(bottom: 8, top: 8),
- child: Text(
- '处方列表',
- style: TextStyle(
- fontSize: 26,
- fontWeight: FontWeight.bold,
- ),
- ),
- ),
- SizedBox(width: 16),
- ...prescriptionList.map(
- (e) => InkWell(
- radius: 8,
- onTap: () async {
- var prescription = await Get.dialog(
- ExaminationPrescription(
- physicalExamNumber: physicalExamNumber,
- patientCode: patientCode,
- prescription: e['prescription'],
- prescriptionTitle:
- '${PrescriptionFormKeys.AllFormKeys[e['prescription']]}',
- isEdit: true,
- ),
- );
- if (prescription != null) {
- createPrescription.call(prescription);
- }
- },
- child: Container(
- decoration: BoxDecoration(
- border: Border.all(
- color: Colors.black26,
- ),
- borderRadius: _borderRadius,
- ),
- margin: EdgeInsets.all(8),
- padding: const EdgeInsets.all(8),
- child: Text(
- '${PrescriptionFormKeys.AllFormKeys[e['prescription']]}',
- style: TextStyle(
- fontSize: 20,
- fontWeight: FontWeight.bold,
- ),
- ),
- ),
- ),
- ),
- ],
- ),
- ],
- ),
- ),
- );
- }
- Widget _buildItem(BuildContext context, Option e) {
- Color bgColor;
- Color txtColor;
- Color borderColor;
- if (currentSelectedCheckBox.contains(e.value)) {
- // 已选中
- final primaryColor = Theme.of(context).primaryColor;
- bgColor = primaryColor;
- txtColor = Colors.white;
- borderColor = primaryColor;
- } else {
- // 非选中的
- if (disbaleOthers) {
- // 含有独占选项时
- bgColor = Colors.grey.shade400;
- txtColor = Colors.white;
- borderColor = Colors.grey.shade400;
- } else {
- // 不含有独占选项时
- bgColor = Colors.transparent;
- txtColor = Colors.black54;
- borderColor = Colors.black26;
- }
- }
- return Container(
- padding: const EdgeInsets.all(8),
- child: InkWell(
- onTap: () => selectCheckBoxChange(e),
- borderRadius: _borderRadius,
- child: Ink(
- decoration: BoxDecoration(
- border: Border.all(
- color: borderColor,
- ),
- borderRadius: _borderRadius,
- color: bgColor,
- ),
- child: Container(
- padding: const EdgeInsets.all(15),
- alignment: Alignment.center,
- width: 250,
- child: FittedBox(
- child: Text(
- e.label ?? '',
- style: TextStyle(
- fontSize: 20,
- color: txtColor,
- ),
- ),
- ),
- ),
- ),
- ),
- );
- }
- }
|