maint_job_detail.dart 21 KB

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