maint_job_page.dart 8.1 KB

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