maint_job_detail.dart 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587
  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 ('' != 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. Container(
  233. decoration: BoxDecoration(color: Colors.white),
  234. child: Column(
  235. children: [
  236. Container(
  237. padding: EdgeInsets.fromLTRB(12, 20, 12, 0),
  238. alignment: Alignment.centerLeft,
  239. child: Row(
  240. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  241. children: [
  242. new Text(
  243. '维保产品数:',
  244. style: GSYConstant.smallTextLight,
  245. ),
  246. Container(
  247. child: Text(
  248. maintJobDetail.prodCount == null
  249. ? '暂无'
  250. : maintJobDetail.prodCount.toString(),
  251. style: GSYConstant.smallTextLight,
  252. textAlign: TextAlign.right,
  253. ),
  254. ),
  255. ],
  256. ),
  257. ),
  258. Container(
  259. padding: EdgeInsets.fromLTRB(12, 15, 12, 0),
  260. child: Row(
  261. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  262. children: [
  263. new Text(
  264. '任务开始时间:',
  265. style: GSYConstant.smallTextLight,
  266. ),
  267. Container(
  268. child: Text(
  269. maintJobDetail.startTime == null
  270. ? '暂无'
  271. : maintJobDetail.startTime!,
  272. style: GSYConstant.smallTextLight,
  273. textAlign: TextAlign.right,
  274. ),
  275. ),
  276. ],
  277. ),
  278. ),
  279. Container(
  280. padding: EdgeInsets.fromLTRB(12, 15, 12, 0),
  281. child: Row(
  282. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  283. children: [
  284. new Text(
  285. '任务结束时间:',
  286. style: GSYConstant.smallTextLight,
  287. ),
  288. Container(
  289. child: Text(
  290. maintJobDetail.endTime == null
  291. ? '暂无'
  292. : maintJobDetail.endTime!,
  293. style: GSYConstant.smallTextLight,
  294. textAlign: TextAlign.right,
  295. ),
  296. ),
  297. ])),
  298. Container(
  299. padding: EdgeInsets.fromLTRB(12, 15, 12, 0),
  300. child: Row(
  301. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  302. children: [
  303. new Text(
  304. '维保计划名称:',
  305. style: GSYConstant.smallTextLight,
  306. ),
  307. Container(
  308. child: Text(
  309. maintJobDetail.planName == null
  310. ? '暂无'
  311. : maintJobDetail.planName!,
  312. style: GSYConstant.smallTextLight,
  313. textAlign: TextAlign.right,
  314. ),
  315. ),
  316. ])),
  317. Container(
  318. padding: EdgeInsets.fromLTRB(12, 15, 12, 0),
  319. child: Row(
  320. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  321. children: [
  322. new Text(
  323. '维保计划编号:',
  324. style: GSYConstant.smallTextLight,
  325. ),
  326. Container(
  327. child: Text(
  328. maintJobDetail.planNum == null
  329. ? '暂无'
  330. : maintJobDetail.planNum!,
  331. style: GSYConstant.smallTextLight,
  332. textAlign: TextAlign.right,
  333. ),
  334. ),
  335. ])),
  336. Container(
  337. padding: EdgeInsets.fromLTRB(12, 15, 12, 0),
  338. child: Row(
  339. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  340. children: [
  341. new Text(
  342. '周期类型:',
  343. style: GSYConstant.smallTextLight,
  344. ),
  345. Container(
  346. child: Text(
  347. maintJobDetail.cycleType == 1
  348. ? '日计划'
  349. : maintJobDetail.cycleType == 2
  350. ? '周计划'
  351. : maintJobDetail.cycleType == 3
  352. ? '月计划'
  353. : '暂无',
  354. style: GSYConstant.smallTextLight,
  355. textAlign: TextAlign.right,
  356. ),
  357. ),
  358. ])),
  359. Container(
  360. padding: EdgeInsets.fromLTRB(12, 15, 12, 0),
  361. child: Row(
  362. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  363. children: [
  364. new Text(
  365. '维保完成时间:',
  366. style: GSYConstant.smallTextLight,
  367. ),
  368. Container(
  369. child: Text(
  370. maintJobDetail.finishTime == null
  371. ? '暂无'
  372. : maintJobDetail.finishTime!,
  373. style: GSYConstant.smallTextLight,
  374. textAlign: TextAlign.right,
  375. ),
  376. ),
  377. ])),
  378. Container(
  379. padding: EdgeInsets.fromLTRB(12, 15, 12, 15),
  380. child: Row(
  381. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  382. children: [
  383. new Text(
  384. '维保人员:',
  385. style: GSYConstant.smallTextLight,
  386. ),
  387. Container(
  388. child: Text(
  389. maintJobDetail.maintStaffName == null
  390. ? '暂无'
  391. : maintJobDetail.maintStaffName!,
  392. style: GSYConstant.smallTextLight,
  393. textAlign: TextAlign.right,
  394. ),
  395. ),
  396. ])),
  397. ],
  398. ),
  399. ),
  400. ],
  401. );
  402. }
  403. Widget _device() {
  404. return ExpansionTile(
  405. title: Container(
  406. child: Text(
  407. '维保设备',
  408. style: GSYConstant.normalTextActionWhiteBold,
  409. )),
  410. children: deviceList.map((e) => _buildDevice(e)).toList(),
  411. initiallyExpanded: true);
  412. }
  413. Widget _buildDevice(DeviceList device) {
  414. return FractionallySizedBox(
  415. widthFactor: 1,
  416. child: Container(
  417. margin: device.id == deviceList[deviceList.length - 1].id
  418. ? EdgeInsets.only(bottom: 0)
  419. : EdgeInsets.only(bottom: 5),
  420. decoration: BoxDecoration(color: Colors.white),
  421. padding: const EdgeInsets.fromLTRB(12, 12, 12, 12),
  422. child: Column(
  423. children: [
  424. Container(
  425. margin: const EdgeInsets.only(top: 10),
  426. // padding: const EdgeInsets.fromLTRB(30.0, 0.0, 0.0, 0.0),
  427. child: Row(
  428. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  429. children: [
  430. new Text(
  431. '设备名称:',
  432. style: GSYConstant.smallTextBold,
  433. ),
  434. Container(
  435. child: Text(
  436. device.showName!,
  437. style: GSYConstant.smallTextBold,
  438. textAlign: TextAlign.right,
  439. ),
  440. ),
  441. ]),
  442. ),
  443. // Divider(
  444. // height: 0.8,
  445. // indent: 10.0,
  446. // endIndent: 10.0,
  447. // color: Colors.grey,
  448. // ),
  449. ],
  450. ),
  451. ));
  452. }
  453. Widget _item() {
  454. return ExpansionTile(
  455. title: Container(
  456. child: Text(
  457. '维保项目',
  458. style: GSYConstant.normalTextActionWhiteBold,
  459. )),
  460. children: itemList.map((e) => _buildItem(e)).toList(),
  461. initiallyExpanded: false);
  462. }
  463. Widget _buildItem(ItemsList item) {
  464. return FractionallySizedBox(
  465. widthFactor: 1,
  466. child: Container(
  467. margin: item.id == itemList[itemList.length - 1].id
  468. ? EdgeInsets.only(bottom: 0)
  469. : EdgeInsets.only(bottom: 5),
  470. padding: const EdgeInsets.fromLTRB(12, 10, 15, 10),
  471. decoration: BoxDecoration(color: Colors.white),
  472. child: Column(
  473. children: [
  474. Container(
  475. alignment: Alignment.centerLeft,
  476. child: Text(item.name == null ? '' : item.name!,
  477. style: TextStyle(
  478. fontSize: GSYConstant.middleTextWhiteSize,
  479. fontWeight: FontWeight.bold)),
  480. ),
  481. Container(
  482. margin: const EdgeInsets.fromLTRB(0, 10.0, 0, 0),
  483. alignment: Alignment.centerLeft,
  484. child: Text(
  485. item.requirements!,
  486. style: GSYConstant.smallTextLight,
  487. ),
  488. ),
  489. ],
  490. ),
  491. ));
  492. }
  493. Widget _remark() {
  494. return ExpansionTile(
  495. title: Container(
  496. child: Text(
  497. '任务结果备注',
  498. style: GSYConstant.normalTextActionWhiteBold,
  499. )),
  500. children: [_buildRemark(maintJobDetail.remarks!)],
  501. initiallyExpanded: false);
  502. }
  503. Widget _buildRemark(String patrolJobDetailData) {
  504. return FractionallySizedBox(
  505. widthFactor: 1,
  506. child: Container(
  507. decoration: BoxDecoration(color: Colors.white),
  508. child: Column(
  509. children: [
  510. Container(
  511. margin: const EdgeInsets.fromLTRB(12, 15.0, 12, 15.0),
  512. alignment: Alignment.centerLeft,
  513. child:
  514. Text(patrolJobDetailData, style: TextStyle(fontSize: 14)),
  515. )
  516. ],
  517. ),
  518. ));
  519. }
  520. Widget _url() {
  521. return ExpansionTile(
  522. title: Container(
  523. child: Text(
  524. '维保图片',
  525. style: GSYConstant.normalTextActionWhiteBold,
  526. )),
  527. children: [
  528. Container(
  529. width: double.infinity,
  530. margin: EdgeInsets.only(bottom: 5),
  531. padding: fileUrls.isNotEmpty?EdgeInsets.only(right: 12, top: 10):EdgeInsets.only(right: 0, top: 0),
  532. color: Colors.white,
  533. child: Wrap(children: fileUrls.map((e) => _buildImage(e)).toList()),
  534. alignment: Alignment.centerLeft,
  535. )
  536. ],
  537. initiallyExpanded: false);
  538. }
  539. Widget _buildImage(FileUrls imageData) {
  540. return Container(
  541. margin: EdgeInsets.only(left: 12, bottom: 10),
  542. width: MediaQuery.of(context).size.width / 4,
  543. height: MediaQuery.of(context).size.width / 4,
  544. child: Image.network(
  545. imageData.url!,
  546. fit: BoxFit.fill,
  547. ));
  548. }
  549. closeJob(String msg) async {
  550. var result = await DioUtil().request('maintJob/close',
  551. method: DioMethod.post, data: {'id': id, 'closeReason': msg});
  552. if (0 == result['code']) {
  553. setState(() {
  554. eventBus.fire(RefreshMaintPage());
  555. Navigator.pop(context);
  556. });
  557. } else {
  558. showToast(result['msg']);
  559. }
  560. }
  561. }