import 'package:fis_jsonrpc/services/report.m.dart';
import 'package:get/get.dart';

class ReportTemplateState {
  ///模板列表
  final Rx<List<ReportTemplateDTO>> _templates = Rx(<ReportTemplateDTO>[]);
  final Rx<List<ReportTemplateDTO>> _publishTemplates =
      Rx(<ReportTemplateDTO>[]);
  final Rx<bool> _isInitTemolates = Rx(false);
  final Rx<bool> _isOrg = Rx(false);
  final Rx<String> _templateId = Rx('');
  final Rx<String> _key = Rx('');
  final Rx<String> _templateType = Rx('');
  final Rx<String> _templateName = Rx('');

  /// 标题
  final Rx<String> _title = Rx('');
  final Rx<String> _defaultTemplateCode = Rx('');

  ///模板列表
  final Rx<ReportTemplateDTO> _selectedTemplate = Rx(ReportTemplateDTO());
  final Rx<int> _selectTemplateIndex = Rx(0);

  ///搜索关键字
  String get key => _key.value;
  set key(String key) => _key.value = key;

  ///模板Id
  String get templateId => _templateId.value;
  set templateId(String v) => _templateId.value = v;

  ///模板类别
  String get templateType => _templateType.value;
  set templateType(String v) => _templateType.value = v;

  ///模板名称
  String get templateName => _templateName.value;
  set templateName(String v) => _templateName.value = v;

  ///add or edit
  String openMode = 'add';

  ///当前选中模板位置
  int get selectTemplateIndex => _selectTemplateIndex.value;
  set selectTemplateIndex(int value) => _selectTemplateIndex.value = value;

  ///是否机构模板
  bool get isOrg => _isOrg.value;
  set isOrg(bool isOrg) => _isOrg.value = isOrg;

  ///当前选中模板
  ReportTemplateDTO get selectedTemplate => _selectedTemplate.value;
  set selectedTemplate(ReportTemplateDTO value) =>
      _selectedTemplate.value = value;

  ///模板列表长度
  int get templateCount => templates.length;

  ///模板列表
  List<ReportTemplateDTO> get templates => _templates.value;
  set templates(List<ReportTemplateDTO> value) => _templates.value = value;

  ///模板列表
  List<ReportTemplateDTO> get publishTemplates => _publishTemplates.value;
  set publishTemplates(List<ReportTemplateDTO> value) =>
      _publishTemplates.value = value;

  ///标题
  set title(String value) => _title.value = value;
  String get title => _title.value;

  ///默认模板Code
  set defaultTemplateCode(String value) => _defaultTemplateCode.value = value;
  String get defaultTemplateCode => _defaultTemplateCode.value;

  ///是否初始化完成
  set isInitTemplates(bool val) => _isInitTemolates.value = val;
  bool get isInitTemplates => _isInitTemolates.value;
}
