123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- import 'package:vid/us/vid_us_unit.dart';
- /// 测量项配置元信息
- class ItemMeta {
- /// 名称
- String name;
- /// 描述
- String description;
- /// 简介注释
- String briefAnnotation;
- /// 测量类型
- String measureType;
- /// 计算输出元信息
- List<ItemOutputMeta> outputs;
- /// 子项元信息集合
- List<ItemMeta> childItems;
- /// 多测量方法
- List<ItemMeta> multiMethodItems;
- /// 当前测量项的购买状态
- /// 0: Free 免费
- /// 1: Probation 试用中
- /// 2: Unpaid 未购买
- /// 3: Purchased 已购买
- /// /// 【TODO】 暂时屏蔽 buyStatus
- // WorkingItemStatusEnum? buyStatus;
- int? rimWidth;
- ItemMeta(
- this.name, {
- required this.measureType,
- required this.description,
- required this.outputs,
- // this.buyStatus,
- this.rimWidth,
- this.briefAnnotation = '',
- this.childItems = const [],
- this.multiMethodItems = const [],
- });
- /// 根据名称获取子项
- ItemMeta? getChildByName(String name) {
- final matchList = childItems.where((e) => e.name == name);
- if (matchList.isNotEmpty) {
- return matchList.first;
- }
- return null;
- }
- /// 根据类型获取子项
- ItemMeta? getChildByType(String type) {
- final matchList = childItems.where((e) => e.measureType == type);
- if (matchList.isNotEmpty) {
- return matchList.first;
- }
- return null;
- }
- }
- class ItemOutputMeta {
- /// 名称
- String name;
- /// 描述
- String description;
- /// 单位
- VidUsUnit unit;
- /// 简介注释
- String? briefAnnotation;
- /// 额外注释
- String? additionalAnnotation;
- /// 小数精度
- int fractionalDigits;
- ItemOutputMeta(
- this.name,
- this.description,
- this.unit, {
- this.briefAnnotation,
- this.additionalAnnotation,
- this.fractionalDigits = 2,
- });
- ItemOutputMeta copyWith({
- String? name,
- String? description,
- VidUsUnit? unit,
- String? briefAnnotation,
- String? additionalAnnotation,
- int? fractionalDigits,
- }) {
- final meta = ItemOutputMeta(
- name ?? this.name,
- description ?? this.description,
- unit ?? this.unit,
- additionalAnnotation: additionalAnnotation ?? this.additionalAnnotation,
- fractionalDigits: fractionalDigits ?? this.fractionalDigits,
- );
- return meta;
- }
- }
|