maint_job_detail.dart 22 KB

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