form_info.dart 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. import 'package:fis_common/event/event_type.dart';
  2. class FormInfo {
  3. static FormInfo? _reportInfo;
  4. ///需要提交到Server的表单值
  5. Map<String, dynamic> _formValue = {};
  6. FormInfo._internal();
  7. ///ReportInfo全局单例
  8. static FormInfo get instance {
  9. _reportInfo ??= FormInfo._internal();
  10. return _reportInfo!;
  11. }
  12. ///需要联动的值改变事件
  13. FEventHandler<UpdateFormArgs> onValueChange = FEventHandler<UpdateFormArgs>();
  14. ///改变目标的值
  15. FEventHandler<TargetFormArgs> onChangeTargetValue =
  16. FEventHandler<TargetFormArgs>();
  17. Map<String, dynamic> get formValue => _formValue;
  18. set formValue(Map<String, dynamic> newValue) {
  19. _formValue = newValue;
  20. }
  21. }
  22. class UpdateFormArgs {
  23. final String sourceKey;
  24. final UpdateFormType type;
  25. final dynamic sourceValue;
  26. UpdateFormArgs({
  27. required this.sourceKey,
  28. required this.sourceValue,
  29. this.type = UpdateFormType.UpdateValue,
  30. });
  31. }
  32. class TargetFormArgs {
  33. final String targetKey;
  34. final String targetValue;
  35. ///是否禁用组件
  36. final bool isDisabledValue;
  37. ///是否隐藏组件(不显示)
  38. final bool isHidden;
  39. TargetFormArgs(
  40. this.targetKey, {
  41. this.targetValue = "",
  42. this.isDisabledValue = false,
  43. this.isHidden = false,
  44. });
  45. }
  46. enum UpdateFormType {
  47. Add,
  48. UpdateValue,
  49. Remove,
  50. }