|
@@ -1,22 +1,34 @@
|
|
|
+import 'package:cs_resources/constants/color_constants.dart';
|
|
|
+import 'package:cs_resources/generated/assets.dart';
|
|
|
+import 'package:flutter/cupertino.dart';
|
|
|
import 'package:flutter/material.dart';
|
|
|
+import 'package:flutter/services.dart';
|
|
|
+import 'package:flutter/widgets.dart';
|
|
|
import 'package:get/get.dart';
|
|
|
import 'package:plugin_basic/base/base_state.dart';
|
|
|
import 'package:plugin_basic/base/base_stateful_page.dart';
|
|
|
import 'package:plugin_basic/utils/ext_get_nav.dart';
|
|
|
import 'package:router/path/router_path.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:widgets/my_appbar.dart';
|
|
|
+import 'package:widgets/my_button.dart';
|
|
|
+import 'package:widgets/my_load_image.dart';
|
|
|
+import 'package:widgets/my_text_view.dart';
|
|
|
+import 'package:widgets/no_shadow_scroll_behavior.dart';
|
|
|
+import 'package:widgets/shatter/form_require_text.dart';
|
|
|
+import 'package:widgets/shatter/round_my_text_field.dart';
|
|
|
|
|
|
import 'labour_request_add_controller.dart';
|
|
|
import 'labour_request_add_state.dart';
|
|
|
|
|
|
-
|
|
|
class LabourRequestAddPage extends BaseStatefulPage<LabourRequestAddController> {
|
|
|
LabourRequestAddPage({Key? key}) : super(key: key);
|
|
|
|
|
|
- //启动当前页面
|
|
|
- static void startInstance() {
|
|
|
- return Get.start(RouterPath.JOB_LABOUR_REQUEST_ADD);
|
|
|
+ //启动当前页面,pageType 0 是新增 1是编辑 2是详情
|
|
|
+ static void startInstance(int pageType, String? appliedId) {
|
|
|
+ return Get.start(RouterPath.JOB_LABOUR_REQUEST_ADD, arguments: {'pageType': pageType, 'appliedId': appliedId});
|
|
|
}
|
|
|
|
|
|
@override
|
|
@@ -26,17 +38,17 @@ class LabourRequestAddPage extends BaseStatefulPage<LabourRequestAddController>
|
|
|
|
|
|
@override
|
|
|
State<LabourRequestAddPage> createState() => _LabourRequestAddState();
|
|
|
-
|
|
|
}
|
|
|
|
|
|
class _LabourRequestAddState extends BaseState<LabourRequestAddPage, LabourRequestAddController> {
|
|
|
-
|
|
|
late LabourRequestAddState state;
|
|
|
|
|
|
@override
|
|
|
void initState() {
|
|
|
super.initState();
|
|
|
state = controller.state;
|
|
|
+ state.pageType = Get.arguments['pageType'];
|
|
|
+ state.appliedId = Get.arguments['appliedId'];
|
|
|
}
|
|
|
|
|
|
@override
|
|
@@ -44,7 +56,13 @@ class _LabourRequestAddState extends BaseState<LabourRequestAddPage, LabourReque
|
|
|
return autoCtlGetBuilder(builder: (controller) {
|
|
|
return Scaffold(
|
|
|
extendBodyBehindAppBar: true,
|
|
|
- appBar: MyAppBar.appBar(context, "Add Labour Requisition".tr),
|
|
|
+ appBar: MyAppBar.appBar(
|
|
|
+ context,
|
|
|
+ state.pageType == 0
|
|
|
+ ? "Add Labour Requisition".tr
|
|
|
+ : state.pageType == 1
|
|
|
+ ? "Edit Labour Requisition".tr
|
|
|
+ : "Labour Requisition".tr),
|
|
|
body: SafeArea(
|
|
|
bottom: true,
|
|
|
top: false,
|
|
@@ -63,12 +81,228 @@ class _LabourRequestAddState extends BaseState<LabourRequestAddPage, LabourReque
|
|
|
end: Alignment.bottomCenter,
|
|
|
),
|
|
|
),
|
|
|
- child: Container(),
|
|
|
+ child: Scrollbar(
|
|
|
+ child: ScrollConfiguration(
|
|
|
+ behavior: NoShadowScrollBehavior(),
|
|
|
+ child: SingleChildScrollView(
|
|
|
+ scrollDirection: Axis.vertical,
|
|
|
+ physics: const BouncingScrollPhysics(),
|
|
|
+ child: Column(
|
|
|
+ crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
+ children: [
|
|
|
+ //工作标题,选择模板
|
|
|
+ FormRequireText(
|
|
|
+ text: "Job Title".tr,
|
|
|
+ ).marginOnly(top: 15),
|
|
|
+
|
|
|
+ //工作标题
|
|
|
+ Container(
|
|
|
+ padding: EdgeInsets.only(left: 16, right: 10),
|
|
|
+ margin: EdgeInsets.only(top: 10),
|
|
|
+ height: 45,
|
|
|
+ decoration: BoxDecoration(
|
|
|
+ color: Color(0xFF4DCFF6).withOpacity(state.pageType == 2 ? 0.5 : 0.2),
|
|
|
+ borderRadius: const BorderRadius.all(Radius.circular(5)),
|
|
|
+ ),
|
|
|
+ child: Row(
|
|
|
+ mainAxisSize: MainAxisSize.max,
|
|
|
+ crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
+ mainAxisAlignment: MainAxisAlignment.start,
|
|
|
+ children: [
|
|
|
+ MyTextView(
|
|
|
+ state.selectedTemplateId == null
|
|
|
+ ? ""
|
|
|
+ : state.labReqOption!.templateList.firstWhere((element) => element.value.toString() == state.selectedTemplateId).txt ?? "",
|
|
|
+ fontSize: 14,
|
|
|
+ hint: "Choose Job Title".tr,
|
|
|
+ textHintColor: ColorConstants.textGrayAECAE5,
|
|
|
+ isFontMedium: true,
|
|
|
+ textColor: ColorConstants.white,
|
|
|
+ ).expanded(),
|
|
|
+
|
|
|
+ //下拉选图标
|
|
|
+ Visibility(
|
|
|
+ visible: state.pageType != 2,
|
|
|
+ child: MyAssetImage(Assets.baseServiceTriangleDropDownIcon, width: 11.5, height: 6.28),
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ ).onTap(() {
|
|
|
+ FocusScope.of(context).unfocus();
|
|
|
+ controller.pickJobTitle();
|
|
|
+ }),
|
|
|
+
|
|
|
+ //开始时间
|
|
|
+ FormRequireText(
|
|
|
+ text: "Start Time".tr,
|
|
|
+ ).marginOnly(top: 15),
|
|
|
+
|
|
|
+ //选择时间
|
|
|
+ Container(
|
|
|
+ padding: EdgeInsets.only(left: 16, right: 10),
|
|
|
+ margin: EdgeInsets.only(top: 10),
|
|
|
+ height: 45,
|
|
|
+ decoration: BoxDecoration(
|
|
|
+ color: Color(0xFF4DCFF6).withOpacity(state.pageType == 2 ? 0.5 : 0.2),
|
|
|
+ borderRadius: const BorderRadius.all(Radius.circular(5)),
|
|
|
+ ),
|
|
|
+ child: Row(
|
|
|
+ mainAxisSize: MainAxisSize.max,
|
|
|
+ crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
+ mainAxisAlignment: MainAxisAlignment.start,
|
|
|
+ children: [
|
|
|
+ MyTextView(
|
|
|
+ state.selectedStartTime == null ? "" : DateTimeUtils.formatDate(state.selectedStartTime),
|
|
|
+ fontSize: 14,
|
|
|
+ hint: "Job Start Time".tr,
|
|
|
+ textHintColor: ColorConstants.textGrayAECAE5,
|
|
|
+ isFontMedium: true,
|
|
|
+ textColor: ColorConstants.white,
|
|
|
+ ).expanded(),
|
|
|
+ //下拉选图标
|
|
|
+ Visibility(
|
|
|
+ visible: state.pageType != 2,
|
|
|
+ child: MyAssetImage(Assets.baseServiceTriangleDropDownIcon, width: 11.5, height: 6.28),
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ ).onTap(() {
|
|
|
+ FocusScope.of(context).unfocus();
|
|
|
+ controller.pickStartTime();
|
|
|
+ }),
|
|
|
+
|
|
|
+ //结束时间
|
|
|
+ FormRequireText(
|
|
|
+ text: "End Time".tr,
|
|
|
+ ).marginOnly(top: 15),
|
|
|
+
|
|
|
+ //选择时间
|
|
|
+ Container(
|
|
|
+ padding: EdgeInsets.only(left: 16, right: 10),
|
|
|
+ margin: EdgeInsets.only(top: 10),
|
|
|
+ height: 45,
|
|
|
+ decoration: BoxDecoration(
|
|
|
+ color: Color(0xFF4DCFF6).withOpacity(state.pageType == 2 ? 0.5 : 0.2),
|
|
|
+ borderRadius: const BorderRadius.all(Radius.circular(5)),
|
|
|
+ ),
|
|
|
+ child: Row(
|
|
|
+ mainAxisSize: MainAxisSize.max,
|
|
|
+ crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
+ mainAxisAlignment: MainAxisAlignment.start,
|
|
|
+ children: [
|
|
|
+ MyTextView(
|
|
|
+ state.selectedEndTime == null ? "" : DateTimeUtils.formatDate(state.selectedEndTime),
|
|
|
+ fontSize: 14,
|
|
|
+ hint: "Job End Time".tr,
|
|
|
+ textHintColor: ColorConstants.textGrayAECAE5,
|
|
|
+ isFontMedium: true,
|
|
|
+ textColor: ColorConstants.white,
|
|
|
+ ).expanded(),
|
|
|
+ //下拉选图标
|
|
|
+ Visibility(
|
|
|
+ visible: state.pageType != 2,
|
|
|
+ child: MyAssetImage(Assets.baseServiceTriangleDropDownIcon, width: 11.5, height: 6.28),
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ ).onTap(() {
|
|
|
+ FocusScope.of(context).unfocus();
|
|
|
+ controller.pickEndTime();
|
|
|
+ }),
|
|
|
+
|
|
|
+ //工作选择部门
|
|
|
+ FormRequireText(
|
|
|
+ text: "Outlet".tr,
|
|
|
+ ).marginOnly(top: 15),
|
|
|
+
|
|
|
+ //选择部门
|
|
|
+ Container(
|
|
|
+ padding: EdgeInsets.only(left: 16, right: 10),
|
|
|
+ margin: EdgeInsets.only(top: 10),
|
|
|
+ height: 45,
|
|
|
+ decoration: BoxDecoration(
|
|
|
+ color: Color(0xFF4DCFF6).withOpacity(state.pageType == 2 ? 0.5 : 0.2),
|
|
|
+ borderRadius: const BorderRadius.all(Radius.circular(5)),
|
|
|
+ ),
|
|
|
+ child: Row(
|
|
|
+ mainAxisSize: MainAxisSize.max,
|
|
|
+ crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
+ mainAxisAlignment: MainAxisAlignment.start,
|
|
|
+ children: [
|
|
|
+ MyTextView(
|
|
|
+ state.selectedDepartmentId == null
|
|
|
+ ? ""
|
|
|
+ : state.labReqOption!.departmentList?.firstWhere((element) => element.value.toString() == state.selectedDepartmentId).txt ??
|
|
|
+ "",
|
|
|
+ fontSize: 14,
|
|
|
+ hint: "Choose Outlet".tr,
|
|
|
+ textHintColor: ColorConstants.textGrayAECAE5,
|
|
|
+ isFontMedium: true,
|
|
|
+ textColor: ColorConstants.white,
|
|
|
+ ).expanded(),
|
|
|
+ //下拉选图标
|
|
|
+ Visibility(
|
|
|
+ visible: state.pageType != 2,
|
|
|
+ child: MyAssetImage(Assets.baseServiceTriangleDropDownIcon, width: 11.5, height: 6.28),
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ ).onTap(() {
|
|
|
+ FocusScope.of(context).unfocus();
|
|
|
+ controller.pickDepartment();
|
|
|
+ }),
|
|
|
+
|
|
|
+ //需要的人数
|
|
|
+ FormRequireText(
|
|
|
+ text: "No. of Staff".tr,
|
|
|
+ ).marginOnly(top: 15),
|
|
|
+
|
|
|
+ //输入框(只允许输入数字)
|
|
|
+ CustomTextField(
|
|
|
+ formKey: "no_of_staff",
|
|
|
+ marginLeft: 0,
|
|
|
+ marginRight: 0,
|
|
|
+ paddingTop: 0,
|
|
|
+ paddingBottom: 0,
|
|
|
+ height: 45,
|
|
|
+ fillBackgroundColor: Color(0xFF4DCFF6).withOpacity(state.pageType == 2 ? 0.5 : 0.2),
|
|
|
+ enabled: state.pageType != 2,
|
|
|
+ inputFormatters: <TextInputFormatter>[FilteringTextInputFormatter.digitsOnly],
|
|
|
+ textInputType: TextInputType.number,
|
|
|
+ formData: state.formData,
|
|
|
+ textInputAction: TextInputAction.done,
|
|
|
+ onSubmit: (key, value) {
|
|
|
+ FocusScope.of(context).unfocus();
|
|
|
+ },
|
|
|
+ marginTop: 10,
|
|
|
+ ),
|
|
|
+
|
|
|
+ //提交按钮
|
|
|
+ Visibility(
|
|
|
+ visible: state.pageType != 2,
|
|
|
+ child: MyButton(
|
|
|
+ type: ClickType.throttle,
|
|
|
+ milliseconds: 500,
|
|
|
+ onPressed: () {
|
|
|
+ FocusScope.of(context).unfocus();
|
|
|
+ controller.doSubmit();
|
|
|
+ },
|
|
|
+ text: "Submit".tr,
|
|
|
+ textColor: ColorConstants.white,
|
|
|
+ fontSize: 16,
|
|
|
+ radius: 22.5,
|
|
|
+ backgroundColor: hexToColor("#FFBB1B"),
|
|
|
+ fontWeight: FontWeight.w500,
|
|
|
+ ).marginSymmetric(horizontal: 0, vertical: 30),
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ ).paddingOnly(left: 15, right: 15),
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ),
|
|
|
),
|
|
|
),
|
|
|
);
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
-
|