/*
 * @Author       : WuWei
 * @LastEditors: ChenYaJin
 * @Date         : 2022-07-12 11:36:28
 * @LastEditTime: 2022-10-19 11:30:20
 * @Description  : Do not edit
 */

import 'package:wisdom_cli/wisdom_cli.dart';

//  提报类型
class TypeListModel implements WPickerEntity {
  String? id;
  String? name;
  String? remark;
  String? createAt;
  String? createBy;
  String? updateAt;
  String? updateBy;
  String? type;
  num? preset;
  num? deleted;

  TypeListModel({
    this.id,
    this.name,
    this.remark,
    this.createAt,
    this.createBy,
    this.updateAt,
    this.updateBy,
    this.type,
    this.preset,
    this.deleted,
  });

  TypeListModel.fromJson(json) {
    Map<String, dynamic> map = Map.from(json ?? {});

    id = map['id'];
    name = map['name'];
    remark = map['remark'];
    createAt = map['createAt'];
    createBy = map['createBy'];
    updateAt = map['updateAt'];
    updateBy = map['updateBy'];
    type = map['type'];
    preset = map['preset'];
    deleted = map['deleted'];
  }

  Map<String, dynamic> toJson() {
    Map<String, dynamic> json = Map<String, dynamic>();

    json['id'] = this.id;
    json['name'] = this.name;
    json['remark'] = this.remark;
    json['createAt'] = this.createAt;
    json['createBy'] = this.createBy;
    json['updateAt'] = this.updateAt;
    json['updateBy'] = this.updateBy;
    json['type'] = this.type;
    json['preset'] = this.preset;
    json['deleted'] = this.deleted;

    return json;
  }

  @override
  String get selectName => name ?? '';

  @override
  get selectUnique => id ?? '';

  @override
  bool get selectDisabled => false;
}

//  提报类型分类树
class TypeTreeModel {
  String? id;
  String? label;
  String? parentId;
  List<TypeTreeModel>? children;

  TypeTreeModel({
    this.id,
    this.label,
    this.parentId,
    this.children,
  });

  TypeTreeModel.fromJson(json) {
    Map<String, dynamic> map = Map.from(json ?? {});

    id = map['id'];
    label = map['label'];
    parentId = map['parentId'];
    children = List<TypeTreeModel>.from(
        (map["children"] ?? []).map((x) => TypeTreeModel.fromJson(x)));
  }

  Map<String, dynamic> toJson() {
    Map<String, dynamic> json = Map<String, dynamic>();

    json['id'] = this.id;
    json['label'] = this.label;
    json['parentId'] = this.parentId;
    json['children'] =
        List<dynamic>.from((children ?? []).map((x) => x.toJson()));

    return json;
  }
}
