liukai пре 2 месеци
родитељ
комит
3c6c2055b6

+ 3 - 1
packages/cpt_uk/lib/modules/job/labour_request_add/labour_request_add_controller.dart

@@ -244,7 +244,9 @@ class LabourRequestAddController extends GetxController {
 
   //选择时间段
   void pickDateRange() {
-    DialogEngine.show(widget: DateRangePickerDialog(
+    DialogEngine.show(
+        widget: DateRangePickerDialog(
+      dateRange: state.repeatDateStr,
       confirmAction: (dateStr) {
         Log.d("选择的时间段:$dateStr");
         state.repeatDateStr = dateStr;

+ 29 - 15
packages/cpt_uk/lib/modules/job/labour_request_add/labour_request_add_page.dart

@@ -344,7 +344,7 @@ class _LabourRequestAddState extends BaseState<UKLabourRequestAddPage, LabourReq
                       //重复的日期区间
                       Visibility(
                         visible: state.pageType == 0,
-                        child:  Container(
+                        child: Container(
                           padding: const EdgeInsets.only(left: 16, right: 10, top: 5, bottom: 5),
                           margin: const EdgeInsets.only(top: 10),
                           decoration: BoxDecoration(
@@ -362,21 +362,35 @@ class _LabourRequestAddState extends BaseState<UKLabourRequestAddPage, LabourReq
                                   spacing: 8.0, // 子组件之间的水平间距
                                   runSpacing: 5.0, // 子组件之间的垂直间距
                                   children: state.repeatDateStr == null
-                                      ? []
+                                      ? [
+                                          MyTextView(
+                                            "",
+                                            textColor: Colors.white,
+                                            isFontRegular: true,
+                                            fontSize: 14,
+                                            hint: "Choose Repeat Date".tr,
+                                            textHintColor: ColorConstants.textGrayAECAE5,
+                                            paddingTop: 5,
+                                            paddingBottom: 5,
+                                            paddingLeft: 7.5,
+                                            paddingRight: 7.5,
+                                          )
+                                        ]
                                       : List.generate(state.repeatDateStr!.split(",").length, (index) {
-                                    return MyTextView(
-                                      state.repeatDateStr!.split(",")[index],
-                                      textColor: Colors.white,
-                                      isFontRegular: true,
-                                      fontSize: 14,
-                                      backgroundColor: ColorConstants.string2Color('#0AC074'),
-                                      paddingTop: 5,
-                                      paddingBottom: 5,
-                                      paddingLeft: 7.5,
-                                      paddingRight: 7.5,
-                                      cornerRadius: 5.0,
-                                    );
-                                  }),
+                                          return MyTextView(
+                                            state.repeatDateStr!.split(",")[index],
+                                            textColor: Colors.white,
+                                            isFontRegular: true,
+                                            fontSize: 14,
+                                            hint: "Choose Repeat Date".tr,
+                                            backgroundColor: ColorConstants.string2Color('#0AC074'),
+                                            paddingTop: 5,
+                                            paddingBottom: 5,
+                                            paddingLeft: 7.5,
+                                            paddingRight: 7.5,
+                                            cornerRadius: 5.0,
+                                          );
+                                        }),
                                 ),
                               ),
 

+ 16 - 2
packages/cpt_uk/lib/widget/date_range_picker_dialog.dart

@@ -14,10 +14,12 @@ import 'package:widgets/widget_export.dart';
 class DateRangePickerDialog extends StatefulWidget {
   final void Function(String) confirmAction; // 回调确认的时间区间
   final VoidCallback? cancelAction;
+  final String? dateRange; // 时间区间参数
 
   DateRangePickerDialog({
     required this.confirmAction,
     this.cancelAction,
+    this.dateRange, // 接收时间区间
   });
 
   @override
@@ -29,6 +31,19 @@ class _DateRangePickerDialogState extends State<DateRangePickerDialog> {
   DateTime? endDate;
 
   @override
+  void initState() {
+    super.initState();
+    // 如果 dateRange 不为空,则解析并设置开始和结束日期
+    if (widget.dateRange != null && widget.dateRange!.isNotEmpty) {
+      List<String> dates = widget.dateRange!.split(',');
+      if (dates.length >= 2) {
+        startDate = DateTime.parse(dates[0]);
+        endDate = DateTime.parse(dates[dates.length - 1]);
+      }
+    }
+  }
+
+  @override
   Widget build(BuildContext context) {
     return Column(
       crossAxisAlignment: CrossAxisAlignment.center,
@@ -160,11 +175,10 @@ class _DateRangePickerDialogState extends State<DateRangePickerDialog> {
                       flex: 1,
                       child: InkWell(
                         onTap: () async {
-
                           if (startDate != null && endDate != null) {
                             if (endDate!.isBefore(startDate!.add(const Duration(hours: 6)))) {
                               ToastEngine.show("End date must be greater than start date");
-                            }else{
+                            } else {
                               onCancel();
                               // 确保开始日期和结束日期都已选择
                               String dateRange = _getDateRange(startDate!, endDate!);

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

@@ -303,6 +303,7 @@ const Map<String, String> en_US = {
   'Copy': 'Copy',
   'Amount': 'Amount',
   'Repeat Date': 'Repeat Date',
+  'Choose Repeat Date': 'Choose Repeat Date',
 
   //插件的国际化
   'Pull to refresh': 'Pull to refresh',

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

@@ -303,6 +303,7 @@ const Map<String, String> zh_CN = {
   'Copy': '复制',
   'Amount': '金额',
   'Repeat Date': '重复日期',
+  'Choose Repeat Date': '选择重复日期',
 
   //插件的国际化
   'Pull to refresh': '下拉刷新',