|
@@ -0,0 +1,346 @@
|
|
|
|
+import 'dart:typed_data';
|
|
|
|
+import 'dart:ui';
|
|
|
|
+import 'package:cs_resources/generated/assets.dart';
|
|
|
|
+import 'package:domain/entity/response/labour_request_index_entity.dart';
|
|
|
|
+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:plugin_platform/engine/toast/toast_engine.dart';
|
|
|
|
+import 'package:shared/utils/date_time_utils.dart';
|
|
|
|
+import 'package:shared/utils/screen_util.dart';
|
|
|
|
+import 'package:widgets/ext/ex_widget.dart';
|
|
|
|
+import 'package:cs_resources/constants/color_constants.dart';
|
|
|
|
+import 'package:widgets/my_button.dart';
|
|
|
|
+import 'package:widgets/my_load_image.dart';
|
|
|
|
+import 'package:widgets/my_text_view.dart';
|
|
|
|
+import 'package:widgets/picker/date_picker_util.dart';
|
|
|
|
+import 'package:widgets/picker/option_pick_util.dart';
|
|
|
|
+import 'package:widgets/widget_export.dart';
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * 用工请求列表的筛选
|
|
|
|
+ */
|
|
|
|
+class LabourRequestFilter extends StatefulWidget {
|
|
|
|
+ VoidCallback? onResetAction;
|
|
|
|
+ void Function(DateTime? selectedStartDate, DateTime? selectedEndDate, String? selectedStatusId, String? selectedDepartmentId)? onFilterAction;
|
|
|
|
+ LabourRequestIndexEntity optionResult;
|
|
|
|
+ DateTime? selectedStartDate;
|
|
|
|
+ DateTime? selectedEndDate;
|
|
|
|
+ String? selectedStatusId;
|
|
|
|
+ String? selectedDepartmentId;
|
|
|
|
+
|
|
|
|
+ LabourRequestFilter({
|
|
|
|
+ required this.optionResult,
|
|
|
|
+ required this.selectedStartDate,
|
|
|
|
+ required this.selectedEndDate,
|
|
|
|
+ required this.selectedStatusId,
|
|
|
|
+ required this.selectedDepartmentId,
|
|
|
|
+ this.onResetAction,
|
|
|
|
+ this.onFilterAction,
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ @override
|
|
|
|
+ State<LabourRequestFilter> createState() => _LabourRequestFilterState();
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+class _LabourRequestFilterState extends State<LabourRequestFilter> {
|
|
|
|
+ DateTime? selectedStartDate;
|
|
|
|
+ DateTime? selectedEndDate;
|
|
|
|
+ String? selectedStatusId;
|
|
|
|
+ String? selectedDepartmentId;
|
|
|
|
+
|
|
|
|
+ @override
|
|
|
|
+ void initState() {
|
|
|
|
+ super.initState();
|
|
|
|
+ this.selectedStartDate = widget.selectedStartDate;
|
|
|
|
+ this.selectedEndDate = widget.selectedEndDate;
|
|
|
|
+ this.selectedStatusId = widget.selectedStatusId;
|
|
|
|
+ this.selectedDepartmentId = widget.selectedDepartmentId;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @override
|
|
|
|
+ Widget build(BuildContext context) {
|
|
|
|
+ return Column(
|
|
|
|
+ crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
+ mainAxisAlignment: MainAxisAlignment.start,
|
|
|
|
+ children: [
|
|
|
|
+ SizedBox(
|
|
|
|
+ height: kToolbarHeight + ScreenUtil.getStatusBarH(context) + 1,
|
|
|
|
+ ),
|
|
|
|
+ Container(
|
|
|
|
+ padding: EdgeInsets.only(left: 15, right: 15, top: 17.5, bottom: 20),
|
|
|
|
+ width: double.infinity,
|
|
|
|
+ decoration: BoxDecoration(
|
|
|
|
+ color: Colors.white,
|
|
|
|
+ ),
|
|
|
|
+ child: Column(
|
|
|
|
+ crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
+ children: [
|
|
|
|
+ //部门
|
|
|
|
+ MyTextView(
|
|
|
|
+ "Outlet".tr,
|
|
|
|
+ fontSize: 14,
|
|
|
|
+ isFontMedium: true,
|
|
|
|
+ textColor: ColorConstants.black33,
|
|
|
|
+ ),
|
|
|
|
+
|
|
|
|
+ //选择部门
|
|
|
|
+ Container(
|
|
|
|
+ padding: EdgeInsets.only(left: 16, right: 10),
|
|
|
|
+ margin: EdgeInsets.only(top: 10),
|
|
|
|
+ height: 45,
|
|
|
|
+ decoration: BoxDecoration(
|
|
|
|
+ color: ColorConstants.grayECECEC,
|
|
|
|
+ borderRadius: const BorderRadius.all(Radius.circular(5)),
|
|
|
|
+ ),
|
|
|
|
+ child: Row(
|
|
|
|
+ mainAxisSize: MainAxisSize.max,
|
|
|
|
+ crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
+ mainAxisAlignment: MainAxisAlignment.start,
|
|
|
|
+ children: [
|
|
|
|
+ MyTextView(
|
|
|
|
+ selectedDepartmentId == null
|
|
|
|
+ ? "Outlet".tr
|
|
|
|
+ : widget.optionResult.departmentList!.firstWhere((element) => element.value.toString() == selectedDepartmentId).txt!,
|
|
|
|
+ fontSize: 14,
|
|
|
|
+ isFontMedium: true,
|
|
|
|
+ textColor: ColorConstants.black33,
|
|
|
|
+ ).expanded(),
|
|
|
|
+ MyAssetImage(Assets.baseServiceTriangleDropDownIcon, width: 11.5, height: 6.28),
|
|
|
|
+ ],
|
|
|
|
+ ),
|
|
|
|
+ ).onTap(() {
|
|
|
|
+ pickerOutlet();
|
|
|
|
+ }),
|
|
|
|
+
|
|
|
|
+ //状态
|
|
|
|
+ MyTextView(
|
|
|
|
+ "Status".tr,
|
|
|
|
+ fontSize: 14,
|
|
|
|
+ isFontMedium: true,
|
|
|
|
+ marginTop: 11,
|
|
|
|
+ textColor: ColorConstants.black33,
|
|
|
|
+ ),
|
|
|
|
+
|
|
|
|
+ //选择状态
|
|
|
|
+ Container(
|
|
|
|
+ padding: EdgeInsets.only(left: 16, right: 10),
|
|
|
|
+ margin: EdgeInsets.only(top: 10),
|
|
|
|
+ height: 45,
|
|
|
|
+ decoration: BoxDecoration(
|
|
|
|
+ color: ColorConstants.grayECECEC,
|
|
|
|
+ borderRadius: const BorderRadius.all(Radius.circular(5)),
|
|
|
|
+ ),
|
|
|
|
+ child: Row(
|
|
|
|
+ mainAxisSize: MainAxisSize.max,
|
|
|
|
+ crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
+ mainAxisAlignment: MainAxisAlignment.start,
|
|
|
|
+ children: [
|
|
|
|
+ MyTextView(
|
|
|
|
+ selectedStatusId == null
|
|
|
|
+ ? "Status".tr
|
|
|
|
+ : widget.optionResult.statusList!.firstWhere((element) => element.value.toString() == selectedStatusId).txt!,
|
|
|
|
+ fontSize: 14,
|
|
|
|
+ isFontMedium: true,
|
|
|
|
+ textColor: ColorConstants.black33,
|
|
|
|
+ ).expanded(),
|
|
|
|
+ MyAssetImage(Assets.baseServiceTriangleDropDownIcon, width: 11.5, height: 6.28),
|
|
|
|
+ ],
|
|
|
|
+ ),
|
|
|
|
+ ).onTap(() {
|
|
|
|
+ pickerStatus();
|
|
|
|
+ }),
|
|
|
|
+
|
|
|
|
+ //开始时间
|
|
|
|
+ MyTextView(
|
|
|
|
+ "Start Date".tr,
|
|
|
|
+ fontSize: 14,
|
|
|
|
+ isFontMedium: true,
|
|
|
|
+ marginTop: 11,
|
|
|
|
+ textColor: ColorConstants.black33,
|
|
|
|
+ ),
|
|
|
|
+
|
|
|
|
+ //选择时间
|
|
|
|
+ Container(
|
|
|
|
+ padding: EdgeInsets.only(left: 16, right: 10),
|
|
|
|
+ margin: EdgeInsets.only(top: 10),
|
|
|
|
+ height: 45,
|
|
|
|
+ decoration: BoxDecoration(
|
|
|
|
+ color: ColorConstants.grayECECEC,
|
|
|
|
+ borderRadius: const BorderRadius.all(Radius.circular(5)),
|
|
|
|
+ ),
|
|
|
|
+ child: Row(
|
|
|
|
+ mainAxisSize: MainAxisSize.max,
|
|
|
|
+ crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
+ mainAxisAlignment: MainAxisAlignment.start,
|
|
|
|
+ children: [
|
|
|
|
+ MyTextView(
|
|
|
|
+ selectedStartDate == null ? "Start Date".tr : DateTimeUtils.formatDate(selectedStartDate, format: "yyyy-MM-dd"),
|
|
|
|
+ fontSize: 14,
|
|
|
|
+ isFontMedium: true,
|
|
|
|
+ textColor: ColorConstants.black33,
|
|
|
|
+ ).expanded(),
|
|
|
|
+ MyAssetImage(Assets.baseServiceTriangleDropDownIcon, width: 11.5, height: 6.28),
|
|
|
|
+ ],
|
|
|
|
+ ),
|
|
|
|
+ ).onTap(() {
|
|
|
|
+ pickerStartDate();
|
|
|
|
+ }),
|
|
|
|
+
|
|
|
|
+ //结束日期
|
|
|
|
+ MyTextView(
|
|
|
|
+ "End Date".tr,
|
|
|
|
+ fontSize: 14,
|
|
|
|
+ marginTop: 11,
|
|
|
|
+ isFontMedium: true,
|
|
|
|
+ textColor: ColorConstants.black33,
|
|
|
|
+ ),
|
|
|
|
+
|
|
|
|
+ //选择结束日期
|
|
|
|
+ Container(
|
|
|
|
+ padding: EdgeInsets.only(left: 16, right: 10),
|
|
|
|
+ margin: EdgeInsets.only(top: 10),
|
|
|
|
+ height: 45,
|
|
|
|
+ decoration: BoxDecoration(
|
|
|
|
+ color: ColorConstants.grayECECEC,
|
|
|
|
+ borderRadius: const BorderRadius.all(Radius.circular(5)),
|
|
|
|
+ ),
|
|
|
|
+ child: Row(
|
|
|
|
+ mainAxisSize: MainAxisSize.max,
|
|
|
|
+ crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
+ mainAxisAlignment: MainAxisAlignment.start,
|
|
|
|
+ children: [
|
|
|
|
+ MyTextView(
|
|
|
|
+ selectedEndDate == null ? "End Date".tr : DateTimeUtils.formatDate(selectedEndDate, format: "yyyy-MM-dd"),
|
|
|
|
+ fontSize: 14,
|
|
|
|
+ isFontMedium: true,
|
|
|
|
+ textColor: ColorConstants.black33,
|
|
|
|
+ ).expanded(),
|
|
|
|
+ MyAssetImage(Assets.baseServiceTriangleDropDownIcon, width: 11.5, height: 6.28),
|
|
|
|
+ ],
|
|
|
|
+ ),
|
|
|
|
+ ).onTap(() {
|
|
|
|
+ pickerEndDate();
|
|
|
|
+ }),
|
|
|
|
+
|
|
|
|
+ //按钮组
|
|
|
|
+ Row(
|
|
|
|
+ children: [
|
|
|
|
+ MyButton(
|
|
|
|
+ onPressed: () {
|
|
|
|
+ onCancel();
|
|
|
|
+ widget.onResetAction?.call();
|
|
|
|
+ },
|
|
|
|
+ text: "Reset".tr,
|
|
|
|
+ textColor: ColorConstants.white,
|
|
|
|
+ backgroundColor: hexToColor("#FFBB1B"),
|
|
|
|
+ radius: 17.25,
|
|
|
|
+ minWidth: 60,
|
|
|
|
+ minHeight: 36,
|
|
|
|
+ ).expanded(),
|
|
|
|
+ SizedBox(width: 15),
|
|
|
|
+ MyButton(
|
|
|
|
+ onPressed: () {
|
|
|
|
+ onCancel();
|
|
|
|
+ widget.onFilterAction?.call(selectedStartDate, selectedEndDate, selectedStatusId, selectedDepartmentId);
|
|
|
|
+ },
|
|
|
|
+ text: "Filter".tr,
|
|
|
|
+ textColor: ColorConstants.white,
|
|
|
|
+ backgroundColor: hexToColor("#0AC074"),
|
|
|
|
+ radius: 17.25,
|
|
|
|
+ minWidth: 60,
|
|
|
|
+ minHeight: 36,
|
|
|
|
+ ).expanded(),
|
|
|
|
+ ],
|
|
|
|
+ ).marginOnly(top: 20),
|
|
|
|
+ ],
|
|
|
|
+ ),
|
|
|
|
+ ),
|
|
|
|
+ Center(child: MyAssetImage(Assets.baseServiceDialogDeleteIcon, width: 26.5, height: 26.5).marginOnly(top: 35)).onTap(() {
|
|
|
|
+ onCancel();
|
|
|
|
+ }),
|
|
|
|
+ ],
|
|
|
|
+ );
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //取消弹框
|
|
|
|
+ void onCancel() async {
|
|
|
|
+ SmartDialog.dismiss();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /// 筛选开始日期
|
|
|
|
+ void pickerStartDate() {
|
|
|
|
+ DatePickerUtil.showCupertinoDatePicker(
|
|
|
|
+ selectedDateTime: selectedStartDate,
|
|
|
|
+ onDateTimeChanged: (date) {
|
|
|
|
+ setState(() {
|
|
|
|
+ selectedStartDate = date;
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+ title: "Start Date".tr,
|
|
|
|
+ );
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /// 筛选结束日期
|
|
|
|
+ void pickerEndDate() {
|
|
|
|
+ DatePickerUtil.showCupertinoDatePicker(
|
|
|
|
+ selectedDateTime: selectedEndDate,
|
|
|
|
+ onDateTimeChanged: (date) {
|
|
|
|
+ setState(() {
|
|
|
|
+ selectedEndDate = date;
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+ title: "End Date".tr,
|
|
|
|
+ );
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /// 筛选部门
|
|
|
|
+ void pickerOutlet() {
|
|
|
|
+ int selectedDepartmentIndex;
|
|
|
|
+ if (selectedDepartmentId == null){
|
|
|
|
+ selectedDepartmentIndex = 0;
|
|
|
|
+ }else{
|
|
|
|
+ selectedDepartmentIndex = widget.optionResult.departmentList!.indexWhere((department) => department.value.toString() == selectedDepartmentId);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (selectedDepartmentIndex <0){
|
|
|
|
+ selectedDepartmentIndex = 0;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ OptionPickerUtil.showCupertinoOptionPicker(
|
|
|
|
+ items: widget.optionResult.departmentList!.map((e) => e.txt!).toList(growable: false),
|
|
|
|
+ initialSelectIndex: selectedDepartmentIndex,
|
|
|
|
+ onPickerChanged: (_, index) {
|
|
|
|
+ setState(() {
|
|
|
|
+ selectedDepartmentId = widget.optionResult.departmentList![index].value!.toString();
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+ );
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /// 筛选状态
|
|
|
|
+ void pickerStatus() {
|
|
|
|
+ int selectedStatusIndex;
|
|
|
|
+ if (selectedStatusId == null){
|
|
|
|
+ selectedStatusIndex = 0;
|
|
|
|
+ }else{
|
|
|
|
+ selectedStatusIndex = widget.optionResult.statusList!.indexWhere((department) => department.value.toString() == selectedStatusId);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (selectedStatusIndex <0){
|
|
|
|
+ selectedStatusIndex = 0;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ OptionPickerUtil.showCupertinoOptionPicker(
|
|
|
|
+ items: widget.optionResult.statusList!.map((e) => e.txt!).toList(growable: false),
|
|
|
|
+ initialSelectIndex: selectedStatusIndex,
|
|
|
|
+ onPickerChanged: (_, index) {
|
|
|
|
+ setState(() {
|
|
|
|
+ selectedStatusId = widget.optionResult.statusList![index].value!.toString();
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+ );
|
|
|
|
+ }
|
|
|
|
+}
|