repair_page.dart 8.8 KB

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