/*
 * @Author       : WuWei
 * @LastEditors: wuwei
 * @Date         : 2023-08-16 10:40:49
 * @LastEditTime: 2024-03-20 11:37:45
 * @Description  : Do not edit
 */

import 'package:get/get.dart';

class FilterPageStore extends GetxController {
  Rx<DateTime> meterDate = Rx<DateTime>(DateTime.now());

  var meterType = ''.obs;
  var order = 'asc'.obs;
  var statusType = ''.obs;
  var isHouse = true.obs;

  ///弹窗筛选
  var filterValues = {
    'buildId': '',
    'name': '',
    'unitId': '',
  }.obs;

  init() async {
    filterValues.value = Map.from(Get.arguments['filterValues']);
    meterType.value = Get.arguments['meterType'];
    order.value = Get.arguments['order'];
    statusType.value = Get.arguments['statusType'];
    isHouse.value = Get.arguments['isHouse'];
    if (Get.arguments['meterDate'] != null) {
      meterDate.value = Get.arguments['meterDate'];
    }
  }

  ///弹窗筛选
  filterChange(values) {
    filterValues.value = Map.from(values);
  }

  List meterTypeList = [
    {'code': '', 'name': '全部'},
    {'code': 'electricMeter', 'name': '电表'},
    {'code': 'waterMeter', 'name': '水表'}
  ];

  List orderTypeList = [
    {'code': 'asc', 'name': '正序'},
    {'code': 'desc', 'name': '倒序'}
  ];

  List statusTypeList = [
    {'code': '', 'name': '全部'},
    {'code': 'true', 'name': '已抄表'},
    {'code': 'false', 'name': '未抄表'}
  ];

  chooseMeterDate(date) {
    meterDate.value = date;
  }

  chooseMeterType(type) {
    meterType.value = type;
  }

  choosehouseFilterType(type) {
    order.value = type;
  }

  chooseStatusType(type) {
    statusType.value = type;
  }
 

  /// 筛选重置
  onResetInner() {
    filterValues.value = {
      'buildId': '',
      'name': '',
      'unitId': '',
    };
    meterType.value = '';
    meterDate.value = DateTime.now();
    statusType.value = '';
    order.value = 'asc';
    Get.back(result: {
      'filterValues': filterValues,
      'meterType': meterType.value,
      'meterDate': meterDate.value,
      'statusType': statusType.value,
      'order': order.value,
    });
  }

  back() {
    Get.back();
  }

  /// 确认筛选
  submit() {
    Get.back(result: {
      'filterValues': filterValues,
      'meterType': meterType.value,
      'meterDate': meterDate.value,
      'statusType': statusType.value,
       'order': order.value,
    });
  }
}
