patrol_job_detail.dart 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399
  1. import 'package:deus_app/common/style/TitleBar.dart';
  2. import 'package:deus_app/common/utils/ConstantString.dart';
  3. import 'package:deus_app/common/utils/ToastUtils.dart';
  4. import 'package:deus_app/model/drop_menu_item.dart';
  5. import 'package:flutter/material.dart';
  6. import 'package:deus_app/model/patrol_response_entity.dart';
  7. import '../../common/utils/DioUtil.dart';
  8. /**
  9. * 巡检任务详情页面
  10. */
  11. class PatrolJobDetail extends StatefulWidget {
  12. var id ;
  13. PatrolJobDetail({super.key, @required this.id});
  14. static var routeName = '/PatrolJobDetail';
  15. @override
  16. State createState() {
  17. print(id);
  18. return new _PatrolJobDetail(id);
  19. }
  20. }
  21. PatrolJobDeviceData p =
  22. PatrolJobDeviceData('设备名称1', '展示名称1', 'deviceKey1', '2023-05-28', '曹刚');
  23. PatrolJobDeviceData a =
  24. PatrolJobDeviceData('设备名称2', '展示名称2', 'deviceKey2', '2023-05-29', '曹刚');
  25. List<PatrolJobDeviceData> device_list = [p, a, a, a, a, a, a, a];
  26. PatrolJobDetailData patrolJobDetailData = PatrolJobDetailData(
  27. '巡检任务',
  28. 'XJRW10001',
  29. '巡检计划',
  30. 'XJJH10001',
  31. 1,
  32. '2023-05-29 00:00:00',
  33. '2023-05-29 23:59:59',
  34. '曹刚',
  35. '2023-05-29 14:00:35',
  36. 2,
  37. '备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注');
  38. PatrolJobItemData patrolJobItemData = PatrolJobItemData('巡检项目1', '结果1');
  39. PatrolJobItemData patrolJobItemData2 = PatrolJobItemData('巡检项目2', '结果2');
  40. List<PatrolJobItemData> item_list = [patrolJobItemData, patrolJobItemData2];
  41. PatrolJobImageData imageData = PatrolJobImageData(1,
  42. 'https://fqgz.flowbb.cn:7070/deus-test/image/59a75f5b80d7458c88f6b48608ee16eb.jpg?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=minioadmin%2F20230530%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20230530T054753Z&X-Amz-Expires=604800&X-Amz-SignedHeaders=host&X-Amz-Signature=cdc7f9501492ef218ce42d4f31c41ed01208802a88c9e9f7df5316251569664c');
  43. List<PatrolJobImageData> image_list = [
  44. imageData,
  45. imageData,
  46. imageData,
  47. imageData,
  48. imageData,
  49. imageData,
  50. imageData,
  51. imageData,
  52. imageData,
  53. imageData,
  54. imageData,
  55. imageData,
  56. imageData,
  57. imageData,
  58. ];
  59. DropMenuItem boy = DropMenuItem('男',1);
  60. DropMenuItem girl = DropMenuItem('女',2);
  61. List<DropMenuItem> sexMenuItems = [boy,girl];
  62. List<String> sexSelects = ['男','女','奥特曼'];
  63. class _PatrolJobDetail extends State<PatrolJobDetail> {
  64. var id;
  65. _PatrolJobDetail(this.id);
  66. _load() async {
  67. var result = await DioUtil().request('patrolJob/appPatrolJobList',
  68. method: DioMethod.get, params: {'id':id});
  69. PatrolJobResponse patrolJobResponse = PatrolJobResponse.fromJson(result);
  70. //var patrolJobResponse = PatrolJobResponse.fromJson(result);
  71. //print(patrolJobResponse);
  72. }
  73. @override
  74. void initState() {
  75. // TODO: implement initState
  76. super.initState();
  77. Future.delayed(
  78. Duration.zero,
  79. () => setState(() {
  80. _load();
  81. }));
  82. }
  83. @override
  84. Widget build(BuildContext context) {
  85. print(id);
  86. return Scaffold(
  87. appBar: TitleBar().backAppbar(context, "巡检任务详情"),
  88. body: Column(
  89. children: [
  90. Expanded(
  91. child: ListView(
  92. children: _Ws(),
  93. ),
  94. )
  95. ],
  96. ));
  97. }
  98. List<Widget> _Ws() {
  99. List<Widget> ws = [];
  100. ws.add(_patrolJobDetail(patrolJobDetailData));
  101. ws.add(_device());
  102. ws.add(_item());
  103. ws.add(_remark());
  104. ws.add(_url());
  105. return ws;
  106. }
  107. Widget _patrolJobDetail(PatrolJobDetailData patrolJobDetailData) {
  108. if (patrolJobDetailData.status == 2) {
  109. return Column(
  110. children: [
  111. Row(
  112. children: [
  113. Container(
  114. padding: EdgeInsets.fromLTRB(15, 20, 0, 0),
  115. alignment: Alignment.centerLeft,
  116. child: Text(
  117. '已完成',
  118. style: TextStyle(fontSize: 20, backgroundColor: Colors.red),
  119. ),
  120. ),
  121. Container(
  122. padding: EdgeInsets.fromLTRB(20, 0, 0, 0),
  123. alignment: Alignment.bottomLeft,
  124. child: Text(
  125. patrolJobDetailData.name,
  126. style: TextStyle(fontSize: 18),
  127. ),
  128. )
  129. ],
  130. ),
  131. Container(
  132. padding: EdgeInsets.fromLTRB(95, 0, 0, 20),
  133. alignment: Alignment.centerLeft,
  134. child: Text(
  135. '任务编号: ' + patrolJobDetailData.number,
  136. style: TextStyle(fontSize: 18),
  137. ),
  138. ),
  139. Divider(
  140. height: 0.8,
  141. indent: 5.0,
  142. endIndent: 5.0,
  143. color: Colors.grey,
  144. ),
  145. Container(
  146. padding: EdgeInsets.fromLTRB(65, 20, 0, 0),
  147. alignment: Alignment.centerLeft,
  148. child: Text(
  149. '巡检任务名称 ' + patrolJobDetailData.name,
  150. style: TextStyle(fontSize: 14),
  151. ),
  152. ),
  153. Container(
  154. padding: EdgeInsets.fromLTRB(65, 20, 0, 0),
  155. alignment: Alignment.centerLeft,
  156. child: Text(
  157. '巡检任务编号 ' + patrolJobDetailData.number,
  158. style: TextStyle(fontSize: 14),
  159. ),
  160. ),
  161. Container(
  162. padding: EdgeInsets.fromLTRB(65, 20, 0, 0),
  163. alignment: Alignment.centerLeft,
  164. child: Text(
  165. '巡检计划名称 ' + patrolJobDetailData.planName,
  166. style: TextStyle(fontSize: 14),
  167. ),
  168. ),
  169. Container(
  170. padding: EdgeInsets.fromLTRB(65, 20, 0, 0),
  171. alignment: Alignment.centerLeft,
  172. child: Text(
  173. '巡检计划编号 ' + patrolJobDetailData.planNumber,
  174. style: TextStyle(fontSize: 14),
  175. ),
  176. ),
  177. Container(
  178. padding: EdgeInsets.fromLTRB(92, 20, 0, 0),
  179. alignment: Alignment.centerLeft,
  180. child: Text(
  181. '周期类型 ' + (patrolJobDetailData.termType == 1 ? '日计划' : '暂无'),
  182. style: TextStyle(fontSize: 14),
  183. ),
  184. ),
  185. Container(
  186. padding: EdgeInsets.fromLTRB(65, 20, 0, 0),
  187. alignment: Alignment.centerLeft,
  188. child: Text(
  189. '任务开始时间 ' + patrolJobDetailData.startDate,
  190. style: TextStyle(fontSize: 14),
  191. ),
  192. ),
  193. Container(
  194. padding: EdgeInsets.fromLTRB(65, 20, 0, 0),
  195. alignment: Alignment.centerLeft,
  196. child: Text(
  197. '任务结束时间 ' + patrolJobDetailData.endDate,
  198. style: TextStyle(fontSize: 14),
  199. ),
  200. ),
  201. Container(
  202. padding: EdgeInsets.fromLTRB(65, 20, 0, 0),
  203. alignment: Alignment.centerLeft,
  204. child: Text(
  205. '实际完成时间 ' + patrolJobDetailData.finishTime,
  206. style: TextStyle(fontSize: 14),
  207. ),
  208. ),
  209. Container(
  210. padding: EdgeInsets.fromLTRB(92, 20, 0, 20),
  211. alignment: Alignment.centerLeft,
  212. child: Text(
  213. '巡检人员 ' + patrolJobDetailData.personnel,
  214. style: TextStyle(fontSize: 14),
  215. ),
  216. ),
  217. ],
  218. );
  219. } else {
  220. return Text('暂无数据');
  221. }
  222. }
  223. Widget _device() {
  224. return ExpansionTile(
  225. title: Container(
  226. child: Text(
  227. '巡检设备',
  228. style: TextStyle(color: Colors.blue, fontSize: 20),
  229. )),
  230. children: device_list.map((e) => _buildDevice(e)).toList(),
  231. initiallyExpanded: true);
  232. }
  233. Widget _buildDevice(PatrolJobDeviceData device) {
  234. return FractionallySizedBox(
  235. widthFactor: 1,
  236. child: Container(
  237. height: 160,
  238. margin: EdgeInsets.only(bottom: 5),
  239. decoration: BoxDecoration(color: Colors.white),
  240. child: Column(
  241. children: [
  242. Container(
  243. margin: const EdgeInsets.fromLTRB(0, 20.0, 0, 0),
  244. padding: const EdgeInsets.fromLTRB(30.0, 0.0, 0.0, 0.0),
  245. alignment: Alignment.centerLeft,
  246. child: Text(device.showName, style: TextStyle(fontSize: 14)),
  247. ),
  248. Container(
  249. margin: const EdgeInsets.fromLTRB(0, 10.0, 0, 0),
  250. padding: const EdgeInsets.fromLTRB(30.0, 0.0, 0.0, 0.0),
  251. alignment: Alignment.centerLeft,
  252. child: Text('设备名称: ' + device.name,
  253. style: TextStyle(fontSize: 14)),
  254. ),
  255. Container(
  256. margin: const EdgeInsets.fromLTRB(0, 10.0, 0, 0),
  257. padding: const EdgeInsets.fromLTRB(30.0, 0.0, 0.0, 0.0),
  258. alignment: Alignment.centerLeft,
  259. child: Text('deviceKey: ' + device.deviceKey,
  260. style: TextStyle(fontSize: 14)),
  261. ),
  262. Container(
  263. margin: const EdgeInsets.fromLTRB(0, 10.0, 0, 20),
  264. padding: const EdgeInsets.fromLTRB(30.0, 0.0, 0.0, 10.0),
  265. alignment: Alignment.centerLeft,
  266. child: Text('完成时间: ' + device.itemCompleteTime,
  267. style: TextStyle(fontSize: 14)),
  268. ),
  269. Divider(
  270. height: 0.8,
  271. indent: 10.0,
  272. endIndent: 10.0,
  273. color: Colors.grey,
  274. ),
  275. ],
  276. ),
  277. ));
  278. }
  279. Widget _item() {
  280. return ExpansionTile(
  281. title: Container(
  282. child: Text(
  283. '巡检项目',
  284. style: TextStyle(color: Colors.blue, fontSize: 20),
  285. )),
  286. children: item_list.map((e) => _buildItem(e)).toList(),
  287. initiallyExpanded: true);
  288. }
  289. Widget _buildItem(PatrolJobItemData item) {
  290. return FractionallySizedBox(
  291. widthFactor: 1,
  292. child: Container(
  293. height: 100,
  294. margin: EdgeInsets.only(bottom: 5),
  295. decoration: BoxDecoration(color: Colors.white),
  296. child: Column(
  297. children: [
  298. Container(
  299. margin: const EdgeInsets.fromLTRB(0, 15.0, 0, 0),
  300. padding: const EdgeInsets.fromLTRB(30.0, 0.0, 0.0, 0.0),
  301. alignment: Alignment.centerLeft,
  302. child: Text(item.name, style: TextStyle(fontSize: 14)),
  303. ),
  304. Container(
  305. margin: const EdgeInsets.fromLTRB(0, 10.0, 0, 20),
  306. padding: const EdgeInsets.fromLTRB(30.0, 0.0, 0.0, 0.0),
  307. alignment: Alignment.centerLeft,
  308. child: Text(item.result, style: TextStyle(fontSize: 14)),
  309. ),
  310. Divider(
  311. height: 0.8,
  312. indent: 10.0,
  313. endIndent: 10.0,
  314. color: Colors.grey,
  315. ),
  316. ],
  317. ),
  318. ));
  319. }
  320. Widget _remark() {
  321. return ExpansionTile(
  322. title: Container(
  323. child: Text(
  324. '任务结果备注',
  325. style: TextStyle(color: Colors.blue, fontSize: 20),
  326. )),
  327. children: [_buildRemark(patrolJobDetailData)],
  328. initiallyExpanded: true);
  329. }
  330. Widget _buildRemark(PatrolJobDetailData patrolJobDetailData) {
  331. return FractionallySizedBox(
  332. widthFactor: 1,
  333. child: Container(
  334. margin: EdgeInsets.only(bottom: 5),
  335. decoration: BoxDecoration(color: Colors.white),
  336. child: Column(
  337. children: [
  338. Container(
  339. margin: const EdgeInsets.fromLTRB(0, 15.0, 0, 15.0),
  340. padding: const EdgeInsets.fromLTRB(20.0, 0.0, 20.0, 0.0),
  341. alignment: Alignment.centerLeft,
  342. child: Text(patrolJobDetailData.remark,
  343. style: TextStyle(fontSize: 14)),
  344. )
  345. ],
  346. ),
  347. ));
  348. }
  349. Widget _url() {
  350. return ExpansionTile(
  351. title: Container(
  352. child: Text(
  353. '任务图片',
  354. style: TextStyle(color: Colors.blue, fontSize: 20),
  355. )),
  356. children: [
  357. Wrap(children: image_list.map((e) => _buildImage(e)).toList()),
  358. ],
  359. initiallyExpanded: true);
  360. }
  361. Widget _buildImage(PatrolJobImageData imageData) {
  362. return Container(
  363. width: 150,
  364. margin: EdgeInsets.only(bottom: 5),
  365. alignment: Alignment.centerLeft,
  366. decoration: BoxDecoration(color: Colors.white),
  367. child: Image.network(imageData.url));
  368. }
  369. }