maint_job_detail.dart 19 KB

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