Files
tuiche/lib/controller/mh_controller/issue_controller.dart
2025-06-06 09:18:06 +08:00

56 lines
1.7 KiB
Dart
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import 'package:ef/ef.dart';
import 'package:json_annotation/json_annotation.dart';
import 'package:vbvs_app/common/color/appConstants.dart';
part 'issue_controller.g.dart';
@JsonSerializable()
class IssueListModel {
List issueList = [];
int limit = AppConstants.limit;
int offset = 0;
bool isLoading = false;
bool hasMore = true;
int? selectedIndex;
IssueListModel();
static IssueListModel fromJson(Map<String, dynamic> json) =>
_$IssueListModelFromJson(json);
Map<String, dynamic> toJson() => _$IssueListModelToJson(this);
}
class IssueListController extends GetControllerEx<IssueListModel> {
// HelpRepository helpRepository = HelpRepository();
IssueListController() {
attr = GetModel(IssueListModel()).obs;
}
// //初始化列表数据
// Future<void> initData() async {
// if (model.isLoading) {
// return;
// }
// model.isLoading = true;
// final List<dynamic> fetchedRepairs = await helpRepository.findHelpInfos(
// limit: model.limit, offset: model.offset);
// if (fetchedRepairs != null) {
// List<IssueModel> infos = [];
// List<dynamic> tmp = fetchedRepairs as List<dynamic>;
// try {
// // infos = tmp.map((repair) => IssueModel.fromJson(repair)).toList();
// // model.issueList!.addAll(infos);
// model.issueList.addAll(tmp);
// } catch (e) {
// print('Error parsing JSON: $e');
// }
// }
// model.offset += model.limit; // 更新 offset下一次查询跳过当前已经加载的记录
// model.hasMore = fetchedRepairs.length == model.limit; // 判断是否还有更多数据
// model.isLoading = false;
// updateAll();
// }
}