Prechádzať zdrojové kódy

labour request 的 api 修改

liukai 3 týždňov pred
rodič
commit
fce9162f5d

+ 5 - 1
packages/cpt_labour_sg/lib/modules/labour_request/labour_request_controller.dart

@@ -1,3 +1,4 @@
+import 'package:domain/entity/response/labour_request_s_g_entity.dart';
 import 'package:domain/repository/labour_sg_repository.dart';
 import 'package:get/get.dart';
 import 'package:plugin_platform/http/dio/dio_cancelable_mixin.dart';
@@ -46,7 +47,10 @@ class LabourRequestController extends GetxController with DioCancelableMixin {
     );
 
     if (result.isSuccess) {
-      state.datas = result.data?.countList ?? [];
+      // state.datas = result.data?.countList ?? [];
+      state.datas = result.list
+          ?.whereType<LabourRequestSGCountList>() // 直接过滤出非 null 的 StaffRequestReportEntity
+          .toList() ??[];
       changeLoadingState(LoadState.State_Success);
     } else {
       errorMessage = result.errorMsg ?? "Network Load Error".tr;

+ 26 - 8
packages/cs_domain/lib/repository/labour_sg_repository.dart

@@ -510,7 +510,7 @@ class LabourSGRepository extends GetxService {
   }
 
   /// 用工请求的首页数据
-  Future<HttpResult<LabourRequestSGEntity>> fetchLabourRequestMain(
+  Future<HttpResult<LabourRequestSGCountList?>> fetchLabourRequestMain(
     String? date, {
     CancelToken? cancelToken,
   }) async {
@@ -526,15 +526,33 @@ class LabourSGRepository extends GetxService {
       cancelToken: cancelToken,
     );
 
-    //根据返回的结果,封装原始数据为Bean/Entity对象
+    // //根据返回的结果,封装原始数据为Bean/Entity对象
+    // if (result.isSuccess) {
+    //   //重新赋值data或list
+    //   final json = result.getDataJson();
+    //   var data = LabourRequestSGEntity.fromJson(json!);
+    //   //重新赋值data或list
+    //   return result.convert<LabourRequestSGEntity>(data: data);
+    // }
+    // return result.convert();
+
     if (result.isSuccess) {
-      //重新赋值data或list
-      final json = result.getDataJson();
-      var data = LabourRequestSGEntity.fromJson(json!);
-      //重新赋值data或list
-      return result.convert<LabourRequestSGEntity>(data: data);
+      var jsonList = result.getListJson();
+
+      var list = jsonList?.map((e) {
+        if (e is Map<String, dynamic>) {
+          return LabourRequestSGCountList.fromJson(e);
+        } else {
+          return null;
+        }
+      }).toList();
+
+      return result.convert<LabourRequestSGCountList?>(list: list);
     }
-    return result.convert();
+
+    return result.convert<LabourRequestSGCountList>();
+
+
   }
 
   /// 添加用工请求的选项数据