- Flutter 3.x 项目初始化(pubspec.yaml + 目录结构) - 核心依赖:dio/go_router/provider/shared_preferences/hive/geolocator - 统一登录页 + Token管理(TokenService + AuthInterceptor) - 底部Tab三合一导航(供水/巡检/营收) - 供水管理Tab:监测数据列表(MonitorListPage) - 巡检Tab:任务列表+状态筛选+进度展示(PatrolTaskListPage) - 营收Tab:抄表页面+账单列表(MeterReadingPage/BillListPage) - 消息推送服务(PushService) - GPS定位服务(LocationService) - 拍照/相册服务(CameraService) - 离线缓存服务(CacheService) - Android/iOS打包配置+权限声明 - GoRouter路由+Auth认证守卫 - Provider状态管理
60 lines
1.7 KiB
Dart
60 lines
1.7 KiB
Dart
/// 巡检任务模型
|
|
class PatrolTaskModel {
|
|
final String id;
|
|
final String taskName;
|
|
final String taskCode;
|
|
final String routeName;
|
|
final String assignee;
|
|
final String status; // pending, in_progress, completed, overdue
|
|
final DateTime planDate;
|
|
final int checkpointTotal;
|
|
final int checkpointCompleted;
|
|
final String? remark;
|
|
|
|
PatrolTaskModel({
|
|
required this.id,
|
|
required this.taskName,
|
|
required this.taskCode,
|
|
required this.routeName,
|
|
required this.assignee,
|
|
required this.status,
|
|
required this.planDate,
|
|
required this.checkpointTotal,
|
|
required this.checkpointCompleted,
|
|
this.remark,
|
|
});
|
|
|
|
double get progress =>
|
|
checkpointTotal > 0 ? checkpointCompleted / checkpointTotal : 0;
|
|
|
|
factory PatrolTaskModel.fromJson(Map<String, dynamic> json) {
|
|
return PatrolTaskModel(
|
|
id: json['id']?.toString() ?? '',
|
|
taskName: json['taskName'] ?? '',
|
|
taskCode: json['taskCode'] ?? '',
|
|
routeName: json['routeName'] ?? '',
|
|
assignee: json['assignee'] ?? '',
|
|
status: json['status'] ?? 'pending',
|
|
planDate: DateTime.tryParse(json['planDate'] ?? '') ?? DateTime.now(),
|
|
checkpointTotal: json['checkpointTotal'] ?? 0,
|
|
checkpointCompleted: json['checkpointCompleted'] ?? 0,
|
|
remark: json['remark'],
|
|
);
|
|
}
|
|
|
|
Map<String, dynamic> toJson() {
|
|
return {
|
|
'id': id,
|
|
'taskName': taskName,
|
|
'taskCode': taskCode,
|
|
'routeName': routeName,
|
|
'assignee': assignee,
|
|
'status': status,
|
|
'planDate': planDate.toIso8601String(),
|
|
'checkpointTotal': checkpointTotal,
|
|
'checkpointCompleted': checkpointCompleted,
|
|
'remark': remark,
|
|
};
|
|
}
|
|
}
|