优化和路径规划新适配
This commit is contained in:
@@ -378,19 +378,26 @@ class DevicesCubit extends Cubit<DevicesState> {
|
||||
emit(state.copyWith(isLoading: false, errorMessage: failure.message));
|
||||
},
|
||||
(records) {
|
||||
print('🔍 [DevicesCubit] 加载成功,记录数: ${records.length}');
|
||||
// print('🔍 [DevicesCubit] 加载成功,记录数: ${records.length}');
|
||||
// 将 WorkRecordEntity 转换为 Map<String, dynamic> 以兼容现有UI
|
||||
final mappedRecords = records.map((record) {
|
||||
// 🔥 核心修复:根据 jsonData 类型决定存储方式
|
||||
// XML接口返回的已是 JSON 字符串,直接使用,避免二次序列化丢失路径数据
|
||||
// JSON接口返回的 WorkRecordJsonData 对象,仍需序列化
|
||||
String? jsonDataStr;
|
||||
if (record.jsonData is String) {
|
||||
jsonDataStr = record.jsonData as String;
|
||||
} else if (record.jsonData is WorkRecordJsonData) {
|
||||
jsonDataStr = _workRecordJsonDataToJson(record.jsonData as WorkRecordJsonData);
|
||||
}
|
||||
return <String, dynamic>{
|
||||
'id': record.id.toString(),
|
||||
'workName': record.workName,
|
||||
'imgUrl': record.imgUrl ?? '',
|
||||
'jsonData': record.jsonData != null
|
||||
? _workRecordJsonDataToJson(record.jsonData!)
|
||||
: null,
|
||||
'jsonData': jsonDataStr,
|
||||
};
|
||||
}).toList();
|
||||
print('🔍 [DevicesCubit] 转换后的数据: $mappedRecords');
|
||||
// print('🔍 [DevicesCubit] 转换后的数据: $mappedRecords');
|
||||
emit(state.copyWith(isLoading: false, workRecords: mappedRecords));
|
||||
},
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user