12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- import 'form_info.dart';
- import 'package:fis_common/index.dart';
- abstract class BaseFormValueChange {
- void onHeightOrWeightChange(UpdateFormArgs e) {
- UpdateFormType type = e.type;
- String height = FormInfo.instance.formValue["Height"] ?? '';
- String weight = FormInfo.instance.formValue["Weight"] ?? '';
- if (height.isNotNullOrEmpty && weight.isNotNullOrEmpty) {
- var doubleHeight = double.parse(height) / 100;
- var doubleWeight = double.parse(weight);
- var bmi =
- (doubleWeight / (doubleHeight * doubleHeight)).toStringAsFixed(2);
- FormInfo.instance.formValue["Bmi"] = bmi;
- FormInfo.instance.onChangeTargetValue.emit(
- this,
- TargetFormArgs(
- "Bmi",
- targetValue: bmi,
- ),
- );
- } else {
- if (FormInfo.instance.formValue.containsKey("Bmi")) {
- FormInfo.instance.formValue.remove("Bmi");
- }
- return;
- }
- }
- ///转诊
- void onReferralChange(UpdateFormArgs e) {
- UpdateFormType type = e.type;
- bool isDisabledValue = false;
- if ((type == UpdateFormType.Add && e.sourceValue == "referral_1")) {
- ///选中了无,则禁用其他选项
- isDisabledValue = true;
- } else if ((type == UpdateFormType.Remove &&
- e.sourceValue == "referral_1") ||
- (type == UpdateFormType.Add && e.sourceValue == "referral_2")) {
- ///取消选中无或选中有,则取消禁用其他选项
- isDisabledValue = false;
- }
- FormInfo.instance.onChangeTargetValue.emit(
- this,
- TargetFormArgs(
- "Reason_For_Referral",
- isDisabledValue: isDisabledValue,
- ),
- );
- FormInfo.instance.onChangeTargetValue.emit(
- this,
- TargetFormArgs(
- "Institution_And_Department",
- isDisabledValue: isDisabledValue,
- ),
- );
- if (e.sourceValue == "referral_1") {
- FormInfo.instance.onChangeTargetValue.emit(
- this,
- TargetFormArgs(
- "referral_2",
- isDisabledValue: false,
- targetValue: "cancelSelection",
- ),
- );
- } else if (e.sourceValue == "referral_2") {
- FormInfo.instance.onChangeTargetValue.emit(
- this,
- TargetFormArgs(
- "referral_1",
- isDisabledValue: false,
- targetValue: "cancelSelection",
- ),
- );
- }
- }
- void onValueChange(UpdateFormArgs e, String sourceValue, String targetKey) {
- UpdateFormType type = e.type;
- bool isDisabledValue = false;
- if (type == UpdateFormType.Add && e.sourceValue == sourceValue) {
- ///选中了无,则禁用其他选项
- isDisabledValue = true;
- } else if (type == UpdateFormType.Remove && e.sourceValue == sourceValue) {
- ///取消选中无,则取消禁用其他选项
- isDisabledValue = false;
- }
- FormInfo.instance.onChangeTargetValue.emit(
- this,
- TargetFormArgs(
- targetKey,
- isDisabledValue: isDisabledValue,
- ),
- );
- }
- }
|