patrol_job_detail.dart 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613
  1. import 'package:deus_app/common/event/RefreshPatrol.dart';
  2. import 'package:deus_app/common/event/RefreshPatrolEdit.dart';
  3. import 'package:deus_app/common/style/TitleBar.dart';
  4. import 'package:deus_app/common/style/gsy_style.dart';
  5. import 'package:deus_app/common/utils/ConstantString.dart';
  6. import 'package:deus_app/common/utils/ToastUtils.dart';
  7. import 'package:deus_app/main.dart';
  8. import 'package:deus_app/page/patrol/patrol_job_list.dart';
  9. import 'package:flutter/material.dart';
  10. import '../../common/dialog/CloseTaskDialog.dart';
  11. import '../../common/utils/DioUtil.dart';
  12. import '../../generated/json/patrol_job_detail_response_entity_helper.dart';
  13. import '../../model/patrol_job_detail_response_entity.dart';
  14. /**
  15. * 巡检任务详情页面
  16. */
  17. class PatrolJobDetail extends StatefulWidget {
  18. var id;
  19. PatrolJobDetail({super.key, @required this.id});
  20. static var routeName = '/PatrolJobDetail';
  21. @override
  22. State createState() {
  23. print(id);
  24. return new _PatrolJobDetail(id);
  25. }
  26. }
  27. class _PatrolJobDetail extends State<PatrolJobDetail> {
  28. var _event;
  29. var id;
  30. bool type = false;
  31. _PatrolJobDetail(this.id);
  32. List<PatrolJobDetailResponseDataPatrolItemVOS> patrolItemVOS =
  33. <PatrolJobDetailResponseDataPatrolItemVOS>[];
  34. List<PatrolJobDetailResponseDataEquipmentVOS> equipmentVOS =
  35. <PatrolJobDetailResponseDataEquipmentVOS>[];
  36. List<String> fileUrls = <String>[];
  37. PatrolJobDetailResponseData responseData = PatrolJobDetailResponseData();
  38. _load() async {
  39. var result = await DioUtil().request('patrolJob/appGetJobDetail',
  40. method: DioMethod.get, params: {'id': id});
  41. PatrolJobDetailResponseEntity patrolJobResponse =
  42. patrolJobDetailResponseEntityFromJson(
  43. PatrolJobDetailResponseEntity(), result);
  44. if (patrolJobResponse.code == 0) {
  45. setState(() {
  46. responseData = patrolJobResponse.data;
  47. patrolItemVOS.addAll(responseData.patrolItemVOS);
  48. equipmentVOS.addAll(responseData.equipmentVOS);
  49. fileUrls.addAll(responseData.fileUrls);
  50. if (responseData.status == 1 || responseData.status == 4) {
  51. type = true;
  52. }
  53. });
  54. } else {
  55. showToast(patrolJobResponse.msg);
  56. }
  57. }
  58. closeJob(String msg) async {
  59. var result = await DioUtil().request('patrolJob/closeJob',
  60. method: DioMethod.post, data: {'id': id, 'closeReason': msg});
  61. if (0 == result['code']) {
  62. setState(() {
  63. eventBus.fire(RefreshPatrol());
  64. Navigator.pop(context);
  65. });
  66. } else {
  67. showToast(result['msg']);
  68. }
  69. }
  70. @override
  71. void initState() {
  72. super.initState();
  73. _load();
  74. _event = eventBus.on<RefreshPatrolEdit>().listen((event) {
  75. setState(() {
  76. _load();
  77. });
  78. });
  79. }
  80. @override
  81. Widget build(BuildContext context) {
  82. return Scaffold(
  83. resizeToAvoidBottomInset: false,
  84. appBar: TitleBar()
  85. .backAppbar("巡检任务详情"),
  86. backgroundColor: const Color(0xfff2f2f2),
  87. body: Stack(
  88. children: [
  89. Container(
  90. margin: EdgeInsets.only(bottom: type?60:0),
  91. child: ListView(
  92. children: _Ws(),
  93. ),
  94. ),
  95. Visibility(
  96. visible: type,
  97. child: Positioned(
  98. left: 0,
  99. right: 0,
  100. bottom: 0,
  101. // flex: 7,
  102. child: Row(
  103. children: [
  104. Expanded(
  105. child: SizedBox(
  106. height: 50,
  107. child: TextButton(
  108. onPressed: () {
  109. CloseTaskDialog.showCupertinoAlertDialog(context,
  110. (msg) {
  111. closeJob(msg);
  112. });
  113. },
  114. style: ButtonStyle(
  115. backgroundColor: MaterialStateProperty.all<Color>(
  116. Color(0xFF4875EC)),
  117. shape: MaterialStateProperty.all(
  118. BeveledRectangleBorder(
  119. borderRadius: BorderRadius.circular(0))),
  120. foregroundColor: MaterialStateProperty.all<Color>(
  121. Colors.white),
  122. // padding: MaterialStateProperty.all(EdgeInsets.zero)
  123. ),
  124. child: const Text(ConstantString.close_task),
  125. ),
  126. ),
  127. ),
  128. Expanded(
  129. child: SizedBox(
  130. height: 50,
  131. child: TextButton(
  132. onPressed: () {
  133. if (type) {
  134. Navigator.push(
  135. context,
  136. MaterialPageRoute(
  137. builder: (context) =>
  138. PatrolJobList(responseData: responseData)));
  139. }
  140. },
  141. style: ButtonStyle(
  142. backgroundColor:
  143. MaterialStateProperty.all<Color>(Colors.blue),
  144. foregroundColor:
  145. MaterialStateProperty.all<Color>(Colors.white),
  146. shape: MaterialStateProperty.all(
  147. BeveledRectangleBorder(
  148. borderRadius: BorderRadius.circular(0))),
  149. // padding: MaterialStateProperty.all(EdgeInsets.zero)
  150. ),
  151. child: const Text(ConstantString.registration),
  152. ),
  153. )),
  154. ],
  155. ),
  156. ))
  157. ],
  158. ));
  159. }
  160. List<Widget> _Ws() {
  161. List<Widget> ws = [];
  162. ws.add(_patrolJobDetail(responseData));
  163. ws.add(_device());
  164. ws.add(_item());
  165. ws.add(_remark());
  166. ws.add(_url());
  167. return ws;
  168. }
  169. Widget _patrolJobDetail(PatrolJobDetailResponseData patrolJobDetailData) {
  170. if ('' != patrolJobDetailData.name) {
  171. return Column(
  172. children: [
  173. Row(
  174. children: [
  175. Container(
  176. margin: EdgeInsets.only(top: 10, left: 12),
  177. // padding: EdgeInsets.fromLTRB(12, 0, 0, 0),
  178. alignment: Alignment.bottomLeft,
  179. child: Text(
  180. patrolJobDetailData.name ?? "",
  181. style: TextStyle(
  182. fontSize: GSYConstant.middleTextWhiteSize,
  183. fontWeight: FontWeight.bold),
  184. ),
  185. ),
  186. Container(
  187. margin: EdgeInsets.only(top: 10, left: 10),
  188. padding: EdgeInsets.fromLTRB(3, 2, 3, 2),
  189. alignment: Alignment.centerLeft,
  190. child: Text(
  191. patrolJobDetailData.status == 0
  192. ? '已关闭'
  193. : patrolJobDetailData.status == 1
  194. ? '执行中'
  195. : patrolJobDetailData.status == 2
  196. ? '已完成'
  197. : patrolJobDetailData.status == 3
  198. ? '待执行'
  199. : patrolJobDetailData.status == 4
  200. ? '已逾期'
  201. : '未知',
  202. style: TextStyle(
  203. fontSize: GSYConstant.minTextSize, color:patrolJobDetailData.status == 0 || patrolJobDetailData.status == 4
  204. ? Colors.red
  205. : patrolJobDetailData.status == 1
  206. ? Colors.orange
  207. : patrolJobDetailData.status == 2
  208. ? Colors.blue
  209. : Colors.black),
  210. ),
  211. decoration: BoxDecoration(
  212. border: new Border.all(
  213. color:patrolJobDetailData.status == 0 || patrolJobDetailData.status == 4
  214. ? Colors.red
  215. : patrolJobDetailData.status == 1
  216. ? Colors.orange
  217. : patrolJobDetailData.status == 2
  218. ? Colors.blue
  219. : Colors.black, //边框颜色
  220. width: 1.0, //边框粗细
  221. ),
  222. borderRadius: const BorderRadius.all(
  223. const Radius.circular(3.0)), //边框的弧度
  224. ),
  225. )
  226. ],
  227. ),
  228. Container(
  229. margin: EdgeInsets.only(top: 10, left: 12, bottom: 12),
  230. alignment: Alignment.centerLeft,
  231. child: Text(
  232. '任务编号: ' + patrolJobDetailData.number,
  233. style: TextStyle(
  234. fontSize: GSYConstant.smallTextSize,
  235. ),
  236. ),
  237. ),
  238. // Divider(
  239. // height: 0.8,
  240. // indent: 5.0,
  241. // endIndent: 5.0,
  242. // color: Colors.grey,
  243. // ),
  244. Container(
  245. decoration: BoxDecoration(color: Colors.white),
  246. child: Column(
  247. children: [
  248. Container(
  249. padding: EdgeInsets.fromLTRB(12, 20, 12, 0),
  250. alignment: Alignment.centerLeft,
  251. child: Row(
  252. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  253. children: [
  254. new Text(
  255. '巡检任务名称:',
  256. style: GSYConstant.smallTextLight,
  257. ),
  258. Container(
  259. child: Text(
  260. patrolJobDetailData.name!,
  261. style: GSYConstant.smallTextLight,
  262. textAlign: TextAlign.right,
  263. ),
  264. ),
  265. ],
  266. ),
  267. ),
  268. Container(
  269. padding: EdgeInsets.fromLTRB(12, 15, 12, 0),
  270. child: Row(
  271. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  272. children: [
  273. new Text(
  274. '巡检任务编号:',
  275. style: GSYConstant.smallTextLight,
  276. ),
  277. Container(
  278. child: Text(
  279. patrolJobDetailData.number,
  280. style: GSYConstant.smallTextLight,
  281. textAlign: TextAlign.right,
  282. ),
  283. ),
  284. ],
  285. ),
  286. ),
  287. Container(
  288. padding: EdgeInsets.fromLTRB(12, 15, 12, 0),
  289. child: Row(
  290. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  291. children: [
  292. new Text(
  293. '巡检计划名称:',
  294. style: GSYConstant.smallTextLight,
  295. ),
  296. Container(
  297. child: Text(
  298. patrolJobDetailData.planName ?? "",
  299. style: GSYConstant.smallTextLight,
  300. textAlign: TextAlign.right,
  301. ),
  302. ),
  303. ])),
  304. Container(
  305. padding: EdgeInsets.fromLTRB(12, 15, 12, 0),
  306. child: Row(
  307. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  308. children: [
  309. new Text(
  310. '巡检计划编号:',
  311. style: GSYConstant.smallTextLight,
  312. ),
  313. Container(
  314. child: Text(
  315. patrolJobDetailData.planNumber!,
  316. style: GSYConstant.smallTextLight,
  317. textAlign: TextAlign.right,
  318. ),
  319. ),
  320. ])),
  321. Container(
  322. padding: EdgeInsets.fromLTRB(12, 15, 12, 0),
  323. child: Row(
  324. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  325. children: [
  326. new Text(
  327. '周期类型:',
  328. style: GSYConstant.smallTextLight,
  329. ),
  330. Container(
  331. child: Text(
  332. patrolJobDetailData.termType == 1 ? '日计划' : '暂无',
  333. style: GSYConstant.smallTextLight,
  334. textAlign: TextAlign.right,
  335. ),
  336. ),
  337. ])),
  338. Container(
  339. padding: EdgeInsets.fromLTRB(12, 15, 12, 0),
  340. child: Row(
  341. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  342. children: [
  343. new Text(
  344. '任务开始时间:',
  345. style: GSYConstant.smallTextLight,
  346. ),
  347. Container(
  348. child: Text(
  349. patrolJobDetailData.startDate!,
  350. style: GSYConstant.smallTextLight,
  351. textAlign: TextAlign.right,
  352. ),
  353. ),
  354. ])),
  355. Container(
  356. padding: EdgeInsets.fromLTRB(12, 15, 12, 0),
  357. child: Row(
  358. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  359. children: [
  360. new Text(
  361. '任务结束时间:',
  362. style: GSYConstant.smallTextLight,
  363. ),
  364. Container(
  365. child: Text(
  366. patrolJobDetailData.endDate!,
  367. style: GSYConstant.smallTextLight,
  368. textAlign: TextAlign.right,
  369. ),
  370. ),
  371. ])),
  372. Container(
  373. padding: EdgeInsets.fromLTRB(12, 15, 12, 0),
  374. child: Row(
  375. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  376. children: [
  377. new Text(
  378. '实际完成时间:',
  379. style: GSYConstant.smallTextLight,
  380. ),
  381. Container(
  382. child: Text(
  383. patrolJobDetailData.finishTime!,
  384. style: GSYConstant.smallTextLight,
  385. textAlign: TextAlign.right,
  386. ),
  387. ),
  388. ])),
  389. Container(
  390. padding: EdgeInsets.fromLTRB(12, 15, 12, 15),
  391. child: Row(
  392. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  393. children: [
  394. new Text(
  395. '巡检人员:',
  396. style: GSYConstant.smallTextLight,
  397. ),
  398. Container(
  399. child: Text(
  400. patrolJobDetailData.personnel!,
  401. style: GSYConstant.smallTextLight,
  402. textAlign: TextAlign.right,
  403. ),
  404. ),
  405. ])),
  406. ],
  407. ),
  408. ),
  409. ],
  410. );
  411. } else {
  412. return Text('暂无数据');
  413. }
  414. }
  415. Widget _device() {
  416. return ExpansionTile(
  417. title: Container(
  418. child: Text(
  419. '巡检设备',
  420. style: GSYConstant.normalTextActionWhiteBold,
  421. )),
  422. children: equipmentVOS.map((e) => _buildDevice(e)).toList(),
  423. initiallyExpanded: true);
  424. }
  425. Widget _buildDevice(PatrolJobDetailResponseDataEquipmentVOS device) {
  426. return FractionallySizedBox(
  427. widthFactor: 1,
  428. child: Container(
  429. margin: device.id ==
  430. responseData
  431. .equipmentVOS![responseData.equipmentVOS!.length - 1].id
  432. ? EdgeInsets.only(bottom: 0)
  433. : EdgeInsets.only(bottom: 5),
  434. decoration: BoxDecoration(color: Colors.white),
  435. padding: const EdgeInsets.fromLTRB(12, 12, 12, 12),
  436. child: Column(
  437. children: [
  438. Container(
  439. // padding: const EdgeInsets.fromLTRB(30.0, 0.0, 0.0, 0.0),
  440. alignment: Alignment.centerLeft,
  441. child: Row(
  442. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  443. children: [
  444. Text(device.showName, style: GSYConstant.smallTextBold),
  445. Text(
  446. device.isComplete == 0 ? '未完成' : '已完成',
  447. style: TextStyle(
  448. fontSize: GSYConstant.smallTextSize,
  449. color: device.isComplete == 0
  450. ? Colors.red
  451. : Colors.blue),
  452. ),
  453. ]),
  454. ),
  455. Container(
  456. margin: const EdgeInsets.only(top: 10),
  457. // padding: const EdgeInsets.fromLTRB(30.0, 0.0, 0.0, 10.0),
  458. // alignment: Alignment.centerLeft,
  459. child: Row(
  460. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  461. children: [
  462. new Text(
  463. '完成时间:',
  464. style: GSYConstant.smallTextLight,
  465. ),
  466. Container(
  467. child: Text(
  468. device.itemCompleteTime,
  469. style: GSYConstant.smallTextLight,
  470. textAlign: TextAlign.right,
  471. ),
  472. ),
  473. ]),
  474. ),
  475. // Divider(
  476. // height: 0.8,
  477. // indent: 10.0,
  478. // endIndent: 10.0,
  479. // color: Colors.grey,
  480. // ),
  481. ],
  482. ),
  483. ));
  484. }
  485. Widget _item() {
  486. return ExpansionTile(
  487. title: Container(
  488. child: Text(
  489. '巡检项目',
  490. style: GSYConstant.normalTextActionWhiteBold,
  491. )),
  492. children: patrolItemVOS.map((e) => _buildItem(e)).toList(),
  493. initiallyExpanded: true);
  494. }
  495. Widget _buildItem(PatrolJobDetailResponseDataPatrolItemVOS item) {
  496. return FractionallySizedBox(
  497. widthFactor: 1,
  498. child: Container(
  499. margin: item.id ==
  500. responseData
  501. .patrolItemVOS[responseData.patrolItemVOS.length - 1].id
  502. ? EdgeInsets.only(bottom: 0)
  503. : EdgeInsets.only(bottom: 5),
  504. padding: const EdgeInsets.fromLTRB(12, 15, 15, 0),
  505. decoration: BoxDecoration(color: Colors.white),
  506. child: Column(
  507. children: [
  508. Container(
  509. alignment: Alignment.centerLeft,
  510. child: Text(item.name,
  511. style: TextStyle(
  512. fontSize: GSYConstant.middleTextWhiteSize,
  513. fontWeight: FontWeight.bold)),
  514. ),
  515. Container(
  516. margin: const EdgeInsets.fromLTRB(0, 10.0, 0, 0),
  517. alignment: Alignment.centerLeft,
  518. child: Text(
  519. item.result,
  520. style: GSYConstant.smallTextLight,
  521. ),
  522. ),
  523. // Divider(
  524. // height: 0.8,
  525. // indent: 10.0,
  526. // endIndent: 10.0,
  527. // color: Colors.grey,
  528. // ),
  529. ],
  530. ),
  531. ));
  532. }
  533. Widget _remark() {
  534. return ExpansionTile(
  535. title: Container(
  536. child: Text(
  537. '任务结果备注',
  538. style: GSYConstant.normalTextActionWhiteBold,
  539. )),
  540. children: [_buildRemark(responseData)],
  541. initiallyExpanded: true);
  542. }
  543. Widget _buildRemark(PatrolJobDetailResponseData patrolJobDetailData) {
  544. return FractionallySizedBox(
  545. widthFactor: 1,
  546. child: Container(
  547. decoration: BoxDecoration(color: Colors.white),
  548. child: Column(
  549. children: [
  550. Container(
  551. margin: const EdgeInsets.fromLTRB(12, 15.0, 12, 15.0),
  552. alignment: Alignment.centerLeft,
  553. child: Text(patrolJobDetailData.remarks,
  554. style: TextStyle(fontSize: 14)),
  555. )
  556. ],
  557. ),
  558. ));
  559. }
  560. Widget _url() {
  561. return ExpansionTile(
  562. title: Container(
  563. child: Text(
  564. '任务图片',
  565. style: GSYConstant.normalTextActionWhiteBold,
  566. )),
  567. children: [
  568. Wrap(children: fileUrls.map((e) => _buildImage(e)).toList()),
  569. ],
  570. initiallyExpanded: true);
  571. }
  572. Widget _buildImage(String imageData) {
  573. return Container(
  574. width: MediaQuery.of(context).size.width / 2,
  575. margin: EdgeInsets.only(bottom: 5),
  576. padding: EdgeInsets.only(left: 12, right: 12),
  577. alignment: Alignment.center,
  578. decoration: BoxDecoration(color: Colors.white),
  579. child: Image.network(imageData));
  580. }
  581. @override
  582. void dispose() {
  583. super.dispose();
  584. _event.cancel();
  585. }
  586. }