maint_job_detail.dart 21 KB

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