applied_add_staff.dart 12 KB

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