Browse Source

add repair get a quote dialog

glglove 2 months ago
parent
commit
e32651aa81

+ 5 - 0
packages/cpt_services/lib/modules/services/clean_order_detail/clean_order_detail_vm.dart

@@ -161,6 +161,10 @@ class CleanOrderDetailVm extends _$CleanOrderDetailVm with DioCancelableMixin {
     DialogEngine.show(
         tag: "cancelOrder",
         position: DialogPosition.center,
+        onDismiss: () {
+          // 清空备注信息
+          clearReasonInput();
+        },
         widget: DialogContentWrap(
           loadingState: LoadState.State_Success,
           maxHeight: 460.0,
@@ -243,6 +247,7 @@ class CleanOrderDetailVm extends _$CleanOrderDetailVm with DioCancelableMixin {
   clearReasonInput() {
     state.cancelReason = "";
     state.cancelFormData!['reason']!["controller"].text = "";
+    state = state.copyWith(cancelReason: "", cancelFormData: state.cancelFormData);
   }
 
   //获取详情数据

+ 110 - 0
packages/cpt_services/lib/modules/services/service_repair_detail/getQuoteDialogContent.dart

@@ -0,0 +1,110 @@
+import 'dart:math';
+
+import 'package:auto_route/src/route/page_route_info.dart';
+import 'package:cpt_services/components/chooseVisitTimeBottomFooter.dart';
+import 'package:cpt_services/modules/services/clean_order_detail/clean_order_detail_vm.dart';
+import 'package:cpt_services/modules/services/service_repair_detail/service_repair_detail_vm.dart';
+import 'package:cs_resources/generated/assets.dart';
+import 'package:cs_resources/theme/app_colors_theme.dart';
+import 'package:flutter/material.dart';
+import 'package:flutter/widgets.dart';
+import 'package:flutter_hooks/flutter_hooks.dart';
+import 'package:hooks_riverpod/hooks_riverpod.dart';
+import 'package:plugin_platform/engine/toast/toast_engine.dart';
+import 'package:shared/utils/color_utils.dart';
+import 'package:shared/utils/util.dart';
+import 'package:widgets/ext/ex_widget.dart';
+import 'package:widgets/my_button.dart';
+import 'package:widgets/my_load_image.dart';
+import 'package:widgets/my_text_view.dart';
+
+class GetQuoteDialogContent extends HookConsumerWidget {
+
+  const GetQuoteDialogContent({
+    Key? key,
+  }) : super(key: key);
+
+  @override
+  Widget build(BuildContext context, WidgetRef ref) {
+    final vm = ref.read(cleanOrderDetailVmProvider.notifier);
+
+    return SizedBox(
+      width: double.infinity,
+      child: Column(
+        mainAxisAlignment: MainAxisAlignment.start,
+        crossAxisAlignment: CrossAxisAlignment.start,
+        children: [
+          MyTextView(
+            "Please fill in your remarks information",
+            fontSize: 17,
+            isFontBold: true,
+          ),
+          Container(
+            height: 175,
+            child: _buildTextAreaLayout(context, vm, ref, 'userNotes'),
+          ),
+        ],
+      ),
+    );
+  }
+
+  /// 多行输入框
+  Widget _buildTextAreaLayout(BuildContext context, CleanOrderDetailVm vm, WidgetRef ref, String key) {
+    final state = ref.watch(serviceRepairDetailVmProvider);
+    final repairDetailVm = ref.read(serviceRepairDetailVmProvider.notifier);
+    final noteCount = useState(0);
+    return Stack(children: [
+      Container(
+        color: ColorUtils.string2Color("#F2F3F6"),
+        margin: const EdgeInsets.only(top: 15, bottom: 28.5),
+        padding: const EdgeInsets.only(left: 10, right: 10, top: 10, bottom: 10),
+        child: TextField(
+          cursorColor: context.appColors.authFiledText,
+          cursorWidth: 1.5,
+          autofocus: false,
+          enabled: true,
+          maxLines: null,
+          focusNode: state.getQuoteFormData![key]!['focusNode'],
+          controller: state.getQuoteFormData![key]!['controller'],
+          decoration: InputDecoration(
+            isDense: true,
+            isCollapsed: true,
+            border: InputBorder.none,
+            hintText: state.getQuoteFormData![key]!['hintText'],
+            hintStyle: TextStyle(
+              color: context.appColors.authFiledHint,
+              fontSize: 16.0,
+              fontWeight: FontWeight.w400,
+            ),
+          ),
+          style: TextStyle(
+            color: context.appColors.authFiledText,
+            fontSize: 16.0,
+            fontWeight: FontWeight.w400,
+          ),
+          textInputAction: TextInputAction.done,
+          onSubmitted: (value) {
+            FocusScope.of(context).unfocus();
+          },
+          expands: true,
+          onChanged: (text) {
+            // 当文本改变时,更新字符数量
+            noteCount.value = text.length;
+            repairDetailVm.changeGetQuoteFormData(context, text);
+          },
+        ),
+      ),
+      // Positioned(
+      //   bottom: 0.0,
+      //   right: 0.0,
+      //   child: Text(
+      //     S.current.characters(noteCount.value),
+      //     style: TextStyle(
+      //       color: context.appColors.textBlack,
+      //       fontSize: 15.0,
+      //     ),
+      //   ),
+      // ),
+    ]);
+  }
+}

+ 1 - 1
packages/cpt_services/lib/modules/services/service_repair_detail/service_repair_detail_page.dart

@@ -230,7 +230,7 @@ class ServiceRepairDetailPage extends HookConsumerWidget {
                         minHeight: 44.5,
                         fontWeight: FontWeight.w400,
                         onPressed: () {
-                          vm.RepairServiceSubmit(context, id);
+                          vm.handlerGetQuote(context, id);
                         },
                       ),
                     ),

+ 19 - 1
packages/cpt_services/lib/modules/services/service_repair_detail/service_repair_detail_state.dart

@@ -1,5 +1,6 @@
 import 'package:domain/entity/garage_sale_rent_detail_entity.dart';
 import 'package:domain/entity/service_repair_detail_entity.dart';
+import 'package:flutter/cupertino.dart';
 import 'package:widgets/load_state_layout.dart';
 
 class ServiceRepairDetailState {
@@ -10,6 +11,9 @@ class ServiceRepairDetailState {
   final int? id;
   final String? type;
 
+  String? userNotes;  // 取消的文字
+  Map<String, Map<String, dynamic>> getQuoteFormData;
+
   ServiceRepairDetailEntity? datas;
 
   ServiceRepairDetailState({
@@ -18,7 +22,17 @@ class ServiceRepairDetailState {
     this.id,
     this.type,
     required this.datas,
-  });
+    this.userNotes,
+    Map<String, Map<String, dynamic>>? getQuoteFormData,
+  }): getQuoteFormData = getQuoteFormData ?? {
+    "userNotes": {
+      'value': '',
+      'controller': TextEditingController(),
+      'hintText': '',
+      'focusNode': FocusNode(),
+      'obsecure': false,
+    },
+  };
 
   ServiceRepairDetailState copyWith({
     ServiceRepairDetailEntity? datas,
@@ -26,6 +40,8 @@ class ServiceRepairDetailState {
     String? errorMessage,
     int? id,
     String? type,
+    String? userNotes,
+    Map<String, Map<String, dynamic>>? getQuoteFormData,
   }) {
     return ServiceRepairDetailState(
       loadingState: loadingState ?? this.loadingState,
@@ -33,6 +49,8 @@ class ServiceRepairDetailState {
       id: id ?? this.id,
       type: type ?? this.type,
       datas: datas?? this.datas,
+      userNotes: userNotes ?? this.userNotes,
+      getQuoteFormData: getQuoteFormData ?? this.getQuoteFormData,
     );
   }
 }

+ 103 - 3
packages/cpt_services/lib/modules/services/service_repair_detail/service_repair_detail_vm.dart

@@ -1,5 +1,6 @@
 import 'package:cpt_services/components/chooseAirConditionContent.dart';
 import 'package:cs_resources/generated/assets.dart';
+import 'package:cs_resources/theme/app_colors_theme.dart';
 import 'package:domain/entity/garage_sale_rent_detail_entity.dart';
 import 'package:domain/entity/service_repair_detail_entity.dart';
 import 'package:flutter/cupertino.dart';
@@ -12,13 +13,16 @@ import 'package:router/ext/auto_router_extensions.dart';
 import 'package:shared/utils/color_utils.dart';
 import 'package:shared/utils/log_utils.dart';
 import 'package:widgets/dialog/app_custom_dialog.dart';
+import 'package:widgets/dialog/dialog_content_wrap.dart';
 import 'package:widgets/load_state_layout.dart';
+import 'package:widgets/my_button.dart';
 import 'package:widgets/my_text_view.dart';
 import 'package:widgets/widget_export.dart';
 import 'package:flutter/src/widgets/framework.dart';
 
 import '../../../respository/services_respository.dart';
 import '../../../router/page/services_page_router.dart';
+import 'getQuoteDialogContent.dart';
 import 'service_repair_detail_state.dart';
 
 part 'service_repair_detail_vm.g.dart';
@@ -251,13 +255,108 @@ class ServiceRepairDetailVm extends _$ServiceRepairDetailVm {
     });
   }
 
-  Future RepairServiceSubmit<T>(
+  changeGetQuoteFormData(BuildContext context,String userNotes){
+    state = state.copyWith(
+      userNotes: userNotes,
+    );
+  }
+
+  // 获取 报价备注信息
+  String getUserNotes(){
+    String userNotes = "";
+    if(state.getQuoteFormData != null){
+      userNotes = state.getQuoteFormData!["userNotes"]!['controller'].text;
+    }
+    Log.d("报价备注信息: $userNotes");
+    return userNotes;
+  }
+
+  // 提交 报价
+  void handlerGetQuote(BuildContext context, int id) async {
+    DialogEngine.show(
+        tag: "getQuote",
+        position: DialogPosition.center,
+        onDismiss: () {
+          // 清空报价备注信息
+          clearUserNotesInput();
+        },
+        widget: DialogContentWrap(
+          loadingState: LoadState.State_Success,
+          maxHeight: 400.0,
+          dialogWidth: 345.0,
+          isShowConfirmBtn: false,
+          isShowCancelBtn: false,
+          confirmTxt: "Confirm",
+          title: "Confirm Information",
+          titleBackgroundColor: context.appColors.textPrimary,
+          closeIconColor: context.appColors.textWhite,
+          titleTextStyle: TextStyle(
+            color: context.appColors.textWhite,
+          ),
+          messageBuilder: (context) {
+            return const GetQuoteDialogContent();
+          },
+          bottomFooterBuilder: (context) {
+            return Padding(
+              padding: const EdgeInsets.only(bottom: 40),
+              child: MyButton(
+                onPressed: () {
+                  // 提交取消订单
+                  submitQuote(context, id);
+                },
+                text: "Confirm",
+                minWidth: 305,
+                minHeight: 45,
+                fontSize: 16,
+                fontWeight: FontWeight.w500,
+                backgroundColor: context.appColors.textPrimary,
+                textColor: context.appColors.textWhite,
+              ),
+            );
+          },
+          bottomBtnRadius: 10,
+          bottomBtnSpace: 5,
+          topLeftRadius: 10.0,
+          topRightRadius: 10.0,
+          bottomLeftRadius: 10.0,
+          bottomRightRadius: 10.0,
+          contentPadding: const EdgeInsets.only(left: 20, right: 20, bottom: 20, top: 20),
+          bottomBtnSectionPadding: const EdgeInsets.only(left: 20, right: 20, bottom: 20, top: 20),
+          cancelAction: () {
+            DialogEngine.dismiss(tag: 'getQuote');
+            clearUserNotesInput();
+          },
+          confirmAction: () {
+            clearUserNotesInput();
+          },
+        ));
+  }
+
+  clearUserNotesInput() {
+    state = state.copyWith(
+      userNotes: "",
+      getQuoteFormData: {
+        "userNotes": {
+          'value': '',
+          'controller': TextEditingController(),
+          'hintText': '',
+          'focusNode': FocusNode(),
+          'obsecure': false,
+        }
+      },
+    );
+  }
+
+  Future submitQuote<T>(
       BuildContext context, int id) async {
     try {
-      Map<String, dynamic> params = {"service_id": id, "user_notes": "test"};
+      Map<String, dynamic> params = {"service_id": id, "user_notes": getUserNotes()};
       final result =
           await serviceRespositoryInstance.fetchRepairServiceSubmit(params);
       if (result.isSuccess) {
+        // 关闭 getQuote dialog
+        DialogEngine.dismiss(tag: 'getQuote');
+        // 弹出成功的提示dialog
         handlerClickQuoteBtn(context, id);
       } else {
         ToastEngine.show(result.errorMsg ?? "Network Load Error");
@@ -267,10 +366,11 @@ class ServiceRepairDetailVm extends _$ServiceRepairDetailVm {
     }
   }
 
+  // 报价提交成功后的 提示dialog
   handlerClickQuoteBtn(
       BuildContext context, int id) async {
     await DialogEngine.show(
-        tag: "gotoQuote",
+        tag: "gotoQuoteSuccess",
         position: DialogPosition.center,
         widget: AppCustomDialog(
           message: '',