|
@@ -0,0 +1,427 @@
|
|
|
+import 'dart:ui';
|
|
|
+
|
|
|
+import 'package:cs_resources/generated/assets.dart';
|
|
|
+import 'package:domain/entity/response/t_h_applied_employee_entity.dart';
|
|
|
+import 'package:domain/entity/response/t_h_o_a_labour_table_entity.dart';
|
|
|
+import 'package:domain/entity/response/t_h_pre_selected_staff_table_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:shared/utils/date_time_utils.dart';
|
|
|
+import 'package:widgets/ext/ex_widget.dart';
|
|
|
+import 'package:cs_resources/constants/color_constants.dart';
|
|
|
+import 'package:widgets/load_state_layout.dart';
|
|
|
+import 'package:widgets/my_button.dart';
|
|
|
+import 'package:widgets/my_load_image.dart';
|
|
|
+import 'package:widgets/my_text_view.dart';
|
|
|
+import 'package:widgets/search_app_bar.dart';
|
|
|
+import 'package:widgets/widget_export.dart';
|
|
|
+
|
|
|
+import 'pre_add_request_controller.dart';
|
|
|
+
|
|
|
+/*
|
|
|
+ * 添加多个用工请求的选择弹窗
|
|
|
+ */
|
|
|
+class PreAddRequestDialog extends StatefulWidget {
|
|
|
+ void Function(String selectIds)? confirmAction;
|
|
|
+
|
|
|
+ PreAddRequestDialog({this.confirmAction});
|
|
|
+
|
|
|
+ @override
|
|
|
+ State<PreAddRequestDialog> createState() => _AppliedAddStaffState();
|
|
|
+}
|
|
|
+
|
|
|
+class _AppliedAddStaffState extends State<PreAddRequestDialog> {
|
|
|
+ @override
|
|
|
+ void initState() {
|
|
|
+ super.initState();
|
|
|
+ Get.put(PreAddRequestController());
|
|
|
+ }
|
|
|
+
|
|
|
+ @override
|
|
|
+ void dispose() {
|
|
|
+ super.dispose();
|
|
|
+ Get.delete<PreAddRequestController>();
|
|
|
+ }
|
|
|
+
|
|
|
+ @override
|
|
|
+ Widget build(BuildContext context) {
|
|
|
+ return GetBuilder<PreAddRequestController>(
|
|
|
+ assignId: true,
|
|
|
+ builder: (controller) {
|
|
|
+ return Container(
|
|
|
+ width: 300,
|
|
|
+ height: 600,
|
|
|
+ decoration: const BoxDecoration(
|
|
|
+ color: Color(0XFFF7F7F7),
|
|
|
+ borderRadius: BorderRadius.all(Radius.circular(15)),
|
|
|
+ ),
|
|
|
+ child: Column(
|
|
|
+ crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
+ children: [
|
|
|
+ Center(
|
|
|
+ child: MyTextView(
|
|
|
+ "Choose Request".tr,
|
|
|
+ fontSize: 19,
|
|
|
+ isFontMedium: true,
|
|
|
+ textColor: ColorConstants.black,
|
|
|
+ marginTop: 22,
|
|
|
+ marginBottom: 15,
|
|
|
+ marginLeft: 22,
|
|
|
+ marginRight: 22,
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+
|
|
|
+ MyTextView(
|
|
|
+ "Outlet".tr,
|
|
|
+ fontSize: 13,
|
|
|
+ marginLeft: 15,
|
|
|
+ isFontRegular: true,
|
|
|
+ textColor: ColorConstants.black33,
|
|
|
+ ),
|
|
|
+
|
|
|
+ Row(
|
|
|
+ children: [
|
|
|
+ MyTextView(
|
|
|
+ controller.selectedDepartmentName ?? "",
|
|
|
+ hint: 'Outlet'.tr,
|
|
|
+ textHintColor: ColorConstants.textBlackHint,
|
|
|
+ fontSize: 13,
|
|
|
+ isFontRegular: true,
|
|
|
+ textColor: ColorConstants.black33,
|
|
|
+ ).expanded(),
|
|
|
+ const MyAssetImage(Assets.baseServiceTriangleDropDownIcon, width: 11.5, height: 6)
|
|
|
+ ],
|
|
|
+ )
|
|
|
+ .constrained(height: 32)
|
|
|
+ .paddingOnly(left: 15, right: 12)
|
|
|
+ .decorated(
|
|
|
+ color: hexToColor("#ECECEC"),
|
|
|
+ borderRadius: const BorderRadius.all(Radius.circular(5)),
|
|
|
+ )
|
|
|
+ .onTap(controller.pickerOutlet)
|
|
|
+ .marginOnly(left: 15, right: 15, top: 8),
|
|
|
+
|
|
|
+ Row(
|
|
|
+ children: [
|
|
|
+ Column(
|
|
|
+ crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
+ children: [
|
|
|
+ MyTextView(
|
|
|
+ "Start Date".tr,
|
|
|
+ fontSize: 13,
|
|
|
+ marginLeft: 15,
|
|
|
+ marginTop: 8,
|
|
|
+ isFontRegular: true,
|
|
|
+ textColor: ColorConstants.black33,
|
|
|
+ ),
|
|
|
+ Row(
|
|
|
+ children: [
|
|
|
+ MyTextView(
|
|
|
+ controller.selectedStartDate == null ? '' : DateTimeUtils.formatDate(controller.selectedStartDate, format: "yyyy-MM-dd"),
|
|
|
+ hint: 'Start Date'.tr,
|
|
|
+ textHintColor: ColorConstants.textBlackHint,
|
|
|
+ fontSize: 13,
|
|
|
+ isFontRegular: true,
|
|
|
+ textColor: ColorConstants.black33,
|
|
|
+ ).expanded(),
|
|
|
+ const MyAssetImage(Assets.baseServiceTriangleDropDownIcon, width: 11.5, height: 6)
|
|
|
+ ],
|
|
|
+ )
|
|
|
+ .constrained(height: 32)
|
|
|
+ .paddingOnly(left: 15, right: 9)
|
|
|
+ .decorated(
|
|
|
+ color: hexToColor("#ECECEC"),
|
|
|
+ borderRadius: const BorderRadius.all(Radius.circular(5)),
|
|
|
+ )
|
|
|
+ .onTap(controller.pickerStartDate)
|
|
|
+ .marginOnly(left: 15, top: 8),
|
|
|
+ ],
|
|
|
+ ).expanded(),
|
|
|
+ Column(
|
|
|
+ crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
+ children: [
|
|
|
+ MyTextView(
|
|
|
+ "End Date".tr,
|
|
|
+ fontSize: 13,
|
|
|
+ marginLeft: 15,
|
|
|
+ marginTop: 8,
|
|
|
+ isFontRegular: true,
|
|
|
+ textColor: ColorConstants.black33,
|
|
|
+ ),
|
|
|
+ Row(
|
|
|
+ children: [
|
|
|
+ MyTextView(
|
|
|
+ controller.selectedEndDate == null ? '' : DateTimeUtils.formatDate(controller.selectedEndDate, format: "yyyy-MM-dd"),
|
|
|
+ hint: 'End Date'.tr,
|
|
|
+ textHintColor: ColorConstants.textBlackHint,
|
|
|
+ fontSize: 13,
|
|
|
+ isFontRegular: true,
|
|
|
+ textColor: ColorConstants.black33,
|
|
|
+ ).expanded(),
|
|
|
+ const MyAssetImage(Assets.baseServiceTriangleDropDownIcon, width: 11.5, height: 6)
|
|
|
+ ],
|
|
|
+ )
|
|
|
+ .constrained(height: 32)
|
|
|
+ .paddingOnly(left: 15, right: 9)
|
|
|
+ .decorated(
|
|
|
+ color: hexToColor("#ECECEC"),
|
|
|
+ borderRadius: const BorderRadius.all(Radius.circular(5)),
|
|
|
+ )
|
|
|
+ .onTap(controller.pickerEndDate)
|
|
|
+ .marginOnly(left: 15, top: 8),
|
|
|
+ ],
|
|
|
+ ).expanded(),
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+
|
|
|
+ MyButton(
|
|
|
+ type: ClickType.throttle,
|
|
|
+ milliseconds: 500,
|
|
|
+ onPressed: () {
|
|
|
+ FocusScope.of(context).unfocus();
|
|
|
+ controller.doSearch();
|
|
|
+ },
|
|
|
+ text: "Submit".tr,
|
|
|
+ textColor: ColorConstants.white,
|
|
|
+ fontSize: 13,
|
|
|
+ minHeight: 32,
|
|
|
+ radius: 5,
|
|
|
+ backgroundColor: hexToColor("#4AA3FF"),
|
|
|
+ fontWeight: FontWeight.w400,
|
|
|
+ ).marginOnly(left: 15, right: 15, top: 2, bottom: 2),
|
|
|
+
|
|
|
+ Container(
|
|
|
+ color: Colors.white,
|
|
|
+ child: EasyRefresh(
|
|
|
+ header: ClassicHeader(
|
|
|
+ dragText: 'Pull to refresh'.tr,
|
|
|
+ armedText: 'Release ready'.tr,
|
|
|
+ readyText: 'Refreshing...'.tr,
|
|
|
+ processingText: 'Refreshing...'.tr,
|
|
|
+ processedText: 'Succeeded'.tr,
|
|
|
+ noMoreText: 'No more'.tr,
|
|
|
+ failedText: 'Failed'.tr,
|
|
|
+ messageText: 'Last updated at %T'.tr,
|
|
|
+ textStyle: const TextStyle(color: ColorConstants.black66, fontSize: 14),
|
|
|
+ messageStyle: const TextStyle(color: ColorConstants.black66, fontSize: 12),
|
|
|
+ iconTheme: const IconThemeData(color: ColorConstants.black66),
|
|
|
+ backgroundColor: Colors.transparent,
|
|
|
+ ),
|
|
|
+ footer: ClassicFooter(
|
|
|
+ dragText: 'Pull to load'.tr,
|
|
|
+ armedText: 'Release ready'.tr,
|
|
|
+ readyText: 'Loading...'.tr,
|
|
|
+ processingText: 'Loading...'.tr,
|
|
|
+ processedText: 'Succeeded'.tr,
|
|
|
+ noMoreText: 'No more'.tr,
|
|
|
+ failedText: 'Failed'.tr,
|
|
|
+ showMessage: false,
|
|
|
+ triggerOffset: 50,
|
|
|
+ iconDimension: 22,
|
|
|
+ textStyle: const TextStyle(color: ColorConstants.black66, fontSize: 14),
|
|
|
+ messageStyle: const TextStyle(color: ColorConstants.black66, fontSize: 12),
|
|
|
+ iconTheme: const IconThemeData(color: ColorConstants.black66),
|
|
|
+ backgroundColor: Colors.transparent,
|
|
|
+ ),
|
|
|
+ controller: controller.refreshController,
|
|
|
+ onRefresh: controller.onRefresh,
|
|
|
+ onLoad: controller.loadMore,
|
|
|
+ child: LoadStateLayout(
|
|
|
+ themeColor: ColorConstants.black66,
|
|
|
+ state: controller.loadingState,
|
|
|
+ errorMessage: controller.errorMessage,
|
|
|
+ errorRetry: () {
|
|
|
+ controller.retryRequest();
|
|
|
+ },
|
|
|
+ successSliverWidget: [
|
|
|
+ SliverList(
|
|
|
+ delegate: SliverChildBuilderDelegate(
|
|
|
+ (context, index) {
|
|
|
+ return _buildStaffItem(controller.datas[index], () {
|
|
|
+ /// Item选中与未选中设置
|
|
|
+ controller.datas[index].isSelected = !controller.datas[index].isSelected;
|
|
|
+ controller.update();
|
|
|
+ });
|
|
|
+ },
|
|
|
+ childCount: controller.datas.length,
|
|
|
+ ))
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ ).paddingZero,
|
|
|
+ ).expanded(),
|
|
|
+
|
|
|
+ //按钮组
|
|
|
+ Row(
|
|
|
+ children: [
|
|
|
+ //取消按钮
|
|
|
+ Expanded(
|
|
|
+ flex: 1,
|
|
|
+ child: InkWell(
|
|
|
+ onTap: () {
|
|
|
+ onCancel();
|
|
|
+ },
|
|
|
+ child: MyTextView(
|
|
|
+ "Cancel".tr,
|
|
|
+ fontSize: 17.5,
|
|
|
+ isFontMedium: true,
|
|
|
+ textAlign: TextAlign.center,
|
|
|
+ textColor: const Color(0XFF0085C4),
|
|
|
+ cornerRadius: 3,
|
|
|
+ borderWidth: 1,
|
|
|
+ ),
|
|
|
+ )),
|
|
|
+
|
|
|
+ //垂直分割线
|
|
|
+ Container(
|
|
|
+ color: const Color(0xff09141F).withOpacity(0.13),
|
|
|
+ width: 0.5,
|
|
|
+ ),
|
|
|
+
|
|
|
+ //同意按钮
|
|
|
+ Expanded(
|
|
|
+ flex: 1,
|
|
|
+ child: InkWell(
|
|
|
+ onTap: () {
|
|
|
+ doCallbackAction(controller);
|
|
|
+ },
|
|
|
+ child: MyTextView(
|
|
|
+ "Submit".tr,
|
|
|
+ marginLeft: 10,
|
|
|
+ fontSize: 17.5,
|
|
|
+ isFontMedium: true,
|
|
|
+ textAlign: TextAlign.center,
|
|
|
+ textColor: Color(0XFF0085C4),
|
|
|
+ cornerRadius: 3,
|
|
|
+ ),
|
|
|
+ )),
|
|
|
+ ],
|
|
|
+ ).constrained(height: 46),
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ );
|
|
|
+ },
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ //取消弹框
|
|
|
+ void onCancel() async {
|
|
|
+ SmartDialog.dismiss();
|
|
|
+ }
|
|
|
+
|
|
|
+ //执行回调
|
|
|
+ void doCallbackAction(PreAddRequestController controller) {
|
|
|
+ onCancel();
|
|
|
+
|
|
|
+ //找到当前选中的
|
|
|
+ var selectedList = controller.datas.where((element) => element.isSelected).toList(growable: false);
|
|
|
+ if (selectedList.isNotEmpty) {
|
|
|
+ var ids = selectedList.map((e) => e.id.toString()).toList(growable: false);
|
|
|
+ String separatedIds = ids.join(',');
|
|
|
+
|
|
|
+ widget.confirmAction?.call(separatedIds);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ Widget _buildStaffItem(THOALabourTableRows item, VoidCallback callback) {
|
|
|
+ return Stack(
|
|
|
+ children: [
|
|
|
+ Column(
|
|
|
+ children: [
|
|
|
+ //时间
|
|
|
+ Row(
|
|
|
+ children: [
|
|
|
+ MyTextView(
|
|
|
+ "Job Time:",
|
|
|
+ textColor: ColorConstants.black66,
|
|
|
+ fontSize: 13,
|
|
|
+ marginRight: 3,
|
|
|
+ isFontRegular: true,
|
|
|
+ ),
|
|
|
+ MyTextView(
|
|
|
+ "${item.jobDate} ${item.startTime} ~ ${item.endTime}}",
|
|
|
+ textColor: ColorConstants.black,
|
|
|
+ fontSize: 13,
|
|
|
+ isFontRegular: true,
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+
|
|
|
+ //部门
|
|
|
+ Row(
|
|
|
+ children: [
|
|
|
+ MyTextView(
|
|
|
+ "Outlet:",
|
|
|
+ marginRight: 3,
|
|
|
+ textColor: ColorConstants.black66,
|
|
|
+ fontSize: 13,
|
|
|
+ isFontRegular: true,
|
|
|
+ ),
|
|
|
+ MyTextView(
|
|
|
+ item.outletName ?? "-",
|
|
|
+ textColor: ColorConstants.black,
|
|
|
+ fontSize: 13,
|
|
|
+ isFontRegular: true,
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ ).marginOnly(top: 5),
|
|
|
+
|
|
|
+ //标题
|
|
|
+ Row(
|
|
|
+ children: [
|
|
|
+ MyTextView(
|
|
|
+ "Job Title:",
|
|
|
+ marginRight: 3,
|
|
|
+ textColor: ColorConstants.black66,
|
|
|
+ fontSize: 13,
|
|
|
+ isFontRegular: true,
|
|
|
+ ),
|
|
|
+ MyTextView(
|
|
|
+ item.jobTitle ?? "-",
|
|
|
+ textColor: ColorConstants.black,
|
|
|
+ fontSize: 13,
|
|
|
+ isFontRegular: true,
|
|
|
+ ).expanded(),
|
|
|
+ ],
|
|
|
+ ).marginOnly(top: 5),
|
|
|
+
|
|
|
+ //状态
|
|
|
+ Row(
|
|
|
+ children: [
|
|
|
+ MyTextView(
|
|
|
+ "Status:",
|
|
|
+ marginRight: 3,
|
|
|
+ textColor: ColorConstants.black66,
|
|
|
+ fontSize: 13,
|
|
|
+ isFontRegular: true,
|
|
|
+ ),
|
|
|
+ MyTextView(
|
|
|
+ item.statusShow ?? "-",
|
|
|
+ textColor: ColorConstants.black,
|
|
|
+ fontSize: 13,
|
|
|
+ isFontRegular: true,
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ ).marginOnly(top: 5),
|
|
|
+
|
|
|
+ Container(
|
|
|
+ margin: const EdgeInsets.only(top: 19),
|
|
|
+ width: double.infinity,
|
|
|
+ height: 1,
|
|
|
+ color: const Color(0XFFF7F7F7),
|
|
|
+ )
|
|
|
+ ],
|
|
|
+ ).paddingOnly(left: 19, right: 20, top: 17),
|
|
|
+
|
|
|
+ //是否勾选
|
|
|
+ MyAssetImage(
|
|
|
+ item.isSelected ? Assets.baseServiceItemSelectedIcon : Assets.baseServiceItemUnselectedGrayIcon,
|
|
|
+ width: 20.5,
|
|
|
+ height: 20.5,
|
|
|
+ ).alignRight().marginOnly(right: 20, top: 17.5),
|
|
|
+ ],
|
|
|
+ ).onTap(callback);
|
|
|
+ }
|
|
|
+}
|