소스 검색

英国lab-req 增加删除功能

glglove 5 일 전
부모
커밋
2ed2ab0c52

+ 22 - 0
packages/cpt_uk/lib/modules/job/labour_request_list/labour_request_item.dart

@@ -22,6 +22,7 @@ class LabourRequestItem extends StatelessWidget {
   final VoidCallback? onCopyAction;
   final VoidCallback? onQuickCopyAction;
   final VoidCallback? onPreSelectedClickAction;
+  final VoidCallback? onDeleteAction;
 
   LabourRequestItem({
     required this.index,
@@ -33,6 +34,7 @@ class LabourRequestItem extends StatelessWidget {
     this.onCopyAction,
     this.onQuickCopyAction,
     this.onPreSelectedClickAction,
+    this.onDeleteAction
   });
 
   @override
@@ -504,6 +506,26 @@ class LabourRequestItem extends StatelessWidget {
                     ).marginOnly(left: 12),
                   ),
                 ),
+
+                //删除工作流按钮  只有 publish_status 为false 的才可以删除
+                Visibility(
+                  visible: item.publishStatus == false ? true : false,
+                  child: Flexible(
+                    child: MyButton(
+                      onPressed: () {
+                        FocusScope.of(context).unfocus();
+                        onDeleteAction?.call();
+                      },
+                      text: "Delete".tr,
+                      textColor: ColorConstants.white,
+                      backgroundColor: Colors.redAccent,
+                      radius: 17.25,
+                      padding: const EdgeInsets.symmetric(horizontal: 8),
+                      minWidth: 60,
+                      minHeight: 35,
+                    ).marginOnly(left: 12),
+                  ),
+                ),
               ],
             ).marginOnly(top: 18, bottom: 2),
           ),

+ 25 - 0
packages/cpt_uk/lib/modules/job/labour_request_list/labour_request_list_controller.dart

@@ -352,6 +352,31 @@ class LabourRequestListController extends GetxController with DioCancelableMixin
     UKLabourRequestPreselectedListPage.startInstance(data.requestId.toString(), publishStatus);
   }
 
+  // 删除
+  void doDelete(UkLabourRequestTableRows data, BuildContext? context ) {
+    DialogEngine.show(
+      widget: AppDefaultDialog(
+        title: "Message".tr,
+        message: "Are you sure you want to delete it?".tr,
+        confirmAction: () {
+          doDeleteLabRequest(data.requestId!.toString());
+        },
+      ));
+  }
+
+  doDeleteLabRequest(String requestId) async {
+    var result = await _UKlabourRepository.deleteLabourRequest(
+      requestId,
+      cancelToken: cancelToken,
+    );
+    if (result.isSuccess) {
+      NotifyEngine.showSuccess("Successful".tr);
+      refreshController.callRefresh();
+    } else {
+      ToastEngine.show(result.errorMsg ?? "Network Load Error".tr);
+    }
+  }
+
   //去新增页面Copy
   void gotoCopyPage(UkLabourRequestTableRows data) {
     UKLabourRequestAddPage.startInstance(0, data.requestId.toString());

+ 4 - 1
packages/cpt_uk/lib/modules/job/labour_request_list/labour_request_list_page.dart

@@ -158,7 +158,10 @@ class _LabourRequestListState extends BaseState<UKLabourRequestListPage, LabourR
                           },
                           onPreSelectedClickAction:(){
                             controller.gotoPreSelectedPage(state.datas[index], context,  state.datas[index].publishStatus!);
-                          }
+                          },
+                          onDeleteAction: (){
+                            controller.doDelete(state.datas[index], context);
+                          },
                         );
                       },
                       childCount: state.datas.length,

+ 2 - 0
packages/cs_domain/lib/constants/api_constants.dart

@@ -304,6 +304,8 @@ class ApiConstants {
   static const apiJobTemplateDetailBySelectTitleUK = "/index.php/api/v1/hotel/temp/show-template-record";
   // labourrequest 快速复制工作
   static const apiLabourRequestQuickCopyUK = "/index.php/api/v1/hotel/lab-req/quick-copy";
+  // labourrequest 删除工作
+  static const apiLabourRequestDeleteUK = "/index.php/api/v1/hotel/lab-req/delete";
   // 预选人列表
   static const apiLabourRequestPreSelectListUK = "/index.php/api/v1/hotel/prestaff/table";
   // 筛选的条件

+ 27 - 0
packages/cs_domain/lib/repository/uk_labour_repository.dart

@@ -693,6 +693,33 @@ class UkLabourRepository extends GetxService {
     return result.convert();
   }
 
+  /// 用工请求 删除
+  Future<HttpResult> deleteLabourRequest(
+      String? requestId,
+      {
+        CancelToken? cancelToken,
+      }) async {
+    //参数
+    Map<String, String> params = {};
+    params['request_id'] = requestId ?? "";
+
+    final result = await httpProvider.requestNetResult(
+      ApiConstants.apiLabourRequestDeleteUK,
+      method: HttpMethod.POST,
+      params: params,
+      networkDebounce: true,
+      isShowLoadingDialog: true,
+      cancelToken: cancelToken,
+    );
+
+    //根据返回的结果,封装原始数据为Bean/Entity对象
+    if (result.isSuccess) {
+      //重新赋值data或list
+      return result.convert();
+    }
+    return result.convert();
+  }
+
   /// 获取 labourequest preselected 列表
   Future<HttpResult<UkLabourRequestPreselectedListEntity>> fetchLabourRequestPreselectedList(
     String reQuestId,