view.dart 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  1. import 'package:flutter/material.dart';
  2. import 'package:get/get.dart';
  3. import 'package:pull_to_refresh/pull_to_refresh.dart';
  4. import '../../../../common/models/index.dart';
  5. import '../../../../common/style/index.dart';
  6. import 'index.dart';
  7. class OfficeCenterPage extends GetView<OfficeCenterController> {
  8. const OfficeCenterPage({Key? key}) : super(key: key);
  9. @override
  10. Widget build(BuildContext context) {
  11. return GetBuilder<OfficeCenterController>(
  12. builder: (_) {
  13. return Scaffold(
  14. appBar: AppBar(
  15. title: Obx(() => Text(controller.state.title)),
  16. actions: [
  17. Obx(() {
  18. final len = controller.state.taskSelectedList.length;
  19. return Visibility(
  20. visible: len > 0,
  21. child: TextButton(
  22. onPressed: () => controller.gotoQuickProcess(),
  23. child: Text('process_task_quick_process'.tr, style: AppTheme.whitePrimaryTextStyle)),
  24. );
  25. })
  26. ],
  27. ),
  28. body: SafeArea(
  29. child: Obx(
  30. () => Column(children: [
  31. searchBar(context),
  32. const SizedBox(height: 5),
  33. Expanded(
  34. flex: 1,
  35. child: SmartRefresher(
  36. enablePullDown: true,
  37. enablePullUp: controller.state.hasMoreData,
  38. controller: controller.refreshController,
  39. onRefresh: controller.onRefresh,
  40. onLoading: controller.onLoadMore,
  41. child: ListView.separated(
  42. separatorBuilder: ((context, index) =>
  43. const Divider(height: 1)),
  44. itemCount: controller.state.dataList.length,
  45. itemBuilder: (context, index) {
  46. final item = controller.state.dataList[index];
  47. if (item is TaskData) {
  48. return taskItem(item, context);
  49. } else if (item is TaskCompletedData) {
  50. return taskCompletedItem(item, context);
  51. } else if (item is ReadData) {
  52. return readItem(item, context);
  53. } else if (item is ReadCompletedData) {
  54. return readCompletedItem(item, context);
  55. }
  56. return Container();
  57. },
  58. )))
  59. ]),
  60. )),
  61. );
  62. },
  63. );
  64. }
  65. Widget searchBar(BuildContext context) {
  66. return Padding(
  67. padding:
  68. const EdgeInsets.only(left: 12, right: 12, top: 8, bottom: 8),
  69. child: Container(
  70. height: 36,
  71. decoration: BoxDecoration(
  72. color: Theme.of(context).colorScheme.background,
  73. borderRadius: const BorderRadius.all(Radius.circular(18))),
  74. alignment: Alignment.centerLeft,
  75. child: Padding(
  76. padding: const EdgeInsets.only(left: 10),
  77. child: Row(
  78. children: [
  79. SizedBox(
  80. width: 22,
  81. height: 22,
  82. child: Icon(Icons.search,
  83. color: Theme.of(context).colorScheme.primary),
  84. ),
  85. Expanded(
  86. flex: 1,
  87. child: Padding(
  88. padding: const EdgeInsets.only(left: 5),
  89. child: TextField(
  90. autofocus: false,
  91. controller: controller.searchController,
  92. decoration: InputDecoration(
  93. isDense: true,
  94. border: InputBorder.none,
  95. hintText: 'process_office_center_search_placeholder'.tr,
  96. hintStyle: Theme.of(context).textTheme.bodySmall,
  97. ),
  98. style: Theme.of(context).textTheme.bodyMedium,
  99. textInputAction: TextInputAction.search,
  100. onSubmitted: controller.onSearch,
  101. ),
  102. ),
  103. )
  104. ],
  105. ),
  106. ),
  107. ));
  108. }
  109. Widget taskItem(TaskData task, BuildContext context) {
  110. String title = task.title ?? '';
  111. if (title.isEmpty) {
  112. title = 'process_work_no_title_no_process'.tr;
  113. }
  114. String time = task.startTime ?? '';
  115. if (time.isNotEmpty) {
  116. time = time.substring(0, 10);
  117. }
  118. return Obx(() {
  119. final len = controller.state.taskSelectedList.length;
  120. // 是否可快速处理
  121. bool rapid = task.allowRapid ?? false;
  122. // 只能选择相同的活动上的待办
  123. if (rapid &&
  124. (len == 0 ||
  125. (len > 0 &&
  126. controller.state.taskSelectedList[0].activity ==
  127. task.activity
  128. && controller.state.taskSelectedList[0].process ==
  129. task.process))) {
  130. return CheckboxListTile(
  131. // onTap: () => controller.clickTask(task),
  132. title: Text('[${task.processName}] $title'),
  133. subtitle: Text(task.activityName ?? ''),
  134. secondary: TextButton(onPressed: (() => controller.clickTask(task)), child: Text('process_task_open_work'.tr)),
  135. // GestureDetector(
  136. // onTap: () => controller.clickTask(task),
  137. // child: Row(
  138. // mainAxisAlignment: MainAxisAlignment.end,
  139. // mainAxisSize: MainAxisSize.min,
  140. // children: [
  141. // Text(time, style: Theme.of(context).textTheme.bodySmall),
  142. // const Icon(
  143. // Icons.keyboard_arrow_right,
  144. // color: AppColor.hintText,
  145. // size: 22,
  146. // )
  147. // ]),
  148. // ),
  149. controlAffinity: ListTileControlAffinity.leading,
  150. value: controller.isItemChecked(task),
  151. onChanged: (value) => controller.onSelectChange(value, task),
  152. );
  153. } else {
  154. return ListTile(
  155. onTap: () => controller.clickTask(task),
  156. title: Text('[${task.processName}] $title'),
  157. subtitle: Text(task.activityName ?? ''),
  158. trailing: Row(
  159. mainAxisAlignment: MainAxisAlignment.end,
  160. mainAxisSize: MainAxisSize.min,
  161. children: [
  162. Text(time, style: Theme.of(context).textTheme.bodySmall),
  163. const Icon(
  164. Icons.keyboard_arrow_right,
  165. color: AppColor.hintText,
  166. size: 22,
  167. )
  168. ]),
  169. );
  170. }
  171. });
  172. }
  173. Widget taskCompletedItem(
  174. TaskCompletedData taskCompleted, BuildContext context) {
  175. String title = taskCompleted.title ?? '';
  176. if (title.isEmpty) {
  177. title = 'process_work_no_title_no_process'.tr;
  178. }
  179. String time = taskCompleted.startTime ?? '';
  180. if (time.isNotEmpty) {
  181. time = time.substring(0, 10);
  182. }
  183. return ListTile(
  184. onTap: () => controller.clickTaskCompleted(taskCompleted),
  185. title: Text('[${taskCompleted.processName}] $title'),
  186. subtitle: Padding(
  187. padding: const EdgeInsets.only(top: 5),
  188. child: Text(taskCompleted.activityName ?? '')),
  189. trailing: Column(
  190. children: [
  191. taskCompleted.completed == true
  192. ? Container(
  193. width: 64,
  194. height: 18,
  195. decoration: const BoxDecoration(
  196. borderRadius: BorderRadius.all(Radius.circular(9)),
  197. color: AppColor.o2Blue),
  198. child: Center(
  199. child: Text('process_work_completed_tag'.tr,
  200. style: const TextStyle(
  201. color: Colors.white, fontSize: 13))),
  202. )
  203. : const SizedBox(height: 18),
  204. const SizedBox(height: 5),
  205. Expanded(
  206. flex: 1,
  207. child: Text(time,
  208. style: Theme.of(context).textTheme.bodySmall,
  209. textAlign: TextAlign.center)),
  210. ],
  211. ));
  212. }
  213. Widget readItem(ReadData read, BuildContext context) {
  214. String title = read.title ?? '';
  215. if (title.isEmpty) {
  216. title = 'process_work_no_title_no_process'.tr;
  217. }
  218. String time = read.startTime ?? '';
  219. if (time.isNotEmpty) {
  220. time = time.substring(0, 10);
  221. }
  222. return ListTile(
  223. onTap: () => controller.clickRead(read),
  224. title: Text('[${read.processName}] $title'),
  225. subtitle: Text(read.activityName ?? ''),
  226. trailing: Column(
  227. children: [
  228. read.completed == true
  229. ? Container(
  230. width: 64,
  231. height: 18,
  232. decoration: const BoxDecoration(
  233. borderRadius: BorderRadius.all(Radius.circular(9)),
  234. color: AppColor.o2Blue),
  235. child: Center(
  236. child: Text('process_work_completed_tag'.tr,
  237. style:
  238. const TextStyle(color: Colors.white, fontSize: 13))),
  239. )
  240. : const SizedBox(height: 18),
  241. const SizedBox(height: 5),
  242. Expanded(
  243. flex: 1,
  244. child: Text(time,
  245. style: Theme.of(context).textTheme.bodySmall,
  246. textAlign: TextAlign.center)),
  247. ],
  248. ),
  249. );
  250. }
  251. Widget readCompletedItem(
  252. ReadCompletedData readCompleted, BuildContext context) {
  253. String title = readCompleted.title ?? '';
  254. if (title.isEmpty) {
  255. title = 'process_work_no_title_no_process'.tr;
  256. }
  257. String time = readCompleted.startTime ?? '';
  258. if (time.isNotEmpty) {
  259. time = time.substring(0, 10);
  260. }
  261. return ListTile(
  262. onTap: () => controller.clickReadCompleted(readCompleted),
  263. title: Text('[${readCompleted.processName}] $title'),
  264. subtitle: Text(readCompleted.activityName ?? ''),
  265. trailing: Column(
  266. children: [
  267. readCompleted.completed == true
  268. ? Container(
  269. width: 64,
  270. height: 18,
  271. decoration: const BoxDecoration(
  272. borderRadius: BorderRadius.all(Radius.circular(9)),
  273. color: AppColor.o2Blue),
  274. child: Center(
  275. child: Text('process_work_completed_tag'.tr,
  276. style:
  277. const TextStyle(color: Colors.white, fontSize: 13))),
  278. )
  279. : const SizedBox(height: 18),
  280. const SizedBox(height: 5),
  281. Expanded(
  282. flex: 1,
  283. child: Text(time,
  284. style: Theme.of(context).textTheme.bodySmall,
  285. textAlign: TextAlign.center)),
  286. ],
  287. ),
  288. );
  289. }
  290. }