84 lines
2.6 KiB
Dart
84 lines
2.6 KiB
Dart
import 'package:ef/ef.dart';
|
||
import 'package:json_annotation/json_annotation.dart';
|
||
import 'package:vbvs_app/common/color/appConstants.dart';
|
||
import 'apply_repair_controller.dart';
|
||
part 'repair_list_controller.g.dart';
|
||
|
||
@JsonSerializable()
|
||
class RepairListModel {
|
||
int limit = AppConstants.limit;
|
||
int offset = 0;
|
||
bool isLoading = false;
|
||
bool hasMore = true;
|
||
|
||
List<ApplyRepairModel> repairList = [];
|
||
|
||
RepairListModel();
|
||
static RepairListModel fromJson(Map<String, dynamic> json) =>
|
||
_$RepairListModelFromJson(json);
|
||
Map<String, dynamic> toJson() => _$RepairListModelToJson(this);
|
||
}
|
||
|
||
class RepairListController extends GetControllerEx<RepairListModel> {
|
||
// RepairRepository repairRepository = RepairRepository();
|
||
// RepairListController() {
|
||
// attr = GetModel(RepairListModel()).obs;
|
||
// }
|
||
|
||
// //初始化列表数据
|
||
// Future<void> initData() async {
|
||
// if (model.isLoading) {
|
||
// return;
|
||
// }
|
||
// model.isLoading = true;
|
||
// final List<dynamic> fetchedRepairs = await repairRepository.fetchRepairs(
|
||
// limit: model.limit, offset: model.offset);
|
||
// if (fetchedRepairs != null) {
|
||
// List<ApplyRepairModel> infos = [];
|
||
// List<dynamic> tmp = fetchedRepairs as List<dynamic>;
|
||
// try {
|
||
// infos = tmp.map((repair) => ApplyRepairModel.fromJson(repair)).toList();
|
||
// model.repairList.addAll(infos);
|
||
// } catch (e) {
|
||
// print('Error parsing JSON: $e');
|
||
// }
|
||
// }
|
||
// model.offset += model.limit; // 更新 offset,下一次查询跳过当前已经加载的记录
|
||
// model.hasMore = fetchedRepairs.length == model.limit; // 判断是否还有更多数据
|
||
// model.isLoading = false;
|
||
// updateAll();
|
||
// }
|
||
|
||
// Future<String> addScore(int id, int score) async {
|
||
// return await repairRepository.addScore(id, score);
|
||
// }
|
||
@override
|
||
void onInit() {
|
||
super.onInit();
|
||
loadMockRepairList();
|
||
}
|
||
|
||
void loadMockRepairList() {
|
||
model.repairList = [
|
||
ApplyRepairModel()
|
||
..id = 1001
|
||
..device_category = '智能床垫 BY-H'
|
||
..status = '待维修'
|
||
..create_time = DateTime.now().subtract(Duration(days: 1))
|
||
..device_id = 'BYH-001',
|
||
ApplyRepairModel()
|
||
..id = 1002
|
||
..device_category = '智能床垫 BY-A'
|
||
..status = '维修中'
|
||
..create_time = DateTime.now().subtract(Duration(days: 2))
|
||
..device_id = 'BYA-002',
|
||
ApplyRepairModel()
|
||
..id = 1003
|
||
..device_category = '智能床垫 BY-C'
|
||
..status = '已完成'
|
||
..create_time = DateTime.now().subtract(Duration(days: 3))
|
||
..device_id = 'BYC-003',
|
||
];
|
||
}
|
||
}
|