repair_detail.dart 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574
  1. import 'package:deus_app/common/dialog/CloseTaskDialog.dart';
  2. import 'package:deus_app/common/event/RefreshRepairDetail.dart';
  3. import 'package:deus_app/common/event/RefreshRepairPage.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/DioUtil.dart';
  8. import 'package:deus_app/common/utils/ToastUtils.dart';
  9. import 'package:deus_app/generated/json/repair_detail_response_entity_helper.dart';
  10. import 'package:deus_app/main.dart';
  11. import 'package:deus_app/model/repair_detail_response_entity.dart';
  12. import 'package:deus_app/page/repair/repair_job_edit.dart';
  13. import 'package:flutter/material.dart';
  14. class RepairDetail extends StatefulWidget {
  15. var id;
  16. RepairDetail({super.key, required this.id});
  17. @override
  18. State createState() {
  19. return _RepairDetail(id);
  20. }
  21. }
  22. class _RepairDetail extends State<RepairDetail> {
  23. var id;
  24. bool type = false;
  25. RepairDetailResponseData responseData = RepairDetailResponseData();
  26. List<String> repairImgUrls = [];
  27. List<String> repairResUrls = [];
  28. String buttonText='';
  29. var _event;
  30. bool isClose=false;
  31. _RepairDetail(this.id);
  32. @override
  33. void initState() {
  34. super.initState();
  35. _load();
  36. _event = eventBus.on<RefreshRepairDetail>().listen((event) {
  37. setState(() {
  38. _load();
  39. });
  40. });
  41. }
  42. @override
  43. Widget build(BuildContext context) {
  44. return Scaffold(
  45. resizeToAvoidBottomInset: false,
  46. appBar: TitleBar().backAppbar("报修详情"),
  47. backgroundColor: const Color(0xfff2f2f2),
  48. body: Stack(
  49. children: [
  50. Container(
  51. margin: EdgeInsets.only(bottom: type ? 60 : 0),
  52. child: ListView(
  53. children: _Ws(),
  54. ),
  55. ),
  56. Visibility(
  57. visible: type,
  58. child: Positioned(
  59. left: 0,
  60. right: 0,
  61. bottom: 0,
  62. // flex: 7,
  63. child: Row(
  64. children: [
  65. Visibility(
  66. visible: isClose,
  67. child: Expanded(
  68. child: SizedBox(
  69. height: 50,
  70. child: TextButton(
  71. onPressed: () {
  72. CloseTaskDialog.showCupertinoAlertDialog(context,
  73. (msg) {
  74. closeJob(msg);
  75. });
  76. },
  77. style: ButtonStyle(
  78. backgroundColor: MaterialStateProperty.all<Color>(
  79. Colors.blue),
  80. shape: MaterialStateProperty.all(
  81. BeveledRectangleBorder(
  82. borderRadius: BorderRadius.circular(0))),
  83. foregroundColor: MaterialStateProperty.all<Color>(
  84. Colors.white),
  85. // padding: MaterialStateProperty.all(EdgeInsets.zero)
  86. ),
  87. child: const Text(ConstantString.close_job),
  88. ),
  89. ),
  90. ),
  91. ),
  92. Expanded(
  93. child: SizedBox(
  94. height: 50,
  95. child: TextButton(
  96. onPressed: () {
  97. if (type) {
  98. if('维修接单'==buttonText){
  99. CloseTaskDialog.showAlertDialog(context, () {
  100. receive();
  101. }, '确认维修接单么?');
  102. }else if('开始维修'==buttonText){
  103. CloseTaskDialog.showAlertDialog(context, () {
  104. start();
  105. }, '确认后不支持更换维修人员');
  106. }else{
  107. Navigator.push(
  108. context,
  109. MaterialPageRoute(
  110. builder: (context) =>
  111. RepairJobEdit(responseData: responseData)));
  112. }
  113. }
  114. },
  115. style: ButtonStyle(
  116. backgroundColor:
  117. MaterialStateProperty.all<Color>(Color(0xFF4875EC)),
  118. foregroundColor:
  119. MaterialStateProperty.all<Color>(Colors.white),
  120. shape: MaterialStateProperty.all(
  121. BeveledRectangleBorder(
  122. borderRadius: BorderRadius.circular(0))),
  123. // padding: MaterialStateProperty.all(EdgeInsets.zero)
  124. ),
  125. child: Text(buttonText),
  126. ),
  127. )),
  128. ],
  129. ),
  130. ))
  131. ],
  132. ),
  133. );
  134. }
  135. List<Widget> _Ws() {
  136. List<Widget> ws = [];
  137. ws.add(_patrolJobDetail(responseData));
  138. ws.add(_basicInformation());
  139. ws.add(_notes());
  140. ws.add(_img());
  141. return ws;
  142. }
  143. Widget _notes() {
  144. return Column(children: [
  145. Container(
  146. height: 50,
  147. padding: EdgeInsets.only(left: 12),
  148. alignment: Alignment.centerLeft,
  149. child: const Text(
  150. '维修结果备注:',
  151. style: TextStyle(
  152. color: Colors.black,
  153. fontSize: GSYConstant.TextSize15,
  154. ),
  155. ),
  156. ),
  157. Container(
  158. color: Colors.white,
  159. padding: EdgeInsets.only(left: 12, right: 12, top: 10, bottom: 10),
  160. alignment: Alignment.centerLeft,
  161. child: Text(
  162. responseData.repResRemarks == null
  163. ? '无'
  164. : responseData.repResRemarks!,
  165. style: const TextStyle(
  166. color: Colors.black,
  167. fontSize: GSYConstant.TextSize15,
  168. ),
  169. ),
  170. ),
  171. ]);
  172. }
  173. Widget _img() {
  174. return Column(children: [
  175. Container(
  176. height: 50,
  177. padding: EdgeInsets.only(left: 12),
  178. alignment: Alignment.centerLeft,
  179. child: const Text(
  180. '维修图片:',
  181. style: TextStyle(
  182. color: Colors.black,
  183. fontSize: GSYConstant.TextSize15,
  184. ),
  185. ),
  186. ),
  187. Container(
  188. width: double.infinity,
  189. margin: EdgeInsets.only(bottom: 5),
  190. padding: repairResUrls.isNotEmpty?EdgeInsets.only(right: 12, top: 10):EdgeInsets.only(right: 0, top: 0),
  191. color: Colors.white,
  192. child: Wrap(
  193. children: repairResUrls.map((e) => _buildImage(e)).toList()),
  194. alignment: Alignment.centerLeft,
  195. )
  196. ]);
  197. }
  198. Widget _basicInformation() {
  199. return Column(children: [
  200. Container(
  201. height: 50,
  202. padding: EdgeInsets.only(left: 12),
  203. alignment: Alignment.centerLeft,
  204. child: const Text(
  205. '基本信息:',
  206. style: TextStyle(
  207. color: Colors.black,
  208. fontSize: GSYConstant.TextSize15,
  209. ),
  210. ),
  211. ),
  212. Container(
  213. color: Colors.white,
  214. padding: EdgeInsets.only(left: 12, right: 12, top: 15, bottom: 15),
  215. child: Column(
  216. crossAxisAlignment: CrossAxisAlignment.start,
  217. children: [
  218. Row(
  219. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  220. children: [
  221. const Text(
  222. '紧急程度:',
  223. style: GSYConstant.smallTextLight,
  224. ),
  225. Text(
  226. responseData.urg == 1 ? "一般" : "紧急",
  227. style: GSYConstant.smallTextLight,
  228. textAlign: TextAlign.right,
  229. ),
  230. ],
  231. ),
  232. const SizedBox(
  233. height: 12,
  234. ),
  235. Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
  236. const Text(
  237. '报修设备:',
  238. style: GSYConstant.smallTextLight,
  239. ),
  240. Text(
  241. responseData.device == null
  242. ? ''
  243. : responseData.device!.showName!,
  244. style: GSYConstant.smallTextLight,
  245. textAlign: TextAlign.right,
  246. ),
  247. ]),
  248. const SizedBox(
  249. height: 12,
  250. ),
  251. Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
  252. const Text(
  253. '报修说明:',
  254. style: GSYConstant.smallTextLight,
  255. ),
  256. Text(
  257. responseData.instructions == null
  258. ? '无'
  259. : responseData.instructions!,
  260. style: GSYConstant.smallTextLight,
  261. textAlign: TextAlign.right,
  262. ),
  263. ]),
  264. const SizedBox(
  265. height: 12,
  266. ),
  267. const Text(
  268. '图片说明:',
  269. style: GSYConstant.smallTextLight,
  270. textAlign: TextAlign.left,
  271. ),
  272. const SizedBox(
  273. height: 10,
  274. ),
  275. Container(
  276. width: double.infinity,
  277. // margin: EdgeInsets.only(bottom: 5),
  278. // padding: fileUrls.isNotEmpty?EdgeInsets.only(right: 12, top: 10):EdgeInsets.only(right: 0, top: 0),
  279. color: Colors.white,
  280. child: Wrap(
  281. children: repairImgUrls.map((e) => _buildImage(e)).toList()),
  282. alignment: Alignment.centerLeft,
  283. )
  284. ],
  285. ),
  286. )
  287. ]);
  288. }
  289. Widget _buildImage(String imageData) {
  290. return Container(
  291. margin: EdgeInsets.only(left: 12, bottom: 10),
  292. width: MediaQuery.of(context).size.width / 4,
  293. height: MediaQuery.of(context).size.width / 4,
  294. child: Image.network(
  295. imageData,
  296. fit: BoxFit.fill,
  297. ));
  298. }
  299. Widget _patrolJobDetail(RepairDetailResponseData patrolJobDetailData) {
  300. return Column(
  301. children: [
  302. Row(
  303. children: [
  304. Container(
  305. margin: EdgeInsets.only(top: 10, left: 12),
  306. // padding: EdgeInsets.fromLTRB(12, 0, 0, 0),
  307. alignment: Alignment.bottomLeft,
  308. child: Text(
  309. patrolJobDetailData.theme == null
  310. ? '暂无'
  311. : patrolJobDetailData.theme!,
  312. style: TextStyle(
  313. fontSize: GSYConstant.middleTextWhiteSize,
  314. fontWeight: FontWeight.bold),
  315. ),
  316. ),
  317. Container(
  318. margin: const EdgeInsets.only(top: 10, left: 10),
  319. padding: const EdgeInsets.fromLTRB(3, 2, 3, 2),
  320. alignment: Alignment.centerLeft,
  321. decoration: BoxDecoration(
  322. border: Border.all(
  323. color: patrolJobDetailData.status == 1 ||
  324. patrolJobDetailData.status == 2
  325. ? Colors.red
  326. : patrolJobDetailData.status == 3
  327. ? Colors.orange
  328. : patrolJobDetailData.status == 4 ||
  329. patrolJobDetailData.status == 5
  330. ? Colors.blue
  331. : Colors.black, //边框颜色
  332. width: 1.0, //边框粗细
  333. ),
  334. borderRadius:
  335. const BorderRadius.all(const Radius.circular(3.0)), //边框的弧度
  336. ),
  337. child: Text(
  338. patrolJobDetailData.status == 1
  339. ? '待接单'
  340. : patrolJobDetailData.status == 2
  341. ? '待执行'
  342. : patrolJobDetailData.status == 3
  343. ? '维修中'
  344. : patrolJobDetailData.status == 4
  345. ? '已关闭'
  346. : patrolJobDetailData.status == 5
  347. ? '已完成'
  348. : '未知',
  349. style: TextStyle(
  350. fontSize: GSYConstant.minTextSize,
  351. color: patrolJobDetailData.status == 1 ||
  352. patrolJobDetailData.status == 2
  353. ? Colors.red
  354. : patrolJobDetailData.status == 3
  355. ? Colors.orange
  356. : patrolJobDetailData.status == 4 ||
  357. patrolJobDetailData.status == 5
  358. ? Colors.blue
  359. : Colors.black, //边框颜色
  360. ),
  361. ),
  362. )
  363. ],
  364. ),
  365. Container(
  366. margin: const EdgeInsets.only(top: 10, left: 12, bottom: 12),
  367. alignment: Alignment.centerLeft,
  368. child: Text(
  369. '报修单号: ' + patrolJobDetailData.repNum,
  370. style: TextStyle(
  371. fontSize: GSYConstant.smallTextSize,
  372. ),
  373. ),
  374. ),
  375. // Divider(
  376. // height: 0.8,
  377. // indent: 5.0,
  378. // endIndent: 5.0,
  379. // color: Colors.grey,
  380. // ),
  381. Container(
  382. decoration: BoxDecoration(color: Colors.white),
  383. child: Column(
  384. children: [
  385. Container(
  386. padding: EdgeInsets.fromLTRB(12, 15, 12, 0),
  387. alignment: Alignment.centerLeft,
  388. child: Row(
  389. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  390. children: [
  391. new Text(
  392. '申请人:',
  393. style: GSYConstant.smallTextLight,
  394. ),
  395. Container(
  396. child: Text(
  397. patrolJobDetailData.applicant,
  398. style: GSYConstant.smallTextLight,
  399. textAlign: TextAlign.right,
  400. ),
  401. ),
  402. ],
  403. ),
  404. ),
  405. Container(
  406. padding: EdgeInsets.fromLTRB(12, 12, 12, 0),
  407. child: Row(
  408. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  409. children: [
  410. new Text(
  411. '申请时间:',
  412. style: GSYConstant.smallTextLight,
  413. ),
  414. Container(
  415. child: Text(
  416. patrolJobDetailData.applicationTime,
  417. style: GSYConstant.smallTextLight,
  418. textAlign: TextAlign.right,
  419. ),
  420. ),
  421. ],
  422. ),
  423. ),
  424. Container(
  425. padding: EdgeInsets.fromLTRB(12, 12, 12, 0),
  426. child: Row(
  427. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  428. children: [
  429. new Text(
  430. '维修人员:',
  431. style: GSYConstant.smallTextLight,
  432. ),
  433. Container(
  434. child: Text(
  435. patrolJobDetailData.maintainer,
  436. style: GSYConstant.smallTextLight,
  437. textAlign: TextAlign.right,
  438. ),
  439. ),
  440. ])),
  441. Container(
  442. padding: EdgeInsets.fromLTRB(12, 12, 12, 0),
  443. child: Row(
  444. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  445. children: [
  446. new Text(
  447. '接单时间:',
  448. style: GSYConstant.smallTextLight,
  449. ),
  450. Container(
  451. child: Text(
  452. patrolJobDetailData.orderRecTime,
  453. style: GSYConstant.smallTextLight,
  454. textAlign: TextAlign.right,
  455. ),
  456. ),
  457. ])),
  458. Container(
  459. padding: EdgeInsets.fromLTRB(12, 12, 12, 15),
  460. child: Row(
  461. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  462. children: [
  463. const Text(
  464. '完成时间:',
  465. style: GSYConstant.smallTextLight,
  466. ),
  467. Text(
  468. patrolJobDetailData.completeTime,
  469. style: GSYConstant.smallTextLight,
  470. textAlign: TextAlign.right,
  471. ),
  472. ])),
  473. ],
  474. ),
  475. ),
  476. ],
  477. );
  478. }
  479. _load() async {
  480. var result = await DioUtil().request('repair-bill/app-detail',
  481. method: DioMethod.post, data: {'id': id});
  482. RepairDetailResponseEntity patrolJobResponse =
  483. repairDetailResponseEntityFromJson(
  484. RepairDetailResponseEntity(), result);
  485. if (patrolJobResponse.code == 0) {
  486. setState(() {
  487. responseData = patrolJobResponse.data;
  488. repairImgUrls.clear();
  489. repairImgUrls.addAll(responseData.repairImgUrls);
  490. repairResUrls.clear();
  491. repairResUrls.addAll(responseData.repairResUrls);
  492. if (responseData.status == 1 || responseData.status == 2|| responseData.status == 3) {
  493. type = true;
  494. if(responseData.status == 1){
  495. isClose=true;
  496. buttonText='维修接单';
  497. }else if(responseData.status==2){
  498. isClose=false;
  499. buttonText='开始维修';
  500. }else if(responseData.status==3){
  501. buttonText='登记维修';
  502. }
  503. }
  504. });
  505. } else {
  506. showToast(patrolJobResponse.msg);
  507. }
  508. }
  509. @override
  510. void dispose() {
  511. super.dispose();
  512. _event.cancel();
  513. }
  514. closeJob(String msg) async {
  515. var result = await DioUtil().request('patrolJob/closeJob',
  516. method: DioMethod.post, data: {'id': id, 'closeReason': msg});
  517. if (0 == result['code']) {
  518. setState(() {
  519. eventBus.fire(RefreshRepairPage());
  520. Navigator.pop(context);
  521. });
  522. } else {
  523. showToast(result['msg']);
  524. }
  525. }
  526. receive() async {
  527. var result = await DioUtil().request('repair-bill/receive',
  528. method: DioMethod.post, data: {'id': id});
  529. if (0 == result['code']) {
  530. setState(() {
  531. _load();
  532. });
  533. } else {
  534. showToast(result['msg']);
  535. }
  536. }
  537. start() async {
  538. var result = await DioUtil().request('repair-bill/start',
  539. method: DioMethod.post, data: {'id': id});
  540. if (0 == result['code']) {
  541. setState(() {
  542. _load();
  543. });
  544. } else {
  545. showToast(result['msg']);
  546. }
  547. }
  548. }