patrol_job_page.dart 9.3 KB

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