repair_detail.dart 19 KB

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