diff --git a/lib/features/devices/presentation/bloc/devices_cubit.dart b/lib/features/devices/presentation/bloc/devices_cubit.dart index 40fe037d..327d77d1 100644 --- a/lib/features/devices/presentation/bloc/devices_cubit.dart +++ b/lib/features/devices/presentation/bloc/devices_cubit.dart @@ -1,7 +1,9 @@ +import 'package:flutter/rendering.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:maibu_satabot_v2/features/devices/domain/entities/device_entity.dart'; import 'package:maibu_satabot_v2/features/devices/domain/repositories/device_repository.dart'; import 'package:maibu_satabot_v2/features/devices/domain/usecases/get_user_device_usecase.dart'; +import 'package:maibu_satabot_v2/features/devices/domain/usecases/select_work_record_usecase.dart'; import 'package:maibu_satabot_v2/features/devices/domain/usecases/unbind_device_usecase.dart'; import 'package:maibu_satabot_v2/features/devices/domain/usecases/update_devicename_usecase.dart'; @@ -18,6 +20,7 @@ class DevicesCubit extends Cubit { final DeleteWorkRecordUseCase _deleteWorkRecordUseCase; final UnbindDeviceUseCase _unbindDeviceUseCase; final UpdateDevicenameUsecase _updateDevicename; + final SelectWorkRecordUseCase _selectWorkRecordUseCase; DevicesCubit( this.repository, @@ -27,6 +30,7 @@ class DevicesCubit extends Cubit { this._deleteWorkRecordUseCase, this._unbindDeviceUseCase, this._updateDevicename, + this._selectWorkRecordUseCase ) : super(const DevicesState()); Future unbindDevice(String deviceId, String deviceName) async { @@ -258,4 +262,18 @@ class DevicesCubit extends Cubit { ), ); } + /// 加载指定作业名的路径数据 + Future loadSelectedPath(String workName) async { + emit(state.copyWith(isLoading: true)); + try { + final result = await _selectWorkRecordUseCase.call(workName); + result.fold( + (failure) => emit(state.copyWith(isLoading: false, errorMessage: failure.message)), + (data) => emit(state.copyWith(isLoading: false, pathData: data)), + ); + } catch (e) { + emit(state.copyWith(isLoading: false, errorMessage: e.toString())); + } + } + }