已完成用户APP首期功能开发
交付用户端首期页面、配套接口、后台资源及测试文档。用户APP构建、静态分析和三个管理后台构建通过;完整测试仍有2项失败,后端模型注释检查未通过,详见交付记录。
This commit is contained in:
49
apps/user_app/lib/domain/models/service_ticket.dart
Normal file
49
apps/user_app/lib/domain/models/service_ticket.dart
Normal file
@@ -0,0 +1,49 @@
|
||||
// 功能描述:工单展示适配,状态动作只取服务端许可,不猜测派单和处理时间。
|
||||
// 版本:1.0.0。
|
||||
import 'client_models.dart';
|
||||
|
||||
class ServiceTicket {
|
||||
const ServiceTicket(this.record);
|
||||
final ClientRecord record;
|
||||
String get identity => record.identity;
|
||||
String get number => text('ticket_no', record.title);
|
||||
String get state => text('status_name', '状态待核实');
|
||||
String get description => text('description', '暂无描述');
|
||||
String get result => text('result');
|
||||
String get address => text('address', '未填写地址');
|
||||
List<Map<String, Object?>> get photos => (record.raw['photos'] as List? ?? [])
|
||||
.whereType<Map<Object?, Object?>>()
|
||||
.map((value) => Map<String, Object?>.from(value))
|
||||
.where((value) => value['identity'] is String)
|
||||
.toList();
|
||||
String get fault =>
|
||||
const {'valve': '阀门故障', 'alarm': '报警器故障', 'leak': '燃气泄漏', 'other': '其他问题'}[text(
|
||||
'fault_type',
|
||||
)] ??
|
||||
category;
|
||||
String get category =>
|
||||
const {
|
||||
'repair': '维修',
|
||||
'installation': '安装',
|
||||
'inspection': '安检',
|
||||
'reinspection': '复检',
|
||||
'customer_service': '客户服务',
|
||||
}[text('category')] ??
|
||||
'其他服务';
|
||||
List<String> get actions =>
|
||||
(record.raw['allowed_actions'] as List?)?.whereType<String>().toList() ?? [];
|
||||
|
||||
/// 返回可展示文字,空值采用调用方指定的占位。
|
||||
String text(String key, [String fallback = '']) {
|
||||
final value = record.raw[key];
|
||||
return value is String && value.trim().isNotEmpty ? value : fallback;
|
||||
}
|
||||
|
||||
/// 使用接口的真实时间转换到本地,缺失时不生成推测进度。
|
||||
String time(String key) {
|
||||
final value = DateTime.tryParse(text(key))?.toLocal();
|
||||
if (value == null) return '未记录';
|
||||
String pad(int n) => n.toString().padLeft(2, '0');
|
||||
return '${value.year}-${pad(value.month)}-${pad(value.day)} ${pad(value.hour)}:${pad(value.minute)}';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user