Pārlūkot izejas kodu

签名弹窗与签到签出

liukai 8 mēneši atpakaļ
vecāks
revīzija
c8dec7e53c

+ 0 - 12
app/pubspec.yaml

@@ -59,18 +59,6 @@ dependencies:
   #  https://pub-web.flutter-io.cn/packages/flutter_bugly
   flutter_bugly: 0.4.4
 
-  # 定位,反地理编码
-  flutter_bmflocation: 3.6.0
-
-  #手写签名 https://pub.dev/packages/hand_signature
-  hand_signature: ^3.0.2
-
-  #密码输入框 https://pub.dev/packages/hb_password_input_textfield
-  hb_password_input_textfield: ^1.0.1
-
-  #视频播放 https://pub.dev/packages/video_player
-  chewie: 1.7.5
-
 
 #  开发环境依赖的库
 dev_dependencies:

+ 49 - 4
packages/cpt_job/lib/modules/sign_in_sign_out/sign_in_sign_out_controller.dart

@@ -1,16 +1,19 @@
+import 'dart:typed_data';
+
 import 'package:domain/entity/response/attendance_entity.dart';
+import 'package:domain/entity/response/check_success_entity.dart';
 import 'package:domain/repository/job_repository.dart';
-import 'package:flutter/material.dart';
 import 'package:get/get.dart';
 import 'package:plugin_basic/service/user_service.dart';
+import 'package:plugin_platform/engine/dialog/dialog_engine.dart';
 import 'package:plugin_platform/engine/toast/toast_engine.dart';
 import 'package:plugin_platform/http/dio/dio_cancelable_mixin.dart';
 import 'package:shared/utils/date_time_utils.dart';
 import 'package:widgets/load_state_layout.dart';
-import 'package:widgets/picker/option_pick_util.dart';
 import 'package:widgets/picker/date_picker_util.dart';
 import 'package:widgets/widget_export.dart';
 
+import '../../widget/attendance_sign_in_out.dart';
 import 'sign_in_sign_out_state.dart';
 
 class SignInSignOutController extends GetxController with DioCancelableMixin {
@@ -97,6 +100,36 @@ class SignInSignOutController extends GetxController with DioCancelableMixin {
     }
   }
 
+  /// 签到签出
+  void requestCheckInCheckOut(bool isCheckIn, AttendanceList item, ByteData byteData) async {
+    //请求接口
+    final String? token = UserService.to.token;
+
+    var result = await jobRepository.submitCheckInOut(
+      token,
+      item.appliedId.toString(),
+      byteData,
+      isCheckIn: isCheckIn,
+      cancelToken: cancelToken,
+    );
+
+    if (result.isSuccess) {
+      CheckSuccessEntity entity = result.data!;
+      if (isCheckIn) {
+        item.checkInImg = entity.checkImg;
+        item.checkInTime = entity.checkTime;
+      } else {
+        item.checkOutImg = entity.checkImg;
+        item.checkOutTime = entity.checkTime;
+      }
+      //更新状态
+      update();
+    } else {
+      errorMessage = result.errorMsg;
+      ToastEngine.show(errorMessage ?? "Network Load Error".tr);
+    }
+  }
+
   //执行搜索
   void doSearch() {
     var keywordController = state.formData['keyword']!['controller'];
@@ -118,12 +151,24 @@ class SignInSignOutController extends GetxController with DioCancelableMixin {
 
   /// 用户签到
   void userSignIn(AttendanceList item) {
-    ToastEngine.show("用户签到");
+    DialogEngine.show(
+      widget: AttendanceSignInOut(
+        confirmAction: (byteData) {
+          requestCheckInCheckOut(true, item, byteData);
+        },
+      ),
+    );
   }
 
   /// 用户签出
   void userSignOut(AttendanceList item) {
-    ToastEngine.show("用户签出");
+    DialogEngine.show(
+      widget: AttendanceSignInOut(
+        confirmAction: (byteData) {
+          requestCheckInCheckOut(false, item, byteData);
+        },
+      ),
+    );
   }
 
   /// 重置筛选条件

+ 8 - 10
packages/cpt_job/lib/modules/sign_in_sign_out/sign_in_sign_out_page.dart

@@ -129,11 +129,11 @@ class _SignInSignOutPageState extends BaseState<SignInSignOutPage, SignInSignOut
                     successSliverWidget: [
                       SliverList(
                           delegate: SliverChildBuilderDelegate(
-                                (context, index) {
-                              return _buildAttendanceItem(controller, index, () {});
-                            },
-                            childCount: controller.datas.length,
-                          ))
+                        (context, index) {
+                          return _buildAttendanceItem(controller, index, () {});
+                        },
+                        childCount: controller.datas.length,
+                      ))
                     ],
                   ),
                 ).expanded(),
