maint_job_page.dart 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. //巡检任务列表
  2. import 'package:deus_app/common/style/TitleBar.dart';
  3. import 'package:deus_app/page/patrol/patrol_job_detail.dart';
  4. import 'package:flutter/material.dart';
  5. import '../../common/style/gsy_style.dart';
  6. import '../../common/utils/ConstantString.dart';
  7. import '../../common/utils/DioUtil.dart';
  8. import '../../common/utils/ToastUtils.dart';
  9. import '../../model/patrol_response_entity.dart';
  10. import '../../widget/MaintJobDrawer.dart';
  11. class MaintJobPage extends StatefulWidget {
  12. const MaintJobPage({super.key});
  13. static var routeName = '/MaintJobPage';
  14. @override
  15. State createState() {
  16. return _MaintJobPage();
  17. }
  18. }
  19. List<PatrolJobData> patrol_job_list = [];
  20. class _MaintJobPage extends State<MaintJobPage> {
  21. final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
  22. _load() async {
  23. var result = await DioUtil().request('patrolJob/appPatrolJobList',
  24. method: DioMethod.post, data: {'query': {}, 'index': 1, 'size': 5});
  25. //var patrolJobResponse = PatrolJobResponse.fromJson(result);
  26. //print(patrolJobResponse);
  27. }
  28. @override
  29. void initState() {
  30. // TODO: implement initState
  31. super.initState();
  32. Future.delayed(
  33. Duration.zero,
  34. () => setState(() {
  35. _load();
  36. }));
  37. }
  38. @override
  39. Widget build(BuildContext context) {
  40. return Scaffold(
  41. key: _scaffoldKey,
  42. appBar: TitleBar().drawAppBar(ConstantString.patrolJobText, () {
  43. _scaffoldKey.currentState?.openEndDrawer();
  44. }),
  45. endDrawer: MaintJobDrawer(
  46. callback: (index, str) {
  47. showToast(str);
  48. },
  49. ),
  50. //抽屉
  51. backgroundColor: const Color(0xfff2f2f2),
  52. body: Column(
  53. children: [
  54. SizedBox(
  55. height: 10,
  56. ),
  57. Row(
  58. mainAxisAlignment: MainAxisAlignment.start,
  59. children: [
  60. SizedBox(
  61. width: 15,
  62. ),
  63. Text(ConstantString.patrolJobTitle,
  64. style: GSYConstant.smallActionLightText),
  65. ],
  66. ),
  67. Expanded(
  68. child: Container(
  69. child: ListView.builder(
  70. itemCount: patrol_job_list.length,
  71. itemBuilder: (context, index) {
  72. PatrolJobData patrolJobData = patrol_job_list[index];
  73. return _patrol_job_list(patrolJobData);
  74. },
  75. )))
  76. ],
  77. ));
  78. }
  79. Widget _patrol_job_list(PatrolJobData patrolJobData) {
  80. return Container(
  81. margin: EdgeInsets.only(top: 12, left: 10, right: 10),
  82. padding: EdgeInsets.only(top: 12, bottom: 10),
  83. color: Colors.white,
  84. child: ListTile(
  85. title: Column(
  86. children: [
  87. Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
  88. Container(
  89. child: Text(
  90. patrolJobData.name!,
  91. style: TextStyle(
  92. color: Colors.black,
  93. fontSize: GSYConstant.middleTextWhiteSize,
  94. fontWeight: FontWeight.bold,
  95. ),
  96. ),
  97. ),
  98. Container(
  99. padding:
  100. EdgeInsets.only(top: 3, bottom: 3, left: 5, right: 5),
  101. child: Text(
  102. patrolJobData.status == 0
  103. ? '已关闭'
  104. : patrolJobData.status == 1
  105. ? '执行中'
  106. : patrolJobData.status == 2
  107. ? '已完成'
  108. : patrolJobData.status == 3
  109. ? '待执行'
  110. : patrolJobData.status == 4
  111. ? '已逾期'
  112. : '未知',
  113. textAlign: TextAlign.right,
  114. style: TextStyle(
  115. color:
  116. patrolJobData.status == 0 || patrolJobData.status == 4
  117. ? Colors.red
  118. : patrolJobData.status == 1
  119. ? Colors.orange
  120. : patrolJobData.status == 2
  121. ? Colors.green
  122. : Colors.black, //边框颜色
  123. fontSize: GSYConstant.minTextSize,
  124. ),
  125. ),
  126. decoration: BoxDecoration(
  127. border: new Border.all(
  128. color:
  129. patrolJobData.status == 0 || patrolJobData.status == 4
  130. ? Colors.red
  131. : patrolJobData.status == 1
  132. ? Colors.orange
  133. : patrolJobData.status == 2
  134. ? Colors.green
  135. : Colors.black, //边框颜色
  136. width: 1.0, //边框粗细
  137. ),
  138. borderRadius: const BorderRadius.all(
  139. const Radius.circular(3.0)), //边框的弧度
  140. ),
  141. )
  142. ]),
  143. SizedBox(
  144. height: 12,
  145. ),
  146. Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
  147. Container(
  148. child: Text(
  149. '任务编号:',
  150. style: TextStyle(
  151. color: GSYColors.primaryLightValue,
  152. fontSize: GSYConstant.middleTextWhiteSize,
  153. ),
  154. ),
  155. ),
  156. Container(
  157. child: Text(
  158. patrolJobData.number!,
  159. textAlign: TextAlign.right,
  160. style: TextStyle(
  161. color: GSYColors.primaryLightValue,
  162. fontSize: GSYConstant.middleTextWhiteSize,
  163. ),
  164. ),
  165. ),
  166. ]),
  167. SizedBox(
  168. height: 10,
  169. ),
  170. Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
  171. Container(
  172. child: Text(
  173. '任务开始时间:',
  174. style: TextStyle(
  175. color: GSYColors.primaryLightValue,
  176. fontSize: GSYConstant.middleTextWhiteSize,
  177. ),
  178. ),
  179. ),
  180. Container(
  181. child: Text(
  182. patrolJobData.startDate!,
  183. textAlign: TextAlign.right,
  184. style: TextStyle(
  185. color: GSYColors.primaryLightValue,
  186. fontSize: GSYConstant.middleTextWhiteSize,
  187. ),
  188. ),
  189. ),
  190. ]),
  191. SizedBox(
  192. height: 10,
  193. ),
  194. Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
  195. Container(
  196. child: Text(
  197. '任务结束时间:',
  198. style: TextStyle(
  199. color: GSYColors.primaryLightValue,
  200. fontSize: GSYConstant.middleTextWhiteSize,
  201. ),
  202. ),
  203. ),
  204. Container(
  205. child: Text(
  206. patrolJobData.endDate!,
  207. textAlign: TextAlign.right,
  208. style: TextStyle(
  209. color: GSYColors.primaryLightValue,
  210. fontSize: GSYConstant.middleTextWhiteSize,
  211. ),
  212. ),
  213. ),
  214. ]),
  215. SizedBox(
  216. height: 5,
  217. ),
  218. ],
  219. ),
  220. onTap: () {
  221. Navigator.push(
  222. context,
  223. MaterialPageRoute(
  224. builder: (context) => new PatrolJobDetail(id:patrolJobData.id)));
  225. },
  226. ));
  227. }
  228. }