修复完成作业停止之后再开始作业

This commit is contained in:
2026-03-12 16:41:11 +08:00
parent 8a91d5b334
commit c58bf370e3
4 changed files with 17 additions and 1 deletions

View File

@@ -1485,6 +1485,12 @@ class _MapPageEnterpriseState extends State<MapPageEnterprise> {
_workStatus = WorkStatus.working;
});
// 🔥 核心修复:先更新 AppState 为 routePlanning
context.read<DevicesCubit>().updateAppState(AppState.routePlanning);
// 🔥 延迟一下,确保状态已更新
await Future.delayed(const Duration(milliseconds: 100));
//// 步骤1:将 List<LatLng> 转换为 List<DeviceAddPathPointModel>
//final List<work_area_model.DeviceAddPathPointModel> pathModels = gcjPathPoints.map((latLng) {
// return work_area_model.DeviceAddPathPointModel(
@@ -1502,7 +1508,7 @@ class _MapPageEnterpriseState extends State<MapPageEnterprise> {
// 步骤 3:调用 Cubit 方法(类型匹配)
await context.read<DevicesCubit>().startRoutePlanning(pathQueue);
context.read<DevicesCubit>().updateAppState(AppState.routePlanning);
///context.read<DevicesCubit>().updateAppState(AppState.routePlanning);
// 可选:显示作业提示
ToastUtils.showSuccess(context, '作业已开始');
//ScaffoldMessenger.of(context).showSnackBar(const SnackBar(content: Text('作业已开始'), backgroundColor: Colors.green));