applied_add_staff.dart 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343
  1. import 'dart:ui';
  2. import 'package:cs_resources/generated/assets.dart';
  3. import 'package:domain/entity/response/job_list_applied_staff_search_entity.dart';
  4. import 'package:flutter/cupertino.dart';
  5. import 'package:flutter/material.dart';
  6. import 'package:flutter/widgets.dart';
  7. import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
  8. import 'package:get/get.dart';
  9. import 'package:widgets/ext/ex_widget.dart';
  10. import 'package:cs_resources/constants/color_constants.dart';
  11. import 'package:widgets/load_state_layout.dart';
  12. import 'package:widgets/my_load_image.dart';
  13. import 'package:widgets/my_text_view.dart';
  14. import 'package:widgets/search_app_bar.dart';
  15. import 'package:widgets/widget_export.dart';
  16. import 'applied_add_staff_controller.dart';
  17. /**
  18. * 添加员工的弹窗
  19. */
  20. class AppliedAddStaff extends StatefulWidget {
  21. String jobId;
  22. void Function(String selectIds)? confirmAction;
  23. AppliedAddStaff({required this.jobId, this.confirmAction});
  24. @override
  25. State<AppliedAddStaff> createState() => _AppliedAddStaffState();
  26. }
  27. class _AppliedAddStaffState extends State<AppliedAddStaff> {
  28. @override
  29. void initState() {
  30. super.initState();
  31. Get.put(AppliedAddStaffController());
  32. }
  33. @override
  34. void dispose() {
  35. super.dispose();
  36. Get.delete<AppliedAddStaffController>();
  37. }
  38. @override
  39. Widget build(BuildContext context) {
  40. return GetBuilder<AppliedAddStaffController>(
  41. assignId: true,
  42. builder: (controller) {
  43. return Container(
  44. width: 300,
  45. height: 555,
  46. decoration: BoxDecoration(
  47. color: Color(0XFFF7F7F7),
  48. borderRadius: const BorderRadius.all(Radius.circular(15)),
  49. ),
  50. child: Column(
  51. crossAxisAlignment: CrossAxisAlignment.start,
  52. children: [
  53. Center(
  54. child: MyTextView(
  55. "Choose Staff".tr,
  56. fontSize: 19,
  57. isFontMedium: true,
  58. textColor: ColorConstants.black,
  59. marginTop: 22,
  60. marginBottom: 15,
  61. marginLeft: 22,
  62. marginRight: 22,
  63. ),
  64. ),
  65. SearchAppBar(
  66. value: controller.keyword,
  67. searchBarHeight: 38,
  68. searchBarBgColor: Colors.white,
  69. searchBarBorderRadius: 15,
  70. searchBarBorder: Border.all(
  71. color: Color(0XFFC3C3C3), // 设置边框颜色为灰色
  72. width: 0.5, // 设置边框宽度
  73. ),
  74. textHintColor: Color(0XFFAFB3B7),
  75. textColor: ColorConstants.black33,
  76. onSearch: (keyword) {
  77. controller.doSearch(keyword);
  78. },
  79. hintText: "Staff Name/ID/Phone".tr,
  80. controller: controller.searchController,
  81. ).marginOnly(left: 16.5, right: 1.5, bottom: 15.5),
  82. Container(
  83. color: Colors.white,
  84. child: EasyRefresh(
  85. header: ClassicHeader(
  86. dragText: 'Pull to refresh'.tr,
  87. armedText: 'Release ready'.tr,
  88. readyText: 'Refreshing...'.tr,
  89. processingText: 'Refreshing...'.tr,
  90. processedText: 'Succeeded'.tr,
  91. noMoreText: 'No more'.tr,
  92. failedText: 'Failed'.tr,
  93. messageText: 'Last updated at %T'.tr,
  94. textStyle: const TextStyle(color: ColorConstants.black66, fontSize: 14),
  95. messageStyle: const TextStyle(color: ColorConstants.black66, fontSize: 12),
  96. iconTheme: const IconThemeData(color: ColorConstants.black66),
  97. backgroundColor: Colors.transparent,
  98. ),
  99. footer: ClassicFooter(
  100. dragText: 'Pull to load'.tr,
  101. armedText: 'Release ready'.tr,
  102. readyText: 'Loading...'.tr,
  103. processingText: 'Loading...'.tr,
  104. processedText: 'Succeeded'.tr,
  105. noMoreText: 'No more'.tr,
  106. failedText: 'Failed'.tr,
  107. showMessage: false,
  108. triggerOffset: 50,
  109. iconDimension: 22,
  110. textStyle: const TextStyle(color: ColorConstants.black66, fontSize: 14),
  111. messageStyle: const TextStyle(color: ColorConstants.black66, fontSize: 12),
  112. iconTheme: const IconThemeData(color: ColorConstants.black66),
  113. backgroundColor: Colors.transparent,
  114. ),
  115. controller: controller.refreshController,
  116. onRefresh: controller.onRefresh,
  117. onLoad: controller.loadMore,
  118. child: LoadStateLayout(
  119. themeColor: ColorConstants.black66,
  120. state: controller.loadingState,
  121. errorMessage: controller.errorMessage,
  122. errorRetry: () {
  123. controller.retryRequest();
  124. },
  125. successSliverWidget: [
  126. SliverList(
  127. delegate: SliverChildBuilderDelegate(
  128. (context, index) {
  129. return _buildStaffItem(controller.datas[index], () {
  130. /// Item选中与未选中设置
  131. controller.datas[index].isSelected = !controller.datas[index].isSelected;
  132. controller.update();
  133. });
  134. },
  135. childCount: controller.datas.length,
  136. ))
  137. ],
  138. ),
  139. ),
  140. ).expanded(),
  141. //按钮组
  142. Row(
  143. children: [
  144. //取消按钮
  145. Expanded(
  146. flex: 1,
  147. child: InkWell(
  148. onTap: () {
  149. onCancel();
  150. },
  151. child: MyTextView(
  152. "Cancel".tr,
  153. fontSize: 17.5,
  154. isFontMedium: true,
  155. textAlign: TextAlign.center,
  156. textColor: Color(0XFF0085C4),
  157. cornerRadius: 3,
  158. borderWidth: 1,
  159. ),
  160. )),
  161. //垂直分割线
  162. Container(
  163. color: Color(0xff09141F).withOpacity(0.13),
  164. width: 0.5,
  165. ),
  166. //同意按钮
  167. Expanded(
  168. flex: 1,
  169. child: InkWell(
  170. onTap: () {
  171. doCallbackAction(controller);
  172. },
  173. child: MyTextView(
  174. "Submit".tr,
  175. marginLeft: 10,
  176. fontSize: 17.5,
  177. isFontMedium: true,
  178. textAlign: TextAlign.center,
  179. textColor: Color(0XFF0085C4),
  180. cornerRadius: 3,
  181. ),
  182. )),
  183. ],
  184. ).constrained(height: 46),
  185. ],
  186. ),
  187. );
  188. },
  189. );
  190. }
  191. //取消弹框
  192. void onCancel() async {
  193. SmartDialog.dismiss();
  194. }
  195. //执行回调
  196. void doCallbackAction(AppliedAddStaffController controller) {
  197. onCancel();
  198. //找到当前选中的
  199. var selectedList = controller.datas.where((element) => element.isSelected).toList(growable: false);
  200. if (selectedList.isNotEmpty) {
  201. var ids = selectedList.map((e) => e.id.toString()).toList(growable: false);
  202. String separatedIds = ids.join(',');
  203. widget.confirmAction?.call(separatedIds);
  204. }
  205. }
  206. Widget _buildStaffItem(JobListAppliedStaffSearchRows item, VoidCallback callback) {
  207. return Stack(
  208. children: [
  209. Column(
  210. children: [
  211. //姓名
  212. Row(
  213. children: [
  214. MyTextView(
  215. "Staff:",
  216. textColor: ColorConstants.black66,
  217. fontSize: 13,
  218. marginRight: 3,
  219. isFontRegular: true,
  220. ),
  221. MyTextView(
  222. item.name ?? "-",
  223. textColor: ColorConstants.black66,
  224. fontSize: 13,
  225. isFontRegular: true,
  226. ),
  227. ],
  228. ),
  229. //头像
  230. Row(
  231. children: [
  232. MyTextView(
  233. "Avatar:",
  234. textColor: ColorConstants.black66,
  235. fontSize: 13,
  236. marginRight: 3,
  237. isFontRegular: true,
  238. ),
  239. MyLoadImage(
  240. item.avatar ?? "",
  241. width: 25,
  242. height: 25,
  243. ),
  244. ],
  245. ).marginOnly(top: 5),
  246. //性别
  247. Row(
  248. children: [
  249. MyTextView(
  250. "Gender:",
  251. marginRight: 3,
  252. textColor: ColorConstants.black66,
  253. fontSize: 13,
  254. isFontRegular: true,
  255. ),
  256. MyTextView(
  257. item.sex ?? "-",
  258. textColor: ColorConstants.black66,
  259. fontSize: 13,
  260. isFontRegular: true,
  261. ),
  262. ],
  263. ).marginOnly(top: 5),
  264. //身份证
  265. Row(
  266. children: [
  267. MyTextView(
  268. "NRIC:",
  269. marginRight: 3,
  270. textColor: ColorConstants.black66,
  271. fontSize: 13,
  272. isFontRegular: true,
  273. ),
  274. MyTextView(
  275. item.nric ?? "-",
  276. textColor: ColorConstants.black66,
  277. fontSize: 13,
  278. isFontRegular: true,
  279. ),
  280. ],
  281. ).marginOnly(top: 5),
  282. //电话
  283. Row(
  284. children: [
  285. MyTextView(
  286. "Phone:",
  287. marginRight: 3,
  288. textColor: ColorConstants.black66,
  289. fontSize: 13,
  290. isFontRegular: true,
  291. ),
  292. MyTextView(
  293. item.phone ?? "-",
  294. textColor: ColorConstants.black66,
  295. fontSize: 13,
  296. isFontRegular: true,
  297. ),
  298. ],
  299. ).marginOnly(top: 5),
  300. Container(
  301. margin: EdgeInsets.only(top: 19),
  302. width: double.infinity,
  303. height: 1,
  304. color: Color(0XFFF7F7F7),
  305. )
  306. ],
  307. ).paddingOnly(left: 19, right: 20, top: 17),
  308. //是否勾选
  309. MyAssetImage(
  310. item.isSelected ? Assets.baseServiceItemSelectedIcon : Assets.baseServiceItemUnselectedGrayIcon,
  311. width: 20.5,
  312. height: 20.5,
  313. ).alignRight().marginOnly(right: 20, top: 17.5),
  314. ],
  315. ).onTap(callback);
  316. }
  317. }