/// 报告编辑器设置
class ReportEditorSetting {
  ReportEditorSetting._internal();

  static ReportEditorSetting? _instance;

  /// 获取单例
  static ReportEditorSetting get ins {
    if (_instance == null) {
      _instance = ReportEditorSetting._internal();
    }
    return _instance!;
  }

  String _lastEntryCategoryCode = '';
  String _lastEntryCode = '';
  String _reportDraft = '';
  String _reportDraftRecordCode = '';
  String _reportDraftTemplateCode = '';

  /// 最后一次打开的词条分类Code
  String get lastEntryCategoryCode => _lastEntryCategoryCode;

  /// 最后一次打开的词条Code
  String get lastEntryCode => _lastEntryCode;

  /// 报告编辑的草稿
  String get reportDraft => _reportDraft;

  /// 报告草稿模板的 Code
  String get reportDraftTemplateCode => _reportDraftTemplateCode;

  /// 报告编辑的草稿关联的记录Code
  String get reportDraftRecordCode => _reportDraftRecordCode;

  /// 设置默认打开状态
  void setLastEntryCategoryCode(String code) {
    _lastEntryCategoryCode = code;
  }

  void setLastEntryCode(String code) {
    _lastEntryCode = code;
  }

  /// 存草稿
  void setReportDraft(String draft, String templateCode) {
    _reportDraft = draft;
    _reportDraftTemplateCode = templateCode;
  }

  void setReportDraftRecordCode(String code) {
    _reportDraftRecordCode = code;
  }

  // ReportEditorSetting();

  /// 从json中初始化数据
  void setDataFromJson(Map<String, dynamic> json) {
    _lastEntryCategoryCode = json['lastEntryCategoryCode'];
    _lastEntryCode = json['lastEntryCode'];
    _reportDraft = json['reportDraft'];
    _reportDraftRecordCode = json['reportDraftRecordCode'];
    _reportDraftTemplateCode = json['reportDraftTemplateCode'];
  }

  /// 当前实体转为json
  Map<String, dynamic> toJson() => {
        'lastEntryCategoryCode': _lastEntryCategoryCode,
        'lastEntryCode': _lastEntryCode,
        'reportDraft': _reportDraft,
        'reportDraftRecordCode': _reportDraftRecordCode,
        'reportDraftTemplateCode': _reportDraftTemplateCode,
      };
}