@@ -242,7 +242,7 @@ class _SignInSignOutPageState extends BaseState<SignInSignOutPage, SignInSignOut
         children: [
           Obx(() {
             return MyTextView(
-              DateTimeUtils.formatDate(controller.startDate.value,format: "yyyy-MM-dd"),
+              DateTimeUtils.formatDate(controller.startDate.value, format: "yyyy-MM-dd"),
               fontSize: 16,
               textAlign: TextAlign.center,
               isFontRegular: true,
@@ -252,12 +252,10 @@ class _SignInSignOutPageState extends BaseState<SignInSignOutPage, SignInSignOut
               },
             );
           }).expanded(),
-
-          Container(color: Color(0XFF52739C), width: 0.5, height: 21.5,),
-
+          Container(color: Color(0XFF52739C), width: 0.5, height: 21.5),
           Obx(() {
             return MyTextView(
-              DateTimeUtils.formatDate(controller.endDate.value,format: "yyyy-MM-dd"),
+              DateTimeUtils.formatDate(controller.endDate.value, format: "yyyy-MM-dd"),
               fontSize: 16,
               textAlign: TextAlign.center,
               isFontRegular: true,

+ 157 - 0
packages/cpt_job/lib/widget/attendance_sign_in_out.dart

@@ -0,0 +1,157 @@
+import 'dart:typed_data';
+import 'dart:ui';
+
+import 'package:flutter/cupertino.dart';
+import 'package:flutter/material.dart';
+import 'package:flutter/widgets.dart';
+import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
+import 'package:get/get.dart';
+import 'package:widgets/ext/ex_widget.dart';
+import 'package:cs_resources/constants/color_constants.dart';
+import 'package:widgets/my_text_view.dart';
+import 'package:widgets/widget_export.dart';
+
+class AttendanceSignInOut extends StatelessWidget {
+  VoidCallback? cancelAction;
+  void Function(ByteData byteData)? confirmAction;
+
+  //签名版配置
+  HandSignatureControl handSignatureControl = HandSignatureControl(
+    threshold: 3.0,
+    smoothRatio: 200 / 240,
+    velocityRange: 2.0,
+  );
+
+  AttendanceSignInOut({this.cancelAction, this.confirmAction});
+
+  @override
+  Widget build(BuildContext context) {
+    return Container(
+      width: 283,
+      height: 320,
+      decoration: BoxDecoration(
+        color: Colors.white, // 设置背景颜色
+        borderRadius: BorderRadius.circular(15), // 设置圆角
+      ),
+      child: Column(
+        children: [
+          MyTextView(
+            "Sign Here".tr,
+            fontSize: 19,
+            isFontMedium: true,
+            textColor: ColorConstants.black,
+            marginTop: 15,
+            marginBottom: 12,
+          ),
+
+          Stack(
+            children: [
+              //签名
+              Center(
+                child: Container(
+                  width: 240,
+                  height: 200,
+                  color: Color(0XFFF0F0F0),
+                  child: HandSignature(
+                    control: handSignatureControl,
+                    color: ColorConstants.black404A5B,
+                    width: 1.0,
+                    maxWidth: 3.5,
+                    type: SignatureDrawType.shape,
+                  ),
+                ),
+              ),
+
+              //清除签名
+              Align(
+                alignment: Alignment.bottomLeft,
+                child: MyTextView(
+                  "Clean".tr,
+                  fontSize: 12,
+                  textColor: ColorConstants.white,
+                  cornerRadius: 10.37,
+                  backgroundColor: Color(0XFFFFBB1B),
+                  paddingTop: 4,
+                  paddingBottom: 4,
+                  paddingLeft: 11,
+                  paddingRight: 11,
+                  margin: 10,
+                  onClick: () {
+                    handSignatureControl.clear();
+                  },
+                ),
+              ),
+            ],
+          ).constrained(
+            width: 240,
+            height: 200,
+          ),
+
+          Container(
+            color: Color(0XFFCECECE),
+            height: 0.5,
+            margin: EdgeInsets.only(top: 18),
+          ),
+
+          //Buttons
+          Row(
+            children: [
+              Expanded(
+                  flex: 1,
+                  child: InkWell(
+                    onTap: () {
+                      onCancel();
+                      cancelAction?.call();
+                    },
+                    child: MyTextView(
+                      "Cancel".tr,
+                      fontSize: 17.5,
+                      isFontMedium: true,
+                      textAlign: TextAlign.center,
+                      textColor: Color(0XFF0085C4),
+                      cornerRadius: 3,
+                      borderWidth: 1,
+                    ),
+                  )),
+              Container(
+                color: Color(0XFFCECECE),
+                width: 0.5,
+              ),
+              Expanded(
+                  flex: 1,
+                  child: InkWell(
+                    onTap: () async {
+                      //签名数据
+                      var byteData = await handSignatureControl.toImage(
+                        format: ImageByteFormat.png,
+                        border: 0,
+                        width: 240,
+                        height: 200,
+                        background: Colors.white,
+                      ) as ByteData;
+
+                      onCancel();
+                      confirmAction?.call(byteData);
+                    },
+                    child: MyTextView(
+                      "Confirm".tr,
+                      marginLeft: 10,
+                      fontSize: 17.5,
+                      isFontMedium: true,
+                      textAlign: TextAlign.center,
+                      textColor: Color(0XFF0085C4),
+                      cornerRadius: 3,
+                    ),
+                  )),
+            ],
+          ).expanded(),
+        ],
+      ),
+    );
+  }
+
+  //取消弹框
+  void onCancel() async {
+    SmartDialog.dismiss();
+  }
+}

+ 7 - 6
packages/cs_domain/lib/repository/job_repository.dart

@@ -1,3 +1,5 @@
+import 'dart:typed_data';
+
 import 'package:get/get.dart';
 import 'package:plugin_platform/dio_export.dart';
 import 'package:plugin_platform/http/http_provider.dart';
@@ -57,7 +59,7 @@ class JobRepository extends GetxService {
   Future<HttpResult<CheckSuccessEntity>> submitCheckInOut(
     String? token,
     String? appliedId,
-    String? path, {
+    ByteData? byteData, {
     bool isCheckIn = false,
     CancelToken? cancelToken,
   }) async {
@@ -67,16 +69,16 @@ class JobRepository extends GetxService {
     params['applied_id'] = appliedId ?? "";
     params['check_type'] = isCheckIn ? "1" : "2";
 
-    Map<String, String> paths = {};
-    if (!Utils.isEmpty(path)) {
-      paths["capture"] = path!;
+    Map<String, Uint8List> streams = {};
+    if (byteData != null) {
+      streams["capture"] = byteData.buffer.asUint8List();
     }
 
     final result = await httpProvider.requestNetResult(
       method: HttpMethod.POST,
       ApiConstants.apiSignInOut,
       params: params,
-      paths: paths,
+      pathStreams: streams,
       networkDebounce: true,
       isShowLoadingDialog: true,
       cancelToken: cancelToken,
@@ -91,5 +93,4 @@ class JobRepository extends GetxService {
     }
     return result.convert<CheckSuccessEntity>();
   }
-
 }

+ 3 - 1
packages/cs_resources/lib/local/language/en_US.dart

@@ -18,7 +18,9 @@ const Map<String, String> en_US = {
   'Start Date': 'Start Date',
   'End Date': 'End Date',
   'Cancel': 'Cancel',
-  'Conform': 'Conform',
+  'Confirm': 'Confirm',
+  'Sign Here': 'Sign Here',
+  'Clean': 'Clean',
 
 
   'Pull to refresh': 'Pull to refresh',

+ 4 - 1
packages/cs_resources/lib/local/language/zh_CN.dart

@@ -18,7 +18,10 @@ const Map<String, String> zh_CN = {
   'Start Date': '开始日期',
   'End Date': '结束日期',
   'Cancel': '取消',
-  'Conform': '确认',
+  'Confirm': '确认',
+  'Sign Here': '请在此签名',
+  'Clean': '清除',
+
 
   'Pull to refresh': '下拉刷新',
   'Release ready': '释放刷新',

+ 2 - 2
packages/cs_widgets/lib/dialog/app_default_dialog.dart

@@ -99,7 +99,7 @@ class AppDefaultDialog extends StatelessWidget {
                           cancelAction?.call();
                         },
                         child: MyTextView(
-                          cancelText ?? "取消".tr,
+                          cancelText ?? "Cancel".tr,
                           marginLeft: 20,
                           marginBottom: 35,
                           paddingTop: 10,
@@ -121,7 +121,7 @@ class AppDefaultDialog extends StatelessWidget {
                           confirmAction?.call();
                         },
                         child: MyTextView(
-                          confirmText ?? "确定".tr,
+                          confirmText ?? "Confirm".tr,
                           marginLeft: 10,
                           paddingTop: 10,
                           paddingBottom: 10,

+ 1 - 1
packages/cs_widgets/lib/picker/date_picker_util.dart

@@ -60,7 +60,7 @@ class DatePickerUtil {
                   ),
                   CupertinoButton(
                     child: Text(
-                      'Conform'.tr,
+                      'Confirm'.tr,
                       style: TextStyle(
                         fontSize: 17,
                         fontWeight: FontWeight.w500,

+ 1 - 1
packages/cs_widgets/lib/widget_export.dart

@@ -5,4 +5,4 @@ export 'package:sticky_headers/sticky_headers.dart';
 export 'package:easy_refresh/easy_refresh.dart';
 export 'package:flutter_html/flutter_html.dart';
 export 'package:webview_flutter/webview_flutter.dart';
-
+export 'package:hand_signature/signature.dart';

+ 3 - 0
packages/cs_widgets/pubspec.yaml

@@ -60,5 +60,8 @@ dependencies:
   # 带缓存的网络图片加载
   extended_image: 8.2.0
 
+  #手写签名 https://pub.dev/packages/hand_signature
+  hand_signature: ^3.0.2
+
 flutter:
   uses-material-design: true